| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 2 | 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#, |
| 3 | netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#, Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#, SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#, SocketAddrV4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV4#, SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6#}, |
| 4 | }; |
| 5 | |
| 6 | 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#}; |
| 7 | |
| 8 | use craterust-analyzer cargo timestamped-socket 0.2.2 crate/::{ |
| 9 | 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#}, |
| 10 | interfacerust-analyzer cargo timestamped-socket 0.2.2 interface/::InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#, |
| 11 | 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#, EthernetAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/EthernetAddress#, MacAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/MacAddress#, NetworkAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/NetworkAddress#}, |
| 12 | raw_socketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/::RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#, |
| 13 | socketrust-analyzer cargo timestamped-socket 0.2.2 socket/::select_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/select_timestamp()., |
| 14 | }; |
| 15 | |
| 16 | use superrust-analyzer cargo timestamped-socket 0.2.2 socket/::{InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#, Socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#, Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#}; |
| 17 | |
| 18 | const SOF_TIMESTAMPING_BIND_PHCrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/SOF_TIMESTAMPING_BIND_PHC.: libcrust-analyzer cargo libc 0.2.152 crate/::c_uintrust-analyzer cargo libc 0.2.152 unix/c_uint# = 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().15; |
| 19 | |
| 20 | 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> { |
| 21 | pub(superrust-analyzer cargo timestamped-socket 0.2.2 socket/) async fn fetch_send_timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp().( |
| 22 | &self, |
| 23 | expected_counter: u32, |
| 24 | ) -> 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#>> { |
| 25 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#; |
| 26 | |
| 27 | const TIMEOUTrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/TIMEOUT.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration# = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(200); |
| 28 | |
| 29 | match tokiorust-analyzer cargo tokio 1.35.1 crate/::timerust-analyzer cargo tokio 1.35.1 time/::timeoutrust-analyzer cargo tokio 1.35.1 time/timeout/timeout().(TIMEOUTrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/TIMEOUT., self.fetch_send_timestamp_looprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp_loop().(expected_counter)).rust-analyzer cargo tokio 1.35.1 time/timeout/impl#[`Timeout<T>`][Future]poll().awaitrust-analyzer cargo tokio 1.35.1 time/timeout/impl#[`Timeout<T>`][Future]poll(). |
| 30 | { |
| 31 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(res_opt_timestamp) => res_opt_timestamp, |
| 32 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_timeout_elapsed) => 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#), |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | pub(superrust-analyzer cargo timestamped-socket 0.2.2 socket/) async fn fetch_send_timestamp_looprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp_loop().( |
| 37 | &self, |
| 38 | expected_counter: u32, |
| 39 | ) -> 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#>> { |
| 40 | let try_read = |_: &RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#| self.fetch_send_timestamp_try_readrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp_try_read().(expected_counter); |
| 41 | |
| 42 | loop { |
| 43 | // the timestamp being available triggers the error interest |
| 44 | match self.socketrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#socket..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#::ERRORrust-analyzer cargo tokio 1.35.1 io/interest/impl#[Interest]ERROR., try_read).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(). { |
| 45 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(timestamp) => break Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(timestamp)), |
| 46 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue, |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | pub(superrust-analyzer cargo timestamped-socket 0.2.2 socket/) fn fetch_send_timestamp_try_readrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/impl#[`Socket<A, S>`]fetch_send_timestamp_try_read().( |
| 52 | &self, |
| 53 | expected_counter: u32, |
| 54 | ) -> 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#>> { |
| 55 | const CONTROL_SIZErust-analyzer cargo timestamped-socket 0.2.2 socket/linux/CONTROL_SIZE.: usize = 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]>() |
| 56 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().control_message_spacerust-analyzer cargo timestamped-socket 0.2.2 control_message/control_message_space().::<(libcrust-analyzer cargo libc 0.2.152 crate/::sock_extended_errrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#, libcrust-analyzer cargo libc 0.2.152 crate/::sockaddr_storagerust-analyzer cargo libc 0.2.152 unix/linux_like/sockaddr_storage#)>(); |
| 57 | |
| 58 | let mut control_buf = [0; CONTROL_SIZErust-analyzer cargo timestamped-socket 0.2.2 socket/linux/CONTROL_SIZE.]; |
| 59 | |
| 60 | // NOTE: this read could block! |
| 61 | let (_, control_messages, _) = 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().().receive_messagerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]receive_message().( |
| 62 | &mut [], |
| 63 | &mut control_buf, |
| 64 | MessageQueuerust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#::Errorrust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#Error#, |
| 65 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 66 | |
| 67 | let mut send_ts = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 68 | for msg in control_messages { |
| 69 | match msg { |
| 70 | 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. } => { |
| 71 | send_ts = 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); |
| 72 | } |
| 73 | |
| 74 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::ReceiveErrorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#ReceiveError#(error) => { |
| 75 | // the timestamping does not set a message; if there is a message, that means |
| 76 | // something else is wrong, and we want to know about it. |
| 77 | if error.ee_errnorust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#ee_errno. as libcrust-analyzer cargo libc 0.2.152 crate/::c_intrust-analyzer cargo libc 0.2.152 unix/c_int# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().libcrust-analyzer cargo libc 0.2.152 crate/::ENOMSGrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/b64/x86_64/ENOMSG. { |
| 78 | tracingrust-analyzer cargo tracing 0.1.37 crate/::warnrust-analyzer cargo tracing 0.1.37 macros/warn!!( |
| 79 | expected_counter, |
| 80 | error.ee_datarust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#ee_data., |
| 81 | "error message on the MSG_ERRQUEUE" |
| 82 | ); |
| 83 | } |
| 84 | |
| 85 | // Check that this message belongs to the send we are interested in |
| 86 | if error.ee_datarust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#ee_data. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().expected_counter { |
| 87 | tracingrust-analyzer cargo tracing 0.1.37 crate/::debugrust-analyzer cargo tracing 0.1.37 macros/debug!!( |
| 88 | error.ee_datarust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#ee_data., |
| 89 | expected_counter, |
| 90 | "Timestamp for unrelated packet" |
| 91 | ); |
| 92 | return 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#); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Otherrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Other#(msg) => { |
| 97 | tracingrust-analyzer cargo tracing 0.1.37 crate/::warnrust-analyzer cargo tracing 0.1.37 macros/warn!!( |
| 98 | msg.cmsg_levelrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_level., |
| 99 | msg.cmsg_typerust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_type., |
| 100 | "unexpected message on the MSG_ERRQUEUE", |
| 101 | ); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(send_ts) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | pub(superrust-analyzer cargo timestamped-socket 0.2.2 socket/) fn configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().( |
| 111 | socket: &RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#, |
| 112 | mode: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, |
| 113 | bind_phc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, |
| 114 | ) -> 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#<()> { |
| 115 | let options = match mode { |
| 116 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwarePTPAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPAll# => { |
| 117 | libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RAW_HARDWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RAW_HARDWARE. |
| 118 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_TX_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_TX_SOFTWARE. |
| 119 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RX_HARDWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RX_HARDWARE. |
| 120 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_TX_HARDWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_TX_HARDWARE. |
| 121 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_OPT_TSONLYrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_OPT_TSONLY. |
| 122 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_OPT_IDrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_OPT_ID. |
| 123 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().bind_phc |
| 124 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|_| SOF_TIMESTAMPING_BIND_PHCrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/SOF_TIMESTAMPING_BIND_PHC.) |
| 125 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 126 | } |
| 127 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => { |
| 128 | libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RAW_HARDWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RAW_HARDWARE. |
| 129 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RX_HARDWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RX_HARDWARE. |
| 130 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().bind_phc |
| 131 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|_| SOF_TIMESTAMPING_BIND_PHCrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/SOF_TIMESTAMPING_BIND_PHC.) |
| 132 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() |
| 133 | } |
| 134 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# => { |
| 135 | libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_SOFTWARE. |
| 136 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RX_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RX_SOFTWARE. |
| 137 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_TX_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_TX_SOFTWARE. |
| 138 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_OPT_TSONLYrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_OPT_TSONLY. |
| 139 | |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_OPT_IDrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_OPT_ID. |
| 140 | } |
| 141 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => { |
| 142 | libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_SOFTWARE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.152 crate/::SOF_TIMESTAMPING_RX_SOFTWARErust-analyzer cargo libc 0.2.152 unix/linux_like/linux/SOF_TIMESTAMPING_RX_SOFTWARE. |
| 143 | } |
| 144 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 145 | }; |
| 146 | |
| 147 | socket.so_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]so_timestamping().(options, bind_phc.unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().()) |
| 148 | } |
| 149 | |
| 150 | pub fn open_interface_udprust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_udp().( |
| 151 | interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#, |
| 152 | port: u16, |
| 153 | timestamping: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, |
| 154 | bind_phc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, |
| 155 | ) -> 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#>> { |
| 156 | // Setup the socket |
| 157 | let socket = 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.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 158 | socket.reuse_addrrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]reuse_addr().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 159 | socket.ipv6_v6onlyrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_v6only().(false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 160 | socket.bindrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]bind().(SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/impl#[SocketAddrV6]new().(Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#::UNSPECIFIEDrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv6Addr]UNSPECIFIED., port, 0, 0).to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/impl#[SocketAddrV6][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().; |
| 161 | socket.bind_to_devicerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]bind_to_device().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 162 | socket.ipv6_multicast_ifrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_multicast_if().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 163 | socket.ipv6_multicast_looprust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_multicast_loop().(false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 164 | configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping, bind_phc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 165 | match timestamping { |
| 166 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# => { |
| 167 | socket.driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().(interface, libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_ALLrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_ALL. as _)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 168 | } |
| 169 | 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#::HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => socket |
| 170 | .driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().( |
| 171 | interface, |
| 172 | libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_PTP_V2_L4_EVENTrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_PTP_V2_L4_EVENT. as _, |
| 173 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 174 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# |
| 175 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# |
| 176 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => {} |
| 177 | } |
| 178 | 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().; |
| 179 | |
| 180 | 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# { |
| 181 | timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping, |
| 182 | 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()., |
| 183 | send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0, |
| 184 | _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#, |
| 185 | _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#, |
| 186 | }) |
| 187 | } |
| 188 | |
| 189 | pub fn open_interface_udp4rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_udp4().( |
| 190 | interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#, |
| 191 | port: u16, |
| 192 | timestamping: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, |
| 193 | bind_phc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, |
| 194 | ) -> 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#<SocketAddrV4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV4#, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#>> { |
| 195 | // Setup the socket |
| 196 | let socket = 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.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 197 | socket.reuse_addrrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]reuse_addr().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 198 | socket.bindrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]bind().(SocketAddrV4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV4#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/impl#[SocketAddrV4]new().(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::UNSPECIFIEDrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr]UNSPECIFIED., port).to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/impl#[SocketAddrV4][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().; |
| 199 | socket.bind_to_devicerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]bind_to_device().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 200 | socket.ip_multicast_ifrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ip_multicast_if().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 201 | socket.ip_multicast_looprust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ip_multicast_loop().(false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 202 | configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping, bind_phc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 203 | match timestamping { |
| 204 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# => { |
| 205 | socket.driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().(interface, libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_ALLrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_ALL. as _)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 206 | } |
| 207 | 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#::HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => socket |
| 208 | .driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().( |
| 209 | interface, |
| 210 | libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_PTP_V2_L4_EVENTrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_PTP_V2_L4_EVENT. as _, |
| 211 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 212 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# |
| 213 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# |
| 214 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => {} |
| 215 | } |
| 216 | 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().; |
| 217 | |
| 218 | 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# { |
| 219 | timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping, |
| 220 | 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()., |
| 221 | send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0, |
| 222 | _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#, |
| 223 | _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#, |
| 224 | }) |
| 225 | } |
| 226 | |
| 227 | pub fn open_interface_udp6rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_udp6().( |
| 228 | interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#, |
| 229 | port: u16, |
| 230 | timestamping: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, |
| 231 | bind_phc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, |
| 232 | ) -> 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#<SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6#, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#>> { |
| 233 | // Setup the socket |
| 234 | let socket = 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.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 235 | socket.reuse_addrrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]reuse_addr().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 236 | socket.ipv6_v6onlyrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_v6only().(true)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 237 | socket.bindrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]bind().(SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/impl#[SocketAddrV6]new().(Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#::UNSPECIFIEDrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv6Addr]UNSPECIFIED., port, 0, 0).to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/impl#[SocketAddrV6][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().; |
| 238 | socket.bind_to_devicerust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]bind_to_device().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 239 | socket.ipv6_multicast_ifrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_multicast_if().(interface)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 240 | socket.ipv6_multicast_looprust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]ipv6_multicast_loop().(false)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 241 | configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping, bind_phc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 242 | match timestamping { |
| 243 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# => { |
| 244 | socket.driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().(interface, libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_ALLrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_ALL. as _)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 245 | } |
| 246 | 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#::HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => socket |
| 247 | .driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().( |
| 248 | interface, |
| 249 | libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_PTP_V2_L4_EVENTrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_PTP_V2_L4_EVENT. as _, |
| 250 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 251 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# |
| 252 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# |
| 253 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => {} |
| 254 | } |
| 255 | 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().; |
| 256 | |
| 257 | 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# { |
| 258 | timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping, |
| 259 | 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()., |
| 260 | send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0, |
| 261 | _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#, |
| 262 | _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#, |
| 263 | }) |
| 264 | } |
| 265 | |
| 266 | pub fn open_interface_ethernetrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_ethernet().( |
| 267 | interface: InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#, |
| 268 | protocol: u16, |
| 269 | timestamping: InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#, |
| 270 | bind_phc: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32>, |
| 271 | ) -> 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#<EthernetAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/EthernetAddress#, Openrust-analyzer cargo timestamped-socket 0.2.2 socket/Open#>> { |
| 272 | let socket = RawSocketrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/RawSocket#::openrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]open().( |
| 273 | libcrust-analyzer cargo libc 0.2.152 crate/::AF_PACKETrust-analyzer cargo libc 0.2.152 unix/linux_like/AF_PACKET., |
| 274 | 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., |
| 275 | u16::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_ne_bytes().(protocol.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_be_bytes().()) as _, |
| 276 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 277 | socket.bindrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/impl#[RawSocket]bind().( |
| 278 | EthernetAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/EthernetAddress#::newrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/impl#[EthernetAddress]new().( |
| 279 | u16::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_ne_bytes().(protocol.to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().()), |
| 280 | MacAddressrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/MacAddress#::newrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/impl#[MacAddress]new().([0; 6]), |
| 281 | interface |
| 282 | .get_indexrust-analyzer cargo timestamped-socket 0.2.2 interface/impl#[InterfaceName]get_index().() |
| 283 | .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#::InvalidInputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidInput#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as _, |
| 284 | ) |
| 285 | .to_sockaddrrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/linux/impl#[EthernetAddress][NetworkAddress]to_sockaddr().(PrivateTokenrust-analyzer cargo timestamped-socket 0.2.2 networkaddress/sealed/PrivateToken#), |
| 286 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 287 | configure_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/configure_timestamping().(&socket, timestamping, bind_phc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 288 | match timestamping { |
| 289 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareAll# | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::HardwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwareRecv# => { |
| 290 | socket.driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().(interface, libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_ALLrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_ALL. as _)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 291 | } |
| 292 | 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#::HardwarePTPRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#HardwarePTPRecv# => socket |
| 293 | .driver_enable_hardware_timestampingrust-analyzer cargo timestamped-socket 0.2.2 raw_socket/linux/impl#[RawSocket]driver_enable_hardware_timestamping().( |
| 294 | interface, |
| 295 | libcrust-analyzer cargo libc 0.2.152 crate/::HWTSTAMP_FILTER_PTP_V2_L2_EVENTrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/HWTSTAMP_FILTER_PTP_V2_L2_EVENT. as _, |
| 296 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 297 | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None# |
| 298 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareAll# |
| 299 | | InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::SoftwareRecvrust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#SoftwareRecv# => {} |
| 300 | } |
| 301 | 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().; |
| 302 | |
| 303 | 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# { |
| 304 | timestamp_moderust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#timestamp_mode.: timestamping, |
| 305 | 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()., |
| 306 | send_counterrust-analyzer cargo timestamped-socket 0.2.2 socket/Socket#send_counter.: 0, |
| 307 | _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#, |
| 308 | _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#, |
| 309 | }) |
| 310 | } |
| 311 | |
| 312 | #[cfg(test)] |
| 313 | mod testsrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/tests/ { |
| 314 | 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#; |
| 315 | |
| 316 | use craterust-analyzer cargo timestamped-socket 0.2.2 crate/::socketrust-analyzer cargo timestamped-socket 0.2.2 socket/::{connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address()., open_iprust-analyzer cargo timestamped-socket 0.2.2 socket/open_ip()., GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#}; |
| 317 | |
| 318 | use superrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/::*; |
| 319 | |
| 320 | #[tokiorust-analyzer cargo tokio 1.35.1 crate/::testrust-analyzer cargo tokio-macros 2.2.0 test:] |
| 321 | async fn test_open_udp6rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/tests/test_open_udp6().() { |
| 322 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 323 | let mut a = open_interface_udp6rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_udp6().( |
| 324 | InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#::from_strrust-analyzer cargo timestamped-socket 0.2.2 interface/impl#[InterfaceName][FromStr]from_str().("lo").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 325 | 5123, |
| 326 | superrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/::InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None#, |
| 327 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 328 | ) |
| 329 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 330 | let mut b = connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address().( |
| 331 | 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#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V6#(Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#::LOCALHOSTrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv6Addr]LOCALHOST.), 5123), |
| 332 | GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None#, |
| 333 | ) |
| 334 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 335 | 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().()); |
| 336 | let mut buf = [0; 4]; |
| 337 | 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().(); |
| 338 | 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); |
| 339 | 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]); |
| 340 | 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().()); |
| 341 | 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().(); |
| 342 | 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); |
| 343 | 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]); |
| 344 | } |
| 345 | |
| 346 | #[tokiorust-analyzer cargo tokio 1.35.1 crate/::testrust-analyzer cargo tokio-macros 2.2.0 test:] |
| 347 | async fn test_open_udp4rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/tests/test_open_udp4().() { |
| 348 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 349 | let mut a = open_interface_udp4rust-analyzer cargo timestamped-socket 0.2.2 socket/linux/open_interface_udp4().( |
| 350 | InterfaceNamerust-analyzer cargo timestamped-socket 0.2.2 interface/InterfaceName#::from_strrust-analyzer cargo timestamped-socket 0.2.2 interface/impl#[InterfaceName][FromStr]from_str().("lo").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 351 | 5124, |
| 352 | superrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/::InterfaceTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/InterfaceTimestampMode#None#, |
| 353 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 354 | ) |
| 355 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 356 | let mut b = connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address().( |
| 357 | 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.), 5124), |
| 358 | GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::Nonerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#None#, |
| 359 | ) |
| 360 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 361 | 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().()); |
| 362 | let mut buf = [0; 4]; |
| 363 | 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().(); |
| 364 | 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); |
| 365 | 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]); |
| 366 | 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().()); |
| 367 | 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().(); |
| 368 | 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); |
| 369 | 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]); |
| 370 | } |
| 371 | |
| 372 | #[tokiorust-analyzer cargo tokio 1.35.1 crate/::testrust-analyzer cargo tokio-macros 2.2.0 test:] |
| 373 | async fn test_software_timestampingrust-analyzer cargo timestamped-socket 0.2.2 socket/linux/tests/test_software_timestamping().() { |
| 374 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#; |
| 375 | |
| 376 | let a = open_iprust-analyzer cargo timestamped-socket 0.2.2 socket/open_ip().( |
| 377 | 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.), 5126), |
| 378 | GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareAll#, |
| 379 | ) |
| 380 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 381 | let mut b = connect_addressrust-analyzer cargo timestamped-socket 0.2.2 socket/connect_address().( |
| 382 | 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.), 5126), |
| 383 | GeneralTimestampModerust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#::SoftwareAllrust-analyzer cargo timestamped-socket 0.2.2 socket/GeneralTimestampMode#SoftwareAll#, |
| 384 | ) |
| 385 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 386 | |
| 387 | let before = SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]now().(); |
| 388 | let send_ts = 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()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 389 | let after = SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]now().(); |
| 390 | |
| 391 | let mut buf = [0; 4]; |
| 392 | 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().(); |
| 393 | let recv_ts = recv_result.timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/RecvResult#timestamp..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 394 | |
| 395 | let before = before |
| 396 | .duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]UNIX_EPOCH.) |
| 397 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 398 | .as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().(); |
| 399 | let after = after |
| 400 | .duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#::UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]UNIX_EPOCH.) |
| 401 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 402 | .as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().(); |
| 403 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!((send_ts.secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds. -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). (before as i64)).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]abs().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). 2); |
| 404 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!((send_ts.secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds. -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). (after as i64)).absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]abs().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). 2); |
| 405 | |
| 406 | let send_nanos = send_ts.secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). 1_000_000_000 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). (send_ts.nanosrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#nanos. as i64); |
| 407 | let recv_nanos = recv_ts.secondsrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#seconds. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). 1_000_000_000 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). (recv_ts.nanosrust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#nanos. as i64); |
| 408 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!((send_nanos -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Sub<Self>`]sub(). recv_nanos) <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). 1_000_000 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). 10); |
| 409 | } |
| 410 | } |