Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e2d770a3
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2d770a3
编写于
4月 29, 2015
作者:
N
Nick Hamann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some missing punctuation in the libstd/net/ip.rs docs.
上级
42196ae7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
19 deletion
+19
-19
src/libstd/net/ip.rs
src/libstd/net/ip.rs
+19
-19
未找到文件。
src/libstd/net/ip.rs
浏览文件 @
e2d770a3
...
...
@@ -60,7 +60,7 @@ pub enum Ipv6MulticastScope {
impl
Ipv4Addr
{
/// Creates a new IPv4 address from four eight-bit octets.
///
/// The result will represent the IP address
a.b.c.d
/// The result will represent the IP address
`a`.`b`.`c`.`d`.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
new
(
a
:
u8
,
b
:
u8
,
c
:
u8
,
d
:
u8
)
->
Ipv4Addr
{
Ipv4Addr
{
...
...
@@ -73,19 +73,19 @@ pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
}
}
/// Returns the four eight-bit integers that make up this address
/// Returns the four eight-bit integers that make up this address
.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
octets
(
&
self
)
->
[
u8
;
4
]
{
let
bits
=
ntoh
(
self
.inner.s_addr
);
[(
bits
>>
24
)
as
u8
,
(
bits
>>
16
)
as
u8
,
(
bits
>>
8
)
as
u8
,
bits
as
u8
]
}
/// Returns true for the special 'unspecified' address 0.0.0.0
/// Returns true for the special 'unspecified' address 0.0.0.0
.
pub
fn
is_unspecified
(
&
self
)
->
bool
{
self
.inner.s_addr
==
0
}
/// Returns true if this is a loopback address (127.0.0.0/8)
/// Returns true if this is a loopback address (127.0.0.0/8)
.
pub
fn
is_loopback
(
&
self
)
->
bool
{
self
.octets
()[
0
]
==
127
}
...
...
@@ -106,7 +106,7 @@ pub fn is_private(&self) -> bool {
}
}
/// Returns true if the address is link-local (169.254.0.0/16)
/// Returns true if the address is link-local (169.254.0.0/16)
.
pub
fn
is_link_local
(
&
self
)
->
bool
{
self
.octets
()[
0
]
==
169
&&
self
.octets
()[
1
]
==
254
}
...
...
@@ -116,7 +116,7 @@ pub fn is_link_local(&self) -> bool {
/// Non-globally-routable networks include the private networks (10.0.0.0/8,
/// 172.16.0.0/12 and 192.168.0.0/16), the loopback network (127.0.0.0/8),
/// the link-local network (169.254.0.0/16), the broadcast address (255.255.255.255/32) and
/// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
/// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
.
pub
fn
is_global
(
&
self
)
->
bool
{
!
self
.is_private
()
&&
!
self
.is_loopback
()
&&
!
self
.is_link_local
()
&&
!
self
.is_broadcast
()
&&
!
self
.is_documentation
()
...
...
@@ -131,13 +131,13 @@ pub fn is_multicast(&self) -> bool {
/// Returns true if this is a broadcast address.
///
/// A broadcast address has all octets set to 255 as defined in RFC 919
/// A broadcast address has all octets set to 255 as defined in RFC 919
.
pub
fn
is_broadcast
(
&
self
)
->
bool
{
self
.octets
()[
0
]
==
255
&&
self
.octets
()[
1
]
==
255
&&
self
.octets
()[
2
]
==
255
&&
self
.octets
()[
3
]
==
255
}
/// Returns true if this address is in a range designated for documentation
/// Returns true if this address is in a range designated for documentation
.
///
/// This is defined in RFC 5737
/// - 192.0.2.0/24 (TEST-NET-1)
...
...
@@ -152,7 +152,7 @@ pub fn is_documentation(&self) -> bool {
}
}
/// Converts this address to an IPv4-compatible IPv6 address
/// Converts this address to an IPv4-compatible IPv6 address
.
///
/// a.b.c.d becomes ::a.b.c.d
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -162,7 +162,7 @@ pub fn to_ipv6_compatible(&self) -> Ipv6Addr {
((
self
.octets
()[
2
]
as
u16
)
<<
8
)
|
self
.octets
()[
3
]
as
u16
)
}
/// Converts this address to an IPv4-mapped IPv6 address
/// Converts this address to an IPv4-mapped IPv6 address
.
///
/// a.b.c.d becomes ::ffff:a.b.c.d
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -247,7 +247,7 @@ fn from_inner(addr: libc::in_addr) -> Ipv4Addr {
impl
Ipv6Addr
{
/// Creates a new IPv6 address from eight 16-bit segments.
///
/// The result will represent the IP address a:b:c:d:e:f:g:h
/// The result will represent the IP address a:b:c:d:e:f:g:h
.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
new
(
a
:
u16
,
b
:
u16
,
c
:
u16
,
d
:
u16
,
e
:
u16
,
f
:
u16
,
g
:
u16
,
h
:
u16
)
->
Ipv6Addr
{
...
...
@@ -259,7 +259,7 @@ pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
}
}
/// Returns the eight 16-bit segments that make up this address
/// Returns the eight 16-bit segments that make up this address
.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
segments
(
&
self
)
->
[
u16
;
8
]
{
[
ntoh
(
self
.inner.s6_addr
[
0
]),
...
...
@@ -272,12 +272,12 @@ pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16,
ntoh
(
self
.inner.s6_addr
[
7
])]
}
/// Returns true for the special 'unspecified' address ::
/// Returns true for the special 'unspecified' address ::
.
pub
fn
is_unspecified
(
&
self
)
->
bool
{
self
.segments
()
==
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]
}
/// Returns true if this is a loopback address (::1)
/// Returns true if this is a loopback address (::1)
.
pub
fn
is_loopback
(
&
self
)
->
bool
{
self
.segments
()
==
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
]
}
...
...
@@ -295,25 +295,25 @@ pub fn is_global(&self) -> bool {
}
}
/// Returns true if this is a unique local address (IPv6)
/// Returns true if this is a unique local address (IPv6)
.
///
/// Unique local addresses are defined in RFC4193 and have the form fc00::/7
/// Unique local addresses are defined in RFC4193 and have the form fc00::/7
.
pub
fn
is_unique_local
(
&
self
)
->
bool
{
(
self
.segments
()[
0
]
&
0xfe00
)
==
0xfc00
}
/// Returns true if the address is unicast and link-local (fe80::/10)
/// Returns true if the address is unicast and link-local (fe80::/10)
.
pub
fn
is_unicast_link_local
(
&
self
)
->
bool
{
(
self
.segments
()[
0
]
&
0xffc0
)
==
0xfe80
}
/// Returns true if this is a deprecated unicast site-local address (IPv6
/// fec0::/10)
/// fec0::/10)
.
pub
fn
is_unicast_site_local
(
&
self
)
->
bool
{
(
self
.segments
()[
0
]
&
0xffc0
)
==
0xfec0
}
/// Returns true if the address is a globally routable unicast address
/// Returns true if the address is a globally routable unicast address
.
///
/// Non-globally-routable unicast addresses include the loopback address,
/// the link-local addresses, the deprecated site-local addresses and the
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录