Struct Packet

Source
pub struct Packet<B> { /* private fields */ }
Expand description

Timestamp Request/Reply packet parser.

Implementations§

Source§

impl<B: AsRef<[u8]>> Packet<B>

Source

pub fn unchecked(buffer: B) -> Packet<B>

Create a Timestamp Request/Reply packet without checking the buffer.

Source

pub fn new(buffer: B) -> Result<Packet<B>>

Parse a Timestamp Request/Reply packet, checking the buffer contents are correct.

Source§

impl<B: AsRef<[u8]>> Packet<B>

Source

pub fn to_owned(&self) -> Packet<Vec<u8>>

Convert the packet to its owned version.

§Notes

It would be nice if ToOwned could be implemented, but Packet already implements Clone and the impl would conflict.

Source§

impl<B: AsRef<[u8]>> Packet<B>

Source

pub fn is_request(&self) -> bool

Check if it’s a Request packet.

Source

pub fn is_reply(&self) -> bool

Check if it’s a Reply packet.

Source

pub fn identifier(&self) -> u16

Packet identifier.

Source

pub fn sequence(&self) -> u16

Packet sequence.

Source

pub fn originate(&self) -> u32

Creation timestamp.

Source

pub fn receive(&self) -> u32

Reception timestamp.

Source

pub fn transmit(&self) -> u32

Transmission timestamp.

Source§

impl<B: AsRef<[u8]> + AsMut<[u8]>> Packet<B>

Source

pub fn make_request(&mut self) -> Result<&mut Self>

Make the packet an Echo Request.

Source

pub fn make_reply(&mut self) -> Result<&mut Self>

Make the packet an Echo Reply.

Source

pub fn set_identifier(&mut self, value: u16) -> Result<&mut Self>

Packet identifier.

Source

pub fn set_sequence(&mut self, value: u16) -> Result<&mut Self>

Packet sequence.

Source

pub fn set_originate(&mut self, value: u32) -> Result<&mut Self>

Creation timestamp.

Source

pub fn set_receive(&mut self, value: u32) -> Result<&mut Self>

Reception timestamp.

Source

pub fn set_transmit(&mut self, value: u32) -> Result<&mut Self>

Transmission timestamp.

Source

pub fn checked(&mut self) -> Checked<'_, Self>

Create a checksumed setter.

Trait Implementations§

Source§

impl<B: AsRef<[u8]> + AsMut<[u8]>> AsMut<[u8]> for Packet<B>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'a, B: Buffer> AsPacket<'a, Packet<&'a [u8]>> for Builder<B>

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>>

Try converting to a packet.
Source§

impl<'a, B: Buffer> AsPacketMut<'a, Packet<&'a mut [u8]>> for Builder<B>

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>>

Try converting to a packet.
Source§

impl<B: AsRef<[u8]>> AsRef<[u8]> for Packet<B>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<B: AsRef<[u8]>> Debug for Packet<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B> Max for Packet<B>

Source§

fn max() -> usize

Get the maximum size.
Source§

impl<B> Max for Packet<B>

Source§

fn max() -> usize

Get the maximum size.
Source§

impl<B> Min for Packet<B>

Source§

fn min() -> usize

Get the minimum size.
Source§

impl<B> Min for Packet<B>

Source§

fn min() -> usize

Get the minimum size.
Source§

impl<B: AsRef<[u8]>> Packet for Packet<B>

Source§

fn split(&self) -> (&[u8], &[u8])

Return both slices.
Source§

fn header(&self) -> &[u8]

Return a slice to the packet header.
Source§

fn payload(&self) -> &[u8]

Return a slice to the packet payload.
Source§

impl<B: AsRef<[u8]> + AsMut<[u8]>> PacketMut for Packet<B>

Source§

fn split_mut(&mut self) -> (&mut [u8], &mut [u8])

Return both mutable slices.
Source§

fn header_mut(&mut self) -> &mut [u8]

Returns a slice to the packet header.
Source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a slice to the packet payload.
Source§

impl<B: AsRef<[u8]>> Size for Packet<B>

Source§

fn size(&self) -> usize

Get the actual size.
Source§

impl<B: AsRef<[u8]>> Size for Packet<B>

Source§

fn size(&self) -> usize

Get the actual size.

Auto Trait Implementations§

§

impl<B> Freeze for Packet<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Packet<B>
where B: RefUnwindSafe,

§

impl<B> Send for Packet<B>
where B: Send,

§

impl<B> Sync for Packet<B>
where B: Sync,

§

impl<B> Unpin for Packet<B>
where B: Unpin,

§

impl<B> UnwindSafe for Packet<B>
where B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, B> AsPacket<'a, Option<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Option<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Option<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Option<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacket<'a, Packet<&'a [u8]>> for B
where B: AsRef<[u8]>,

Source§

fn as_packet(&self) -> Result<Packet<&[u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Option<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Option<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Option<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Option<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<'a, B> AsPacketMut<'a, Packet<&'a mut [u8]>> for B
where B: AsRef<[u8]> + AsMut<[u8]>,

Source§

fn as_packet_mut(&mut self) -> Result<Packet<&mut [u8]>, Error>

Try converting to a packet.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Max for T
where T: Max + Max,

Source§

fn max() -> usize

Get the maximum size.
Source§

impl<T> Min for T
where T: Min + Min,

Source§

fn min() -> usize

Get the minimum size.
Source§

impl<T> Size for T
where T: Size + Size,

Source§

fn size(&self) -> usize

Get the actual size.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.