Struct std::net::SocketAddrV61.0.0[−][src]

pub struct SocketAddrV6 { /* fields omitted */ }
Expand description

IPv6 套接字地址。

IPv6 套接字地址由 IPv6 address,16 位端口号以及包含流量类别,流标签和作用域标识符的字段组成 (有关更多详细信息,请参见 IETF RFC 2553, Section 3.3)。

有关同时包含 IPv4 和 IPv6 套接字地址的类型,请参见 SocketAddr。

SocketAddrV6 结构体的大小可能会因目标操作系统而异。不要假设此类型与底层系统表示具有相同的内存布局。

Examples

use std::net::{Ipv6Addr, SocketAddrV6};

let socket = SocketAddrV6::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1), 8080, 0, 0);

assert_eq!("[2001:db8::1]:8080".parse(), Ok(socket));
assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1));
assert_eq!(socket.port(), 8080);
Run

Implementations

从 IPv6 address,16 位端口号以及 flowinfo 和 scope_id 字段创建新的套接字地址。

有关 flowinfo 和 scope_id 参数的含义和布局的更多信息,请参见 IETF RFC 2553, Section 3.3。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
Run

返回与此套接字地址关联的 IP 地址。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
assert_eq!(socket.ip(), &Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
Run

更改与此套接字地址关联的 IP 地址。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
socket.set_ip(Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
Run

返回与此套接字地址关联的端口号。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
assert_eq!(socket.port(), 8080);
Run

更改与此套接字地址关联的端口号。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
socket.set_port(4242);
assert_eq!(socket.port(), 4242);
Run

返回与此地址关联的流信息。

该信息对应于 IETF RFC 2553, Section 3.3 中指定的 C 的 netinet/in.h 中的 sin6_flowinfo 字段。 它结合了关于流标签和流量类别的信息,分别在 IETF RFC 2460,Section 6 和 Section 7 中指定。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
assert_eq!(socket.flowinfo(), 10);
Run

更改与此套接字地址关联的流信息。

有关更多详细信息,请参见 SocketAddrV6::flowinfo 的文档。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
socket.set_flowinfo(56);
assert_eq!(socket.flowinfo(), 56);
Run

返回与此地址关联的作用域 ID。

该信息对应于 IETF RFC 2553, Section 3.3 中指定的 C 的 netinet/in.h 中的 sin6_scope_id 字段。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
assert_eq!(socket.scope_id(), 78);
Run

更改与此套接字地址关联的作用域 ID。

有关更多详细信息,请参见 SocketAddrV6::scope_id 的文档。

Examples

use std::net::{SocketAddrV6, Ipv6Addr};

let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
socket.set_scope_id(42);
assert_eq!(socket.scope_id(), 42);
Run

Trait Implementations

返回值的副本。 Read more

从 source 执行复制分配。 Read more

使用给定的格式化程序格式化该值。 Read more

使用给定的格式化程序格式化该值。 Read more

可以从解析中返回的相关错误。

解析字符串 s 以返回此类型的值。 Read more

将该值输入给定的 Hasher。 Read more

将这种类型的切片送入给定的 Hasher 中。 Read more

此方法返回 self 和 other 之间的 Ordering。 Read more

比较并返回两个值中的最大值。 Read more

比较并返回两个值中的最小值。 Read more

将值限制为一定的时间间隔。 Read more

此方法测试 self 和 other 值是否相等,并由 == 使用。 Read more

此方法测试 !=。

如果存在,则此方法返回 self 和 other 值之间的顺序。 Read more

此方法测试的内容少于 (对于 self 和 other),并且由 < 操作员使用。 Read more

此方法测试小于或等于 (对于 self 和 other),并且由 <= 运算符使用。 Read more

此方法测试大于 (对于 self 和 other),并且由 > 操作员使用。 Read more

此方法测试是否大于或等于 (对于 self 和 other),并且由 >= 运算符使用。 Read more

在此类型可能对应的套接字地址上返回的迭代器。 Read more

将此 object 转换为解析的 SocketAddr 的迭代器。 Read more

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

获得所有权后的结果类型。

通常通过克隆从借用数据中创建拥有的数据。 Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

recently added

使用借来的数据来替换拥有的数据,通常是通过克隆。 Read more

将给定值转换为 String。 Read more

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。