Debian Codegraph @

src/socket.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#, osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/::AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#};
2
3 use tokiorust-analyzer cargo tokio 1.35.1 crate/::iorust-analyzer cargo tokio 1.35.1 io/::{unixrust-analyzer cargo tokio 1.35.1 io/unix/::AsyncFdrust-analyzer cargo tokio 1.35.1 io/async_fd/AsyncFd#, Interestrust-analyzer cargo tokio 1.35.1 io/interest/Interest#};
4
5 use craterust-analyzer cargo timestamped-socket 0.2.2 crate/::{
6 control_messagerust-analyzer cargo timestamped-socket 0.2.2 control_message/::{control_message_spacerust-analyzer cargo timestamped-socket 0.2.2 control_message/control_message_space()., ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#, MessageQueuerust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#},
7 interfacerust-analyzer cargo timestamped-socket 0.2.2 interface/::InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#,
8 networkaddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/::{sealedrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/::PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#, MulticastJoinablerust-analyzer cargo timestamped-socket 0.2.2 networkaddress/MulticastJoinable#, NetworkAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#},
9 raw_socketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/::RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#,
10 };
11
12 #[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "macos")))]
13 mod fallback;
14 #[cfg(target_os = "freebsd")]
15 mod freebsd;
16 #[cfg(target_os = "linux")]
17 mod linuxrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/;
18 #[cfg(target_os = "macos")]
19 mod macos;
20
21 #[cfg(not(any(target_os = "linux", target_os = "freebsd", target_os = "macos")))]
22 use selfrust-analyzer cargo timestamped-socket 0.2.2 socket/::fallback::*;
23 #[cfg(target_os = "freebsd")]
24 use selfrust-analyzer cargo timestamped-socket 0.2.2 socket/::freebsd::*;
25 #[cfg(target_os = "linux")]
26 pub use selfrust-analyzer cargo timestamped-socket 0.2.2 socket/::linuxrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/::*;
27 #[cfg(target_os = "macos")]
28 use selfrust-analyzer cargo timestamped-socket 0.2.2 socket/::macos::*;
29
30 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
31 pub struct Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp# {
32 pub secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds.: i64,
33 pub nanosrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#nanos.: u32,
34 }
35
36 impl Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp# {
37 #[cfg_attr(target_os = "macos", allow(unused))] // macos does not do nanoseconds
38 pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) fn from_timespecrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timespec().(timespec: libcrust-analyzer cargo libc 0.2.152 crate/::timespecrust-analyzer cargo libc 0.2.152 unix/timespec#) -> Selfrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp] {
39 Selfrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp] {
40 secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds.: timespec.tv_secrust-analyzer cargo libc 0.2.152 unix/timespec#tv_sec. as _,
41 nanosrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#nanos.: timespec.tv_nsecrust-analyzer cargo libc 0.2.152 unix/timespec#tv_nsec. as _,
42 }
43 }
44
45 pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) fn from_timevalrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timeval().(timeval: libcrust-analyzer cargo libc 0.2.152 crate/::timevalrust-analyzer cargo libc 0.2.152 unix/timeval#) -> Selfrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp] {
46 Selfrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp] {
47 secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds.: timeval.tv_secrust-analyzer cargo libc 0.2.152 unix/timeval#tv_sec. as _,
48 nanosrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#nanos.: (1000 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().timeval.tv_usecrust-analyzer cargo libc 0.2.152 unix/timeval#tv_usec.) as _,
49 }
50 }
51 }
52
53 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
54 pub enum GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode# {
55 SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareAll#,
56 SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareRecv#,
57 #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:]
58 Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None#,
59 }
60
61 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
62 pub enum InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode# {
63 HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll#,
64 HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv#,
65 HardwarePTPAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPAll#,
66 HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv#,
67 SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll#,
68 SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv#,
69 #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:]
70 Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None#,
71 }
72
73 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#> for InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode# {
74 fn fromrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[InterfaceTimestampMode][`From<GeneralTimestampMode>`]from().(value: GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#) -> Selfrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[InterfaceTimestampMode][`From<GeneralTimestampMode>`] {
75 match value {
76 GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareAll# => InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll#,
77 GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareRecv# => InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv#,
78 GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None# => InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None#,
79 }
80 }
81 }
82
83 fn select_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/select_timestamp().(
84 mode: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#,
85 software: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>,
86 hardware: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>,
87 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#> {
88 use InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::*;
89
90 match mode {
91 SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# | SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => software,
92 HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# | HardwarePTPAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPAll# | HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => hardware,
93 Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# => Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#::Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
94 }
95 }
96
97 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
98 pub struct RecvResultrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#<A> {
99 pub bytes_readrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#bytes_read.: usize,
100 pub remote_addrrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#remote_addr.: A,
101 pub timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#timestamp.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>,
102 }
103
104 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
105 pub struct Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, S> {
106 timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#,
107 socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.: AsyncFdrust-analyzer cargo tokio 1.35.1 io/async_fd/AsyncFd#<RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#>,
108 #[cfg(target_os = "linux")]
109 send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: u32,
110 _addrrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_addr.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<A>,
111 _staterust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_state.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>,
112 }
113
114 pub struct Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#;
115 pub struct Connectedrust-analyzer cargo timestamped-socket 0.2.2 socket/Connected#;
116
117 impl<A: NetworkAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#, S> Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, S> {
118 pub fn local_addrrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]local_addr().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<A> {
119 let addr = self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..get_refrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]get_ref().().getsocknamerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]getsockname().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
120 A::from_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#from_sockaddr().(addr, PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
121 }
122
123 pub fn peer_addrrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]peer_addr().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<A> {
124 let addr = self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..get_refrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]get_ref().().getpeernamerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]getpeername().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
125 A::from_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#from_sockaddr().(addr, PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
126 }
127
128 pub async fn recvrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]recv().(&self, buf: &mut [u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<RecvResultrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#<A>> {
129 self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.
130 .async_iorust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]async_io().(Interestrust-analyzer cargo tokio 1.35.1 io/interest/Interest#::READABLErust-analyzer cargo tokio 1.35.1 io/interest/impl#[Interest]READABLE., |socket| {
131 let mut control_buf = [0; control_message_spacerust-analyzer cargo timestamped-socket 0.2.2 control_message/control_message_space().::<[libcrust-analyzer cargo libc 0.2.152 crate/::timespecrust-analyzer cargo libc 0.2.152 unix/timespec#; 3]>()];
132
133 // loops for when we receive an interrupt during the recv
134 let (bytes_read, control_messages, remote_address) =
135 socket.receive_messagerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]receive_message().(buf, &mut control_buf, MessageQueuerust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#::Normalrust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#Normal#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
136
137 let mut timestamp = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
138
139 // Loops through the control messages, but we should only get a single message
140 // in practice
141 for msg in control_messages {
142 match msg {
143 ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Timestampingrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping# { softwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#software., hardwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#hardware. } => {
144 tracingrust-analyzer cargo tracing 0.1.37 crate/::tracerust-analyzer cargo tracing 0.1.37 macros/trace!!("Timestamps: {:?} {:?}", software, hardware);
145 timestamp = select_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/select_timestamp().(self.timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode., software, hardware);
146 }
147
148 #[cfg(target_os = "linux")]
149 ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::ReceiveErrorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#ReceiveError#(error) => {
150 tracingrust-analyzer cargo tracing 0.1.37 crate/::warnrust-analyzer cargo tracing 0.1.37 macros/warn!!(
151 "unexpected error control message on receive: {}",
152 error.ee_errnorust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#ee_errno.
153 );
154 }
155
156 ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Otherrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Other#(msg) => {
157 tracingrust-analyzer cargo tracing 0.1.37 crate/::debugrust-analyzer cargo tracing 0.1.37 macros/debug!!(
158 "unexpected control message on receive: {} {}",
159 msg.cmsg_levelrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_level.,
160 msg.cmsg_typerust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_type.,
161 );
162 }
163 }
164 }
165
166 let remote_addr = A::from_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#from_sockaddr().(remote_address, PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#)
167 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
168
169 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(RecvResultrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult# {
170 bytes_readrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#bytes_read.,
171 remote_addrrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#remote_addr.,
172 timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#timestamp.,
173 })
174 })
175 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
176 }
177 }
178
179 impl<A: NetworkAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#> Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#> {
180 pub async fn send_torust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, Open>`]send_to().(&mut self, buf: &[u8], addr: A) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>> {
181 let addr = addr.to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#to_sockaddr().(PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#);
182
183 self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.
184 .async_iorust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]async_io().(Interestrust-analyzer cargo tokio 1.35.1 io/interest/Interest#::WRITABLErust-analyzer cargo tokio 1.35.1 io/interest/impl#[Interest]WRITABLE., |socket| socket.send_torust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]send_to().(buf, addr))
185 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
186
187 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(
188 self.timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.,
189 InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwarePTPAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll#
190 ) {
191 #[cfg(target_os = "linux")]
192 {
193 let expected_counter = self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.;
194 self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter. = self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(1);
195 self.fetch_send_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp().(expected_counter).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
196 }
197
198 #[cfg(not(target_os = "linux"))]
199 {
200 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("Should not be able to create send timestamping sockets on platforms other than linux")
201 }
202 } else {
203 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
204 }
205 }
206
207 pub fn connectrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, Open>`]connect().(self, addr: A) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, Connectedrust-analyzer cargo timestamped-socket 0.2.2 socket/Connected#>> {
208 let addr = addr.to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#to_sockaddr().(PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#);
209 self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..get_refrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]get_ref().().connectrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]connect().(addr)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
210 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket# {
211 timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: self.timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.,
212 socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.: self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.,
213 #[cfg(target_os = "linux")]
214 send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.,
215 _addrrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_addr.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
216 _staterust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_state.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
217 })
218 }
219 }
220
221 impl<A: NetworkAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#> Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, Connectedrust-analyzer cargo timestamped-socket 0.2.2 socket/Connected#> {
222 pub async fn sendrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, Connected>`]send().(&mut self, buf: &[u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>> {
223 self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.
224 .async_iorust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]async_io().(Interestrust-analyzer cargo tokio 1.35.1 io/interest/Interest#::WRITABLErust-analyzer cargo tokio 1.35.1 io/interest/impl#[Interest]WRITABLE., |socket| socket.sendrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]send().(buf))
225 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
226
227 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(
228 self.timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.,
229 InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwarePTPAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll#
230 ) {
231 #[cfg(target_os = "linux")]
232 {
233 let expected_counter = self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.;
234 self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter. = self.send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(1);
235 self.fetch_send_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp().(expected_counter).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
236 }
237
238 #[cfg(not(target_os = "linux"))]
239 {
240 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("Should not be able to create send timestamping sockets on platforms other than linux")
241 }
242 } else {
243 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
244 }
245 }
246 }
247
248 impl<A: MulticastJoinablerust-analyzer cargo timestamped-socket 0.2.2 networkaddress/MulticastJoinable#, S> Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<A, S> {
249 pub fn join_multicastrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]join_multicast().(&self, addr: A, interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
250 addr.join_multicastrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/MulticastJoinable#join_multicast().(self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..get_refrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]get_ref().().as_raw_fdrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket][AsRawFd]as_raw_fd().(), interface, PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#)
251 }
252
253 pub fn leave_multicastrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]leave_multicast().(&self, addr: A, interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
254 addr.leave_multicastrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/MulticastJoinable#leave_multicast().(self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..get_refrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]get_ref().().as_raw_fdrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket][AsRawFd]as_raw_fd().(), interface, PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#)
255 }
256 }
257
258 pub fn open_iprust-analyzer cargo timestamped-socket 0.2.2 socket/open_ip().(
259 addr: SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#,
260 timestamping: GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#,
261 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#>> {
262 // Setup the socket
263 let socket = match addr {
264 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#V4#(_) => RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#::openrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]open().(libcrust-analyzer cargo libc 0.2.152 crate/::PF_INETrust-analyzer cargo libc 0.2.152 unix/linux_like/PF_INET., libcrust-analyzer cargo libc 0.2.152 crate/::SOCK_DGRAMrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/b64/x86_64/SOCK_DGRAM., libcrust-analyzer cargo libc 0.2.152 crate/::IPPROTO_UDPrust-analyzer cargo libc 0.2.152 unix/IPPROTO_UDP.),
265 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#V6#(_) => RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#::openrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]open().(libcrust-analyzer cargo libc 0.2.152 crate/::PF_INET6rust-analyzer cargo libc 0.2.152 unix/linux_like/PF_INET6., libcrust-analyzer cargo libc 0.2.152 crate/::SOCK_DGRAMrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/b64/x86_64/SOCK_DGRAM., libcrust-analyzer cargo libc 0.2.152 crate/::IPPROTO_UDPrust-analyzer cargo libc 0.2.152 unix/IPPROTO_UDP.),
266 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
267 socket.bindrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]bind().(addr.to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/impl#[SocketAddr][NetworkAddress]to_sockaddr().(PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
268 socket.set_nonblockingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]set_nonblocking().(true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
269 configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
270
271 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket# {
272 timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
273 socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.: AsyncFdrust-analyzer cargo tokio 1.35.1 io/async_fd/AsyncFd#::newrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]new().(socket)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
274 #[cfg(target_os = "linux")]
275 send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0,
276 _addrrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_addr.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
277 _staterust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_state.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
278 })
279 }
280
281 pub fn connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address().(
282 addr: SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#,
283 timestamping: GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#,
284 ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#<SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#, Connectedrust-analyzer cargo timestamped-socket 0.2.2 socket/Connected#>> {
285 // Setup the socket
286 let socket = match addr {
287 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#V4#(_) => RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#::openrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]open().(libcrust-analyzer cargo libc 0.2.152 crate/::PF_INETrust-analyzer cargo libc 0.2.152 unix/linux_like/PF_INET., libcrust-analyzer cargo libc 0.2.152 crate/::SOCK_DGRAMrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/b64/x86_64/SOCK_DGRAM., libcrust-analyzer cargo libc 0.2.152 crate/::IPPROTO_UDPrust-analyzer cargo libc 0.2.152 unix/IPPROTO_UDP.),
288 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#V6#(_) => RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#::openrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]open().(libcrust-analyzer cargo libc 0.2.152 crate/::PF_INET6rust-analyzer cargo libc 0.2.152 unix/linux_like/PF_INET6., libcrust-analyzer cargo libc 0.2.152 crate/::SOCK_DGRAMrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/b64/x86_64/SOCK_DGRAM., libcrust-analyzer cargo libc 0.2.152 crate/::IPPROTO_UDPrust-analyzer cargo libc 0.2.152 unix/IPPROTO_UDP.),
289 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
290 socket.connectrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]connect().(addr.to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/impl#[SocketAddr][NetworkAddress]to_sockaddr().(PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
291 socket.set_nonblockingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]set_nonblocking().(true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
292 configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
293
294 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket# {
295 timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
296 socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket.: AsyncFdrust-analyzer cargo tokio 1.35.1 io/async_fd/AsyncFd#::newrust-analyzer cargo tokio 1.35.1 io/async_fd/impl#[`AsyncFd<T>`]new().(socket)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
297 #[cfg(target_os = "linux")]
298 send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0,
299 _addrrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_addr.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
300 _staterust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#_state.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
301 })
302 }
303
304 #[cfg(test)]
305 mod testsrust-analyzer cargo timestamped-socket 0.2.2 socket/tests/ {
306 use superrust-analyzer cargo timestamped-socket 0.2.2 socket/::*;
307 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#};
308
309 #[tokiorust-analyzer cargo tokio 1.35.1 crate/::testrust-analyzer cargo tokio-macros 2.2.0 test:]
310 async fn test_open_iprust-analyzer cargo timestamped-socket 0.2.2 socket/tests/test_open_ip().() {
311 let mut a = open_iprust-analyzer cargo timestamped-socket 0.2.2 socket/open_ip().(
312 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/impl#[SocketAddr]new().(IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::LOCALHOSTrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr]LOCALHOST.), 5125),
313 GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None#,
314 )
315 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
316 let mut b = connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address().(
317 SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/impl#[SocketAddr]new().(IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::LOCALHOSTrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr]LOCALHOST.), 5125),
318 GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None#,
319 )
320 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
321 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(b.sendrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, Connected>`]send().(&[1, 2, 3]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
322 let mut buf = [0; 4];
323 let recv_result = a.recvrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]recv().(&mut buf).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
324 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(recv_result.bytes_readrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#bytes_read., 3);
325 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., &[1, 2, 3]);
326 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(a.send_torust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, Open>`]send_to().(&[4, 5, 6], recv_result.remote_addrrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#remote_addr.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
327 let recv_result = b.recvrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[`Socket<A, S>`]recv().(&mut buf).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
328 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(recv_result.bytes_readrust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#bytes_read., 3);
329 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., &[4, 5, 6]);
330 }
331 }