Enum otter_api_tests::imports::nix::sys::socket::ControlMessageOwned [−]
pub enum ControlMessageOwned {
ScmRights(Vec<i32, Global>),
ScmCredentials(UnixCredentials),
ScmTimestamp(TimeVal),
ScmTimestampns(TimeSpec),
Ipv4PacketInfo(in_pktinfo),
Ipv6PacketInfo(in6_pktinfo),
UdpGroSegments(u16),
// some variants omitted
}Expand description
A type-safe wrapper around a single control message, as used with
recvmsg.
Variants
Received version of
[ControlMessage::ScmRights][#enum.ControlMessage.html#variant.ScmRights]
ScmCredentials(UnixCredentials)Received version of
[ControlMessage::ScmCredentials][#enum.ControlMessage.html#variant.ScmCredentials]
ScmTimestamp(TimeVal)A message of type SCM_TIMESTAMP, containing the time the
packet was received by the kernel.
See the kernel’s explanation in “SO_TIMESTAMP” of networking/timestamping.
Examples
// Set up let message = "Ohayō!".as_bytes(); let in_socket = socket( AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), None).unwrap(); setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap(); let localhost = InetAddr::new(IpAddr::new_v4(127, 0, 0, 1), 0); bind(in_socket, &SockAddr::new_inet(localhost)).unwrap(); let address = getsockname(in_socket).unwrap(); // Get initial time let time0 = SystemTime::now(); // Send the message let iov = [IoVec::from_slice(message)]; let flags = MsgFlags::empty(); let l = sendmsg(in_socket, &iov, &[], flags, Some(&address)).unwrap(); assert_eq!(message.len(), l); // Receive the message let mut buffer = vec![0u8; message.len()]; let mut cmsgspace = cmsg_space!(TimeVal); let iov = [IoVec::from_mut_slice(&mut buffer)]; let r = recvmsg(in_socket, &iov, Some(&mut cmsgspace), flags).unwrap(); let rtime = match r.cmsgs().next() { Some(ControlMessageOwned::ScmTimestamp(rtime)) => rtime, Some(_) => panic!("Unexpected control message"), None => panic!("No control message") }; // Check the final time let time1 = SystemTime::now(); // the packet's received timestamp should lie in-between the two system // times, unless the system clock was adjusted in the meantime. let rduration = Duration::new(rtime.tv_sec() as u64, rtime.tv_usec() as u32 * 1000); assert!(time0.duration_since(UNIX_EPOCH).unwrap() <= rduration); assert!(rduration <= time1.duration_since(UNIX_EPOCH).unwrap()); // Close socket nix::unistd::close(in_socket).unwrap();
ScmTimestampns(TimeSpec)Nanoseconds resolution timestamp
Ipv4PacketInfo(in_pktinfo)Ipv6PacketInfo(in6_pktinfo)UdpGroSegments(u16)UDP Generic Receive Offload (GRO) allows receiving multiple UDP packets from a single sender. Fixed-size payloads are following one by one in a receive buffer. This Control Message indicates the size of all smaller packets, except, maybe, the last one.
UdpGroSegment socket option should be enabled on a socket
to allow receiving GRO packets.
Trait Implementations
impl Clone for ControlMessageOwned
impl Clone for ControlMessageOwnedpub fn clone(&self) -> ControlMessageOwned
pub fn clone(&self) -> ControlMessageOwnedReturns a copy of the value. Read more
Performs copy-assignment from source. Read more
impl Debug for ControlMessageOwned
impl Debug for ControlMessageOwnedimpl PartialEq<ControlMessageOwned> for ControlMessageOwned
impl PartialEq<ControlMessageOwned> for ControlMessageOwnedpub fn eq(&self, other: &ControlMessageOwned) -> bool
pub fn eq(&self, other: &ControlMessageOwned) -> boolThis method tests for self and other values to be equal, and is used
by ==. Read more
pub fn ne(&self, other: &ControlMessageOwned) -> bool
pub fn ne(&self, other: &ControlMessageOwned) -> boolThis method tests for !=.
impl Eq for ControlMessageOwnedimpl StructuralEq for ControlMessageOwnedimpl StructuralPartialEq for ControlMessageOwnedAuto Trait Implementations
impl RefUnwindSafe for ControlMessageOwnedimpl Send for ControlMessageOwnedimpl Sync for ControlMessageOwnedimpl Unpin for ControlMessageOwnedimpl UnwindSafe for ControlMessageOwnedBlanket Implementations
Mutably borrows from an owned value. Read more
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more
impl<A> DynCastExt for A
impl<A> DynCastExt for Apub fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>,
pub fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>, Use this to cast from one trait object type to another. Read more
pub fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
pub fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>, Use this to upcast a trait to one of its supertraits. Read more
pub fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
pub fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized, pub fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
pub fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>, Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more
Compare self to key and return true if they are equal.
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;[src]
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;[src]Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;[src]
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;[src]pub fn vzip(self) -> V