Skip to main content

PacketMut

Struct PacketMut 

Source
pub struct PacketMut { /* private fields */ }
Expand description

A mutable, contiguous, growable sequence of bytes, specialized for networking applications.

Implementations§

Source§

impl PacketMut

Source

pub fn new(size: usize) -> Self

Constructs a new PacketMut and allocates an underlying buffer of the given size on the heap. The newly-allocated underlying buffer is filled with zero bytes (0u8).

§Examples
let mut pkt = PacketMut::new(5);
assert_eq!(pkt.len(), 5);
assert_eq!(pkt.as_ref(), &[0, 0, 0, 0, 0]);
pkt[4] = 42;
assert_eq!(pkt.as_ref(), &[0, 0, 0, 0, 42]);
Source

pub fn with_capacity(size: usize) -> Self

Constructs a new PacketMut with at least the specified capacity. The packet will be able to hold at least size bytes without reallocating.

Note that the packet will have at least the given capacity, but will have a length of zero until bytes are added to it.

§Examples
let mut pkt = PacketMut::with_capacity(5);
assert_eq!(pkt.len(), 0);
assert_eq!(pkt.capacity(), 5);
Source

pub fn capacity(&self) -> usize

Returns the number of contiguous bytes the underlying buffer can hold without reallocating.

§Examples
let mut pkt = PacketMut::with_capacity(3);
assert_eq!(pkt.len(), 0);
assert_eq!(pkt.capacity(), 3);
Source

pub fn extend_from_slice(&mut self, slice: &[u8])

Appends the given bytes to the end of this PacketMut. The underlying buffer is resized if it does not have enough capacity.

§Examples

Extending within the underlying buffer’s capacity increases the length, but not the capacity:

let mut pkt = PacketMut::with_capacity(3);
pkt.extend_from_slice(&[1, 2, 3]);
assert_eq!(pkt.len(), 3);
assert_eq!(pkt.capacity(), 3);

Extending beyond the backing buffer’s capacity triggers a reallocation, changing both the length and the capacity:

let mut pkt = PacketMut::with_capacity(3);
pkt.extend_from_slice(&[1, 2, 3, 4]);
assert_eq!(pkt.len(), 4);
assert_eq!(pkt.capacity(), 8);
Source

pub fn grow_front(&mut self, len: usize)

Add the given number of zero bytes to the front of this [PacketMut]. The underlying buffer is resized if it does not have enough capacity.

Source

pub fn extend_front_from_slice(&mut self, slice: &[u8])

Prepends the given bytes to this PacketMut. The underlying buffer is resized if it does not have enough capacity.

Source

pub fn get<I>(&self, index: I) -> Option<&<I as SliceIndex<[u8]>>::Output>
where I: SliceIndex<[u8]>,

Returns a reference to an element or subslice depending on the type of index.

If given a position, returns a reference to the element at that position or None if out of bounds. If given a range, returns the subslice corresponding to that range, or None if out of bounds.

Source

pub fn get_mut<I>( &mut self, index: I, ) -> Option<&mut <I as SliceIndex<[u8]>>::Output>
where I: SliceIndex<[u8]>,

Returns a mutable reference to an element or subslice depending on the type of index.

If given a position, returns a reference to the element at that position or None if out of bounds. If given a range, returns the subslice corresponding to that range, or None if out of bounds.

Source

pub fn freeze(self) -> Packet

Converts self into an immutable Packet. This is a zero-cost type conversion simply to indicate the returned packet won’t be mutated anymore, allowing the packet to be cheaply cloned and moved between execution contexts (threads/async tasks).

§Examples
let mut pkt_mut = PacketMut::with_capacity(4);
pkt_mut.extend_from_slice(b"hello world");
let pkt1 = pkt_mut.freeze();
let pkt2 = pkt1.clone();
assert_eq!(pkt1, pkt2);
let th = std::thread::spawn(move || {
   assert_eq!(&pkt1[..], b"hello world");
});
assert_eq!(&pkt2[..], b"hello world");
th.join().unwrap();
Source

pub fn is_empty(&self) -> bool

Returns true if this PacketMut has a length of 0.

§Examples
let pkt = PacketMut::from(&[]);
assert!(pkt.is_empty());
Source

pub fn iter(&self) -> Iter<'_, u8>

Returns an iterator over the bytes in this PacketMut. The iterator yields all bytes in order from start to end.

§Examples
let pkt = PacketMut::from(&[0xAA, 0xBB, 0xCC]);
let mut iter = pkt.iter();
assert_eq!(iter.next(), Some(&0xAA));
assert_eq!(iter.next(), Some(&0xBB));
assert_eq!(iter.next(), Some(&0xCC));
assert_eq!(iter.next(), None);
Source

pub fn iter_mut(&mut self) -> IterMut<'_, u8>

Returns an iterator over the bytes in this PacketMut that allows modifying each value. The iterator yields all bytes in order from start to end.

§Examples
let mut pkt = PacketMut::from(&[0xAA, 0xBB, 0xCC]);
for byte in pkt.iter_mut() {
    *byte += 1;
}
assert_eq!(pkt.as_ref(), &[0xAB, 0xBC, 0xCD]);
Source

pub fn len(&self) -> usize

Returns the number of bytes contained in this PacketMut.

§Examples
let pkt = PacketMut::from(&[1, 2, 3]);
assert_eq!(pkt.len(), 3);
Source

pub fn truncate(&mut self, count: usize)

Removes the last count bytes from the end of this PacketMut, leaving self.len() - count bytes in the packet. Existing capacity is preserved and the backing buffer is not changed.

§Examples
let mut pkt = PacketMut::from(&[1, 2, 3, 4, 5]);
pkt.truncate(3);
assert_eq!(pkt, PacketMut::from(&[1, 2, 3]));
Source

pub fn truncate_front(&mut self, count: usize)

Removes the first count bytes from the front of this PacketMut, leaving self.len() - count bytes in the packet. Existing capacity is preserved and the backing buffer is not changed.

§Panics

Panics if at > self.len().

§Examples
let mut pkt = PacketMut::from(&[1, 2, 3, 4, 5]);
pkt.truncate_front(2);
assert_eq!(pkt, PacketMut::from(&[3, 4, 5]));
Source

pub fn split_off(&mut self, at: usize) -> PacketMut

Splits the PacketMut into two at the given index.

After the call, self will contain the bytes [0, at), and the returned PacketMut will contain the bytes [at, capacity). Existing capacity is preserved, the backing buffer is not changed, and both self and the returned PacketMut share the same backing buffer.

§Panics

Panics if at > len.

§Complexity

O(1). Indices are adjusted and reference counts are updated, but none of the backing buffer is traversed or cloned.

§Examples
let mut pkt1 = PacketMut::from(&[1, 2, 3, 4, 5]);
let pkt2 = pkt1.split_off(2);
assert_eq!(pkt1, PacketMut::from(&[1, 2]));
assert_eq!(pkt2, PacketMut::from(&[3, 4, 5]));
Source

pub fn split_to(&mut self, at: usize) -> PacketMut

Splits the PacketMut into two at the given index.

After the call, self will contain the bytes [at, len), and the returned PacketMut will contain the bytes [0, at). Existing capacity is preserved, the backing buffer is not changed, and both self and the returned PacketMut share the same backing buffer.

§Panics

Panics if at > len.

§Complexity

O(1). Indices are adjusted and reference counts are updated, but none of the backing buffer is traversed or cloned.

§Examples
let mut pkt1 = PacketMut::from(&[1, 2, 3, 4, 5]);
let pkt2 = pkt1.split_to(2);
assert_eq!(pkt1, PacketMut::from(&[3, 4, 5]));
assert_eq!(pkt2, PacketMut::from(&[1, 2]));
Source

pub fn get_src_addr(&self) -> Option<IpAddr>

Returns the source IP address of the packet.

Returns None if the packet structure doesn’t match an IPv4 or IPv6 datagram.

Source

pub fn get_dst_addr(&self) -> Option<IpAddr>

Returns the destination IP address of the packet.

Returns None if the packet structure doesn’t match an IPv4 or IPv6 datagram.

Trait Implementations§

Source§

impl AsMut<[u8]> for PacketMut

Source§

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

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

impl AsRef<[u8]> for PacketMut

Source§

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

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

impl Buf for PacketMut

Source§

fn remaining(&self) -> usize

Returns the number of bytes between the current position and the end of the buffer. Read more
Source§

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

Returns a slice starting at the current position and of length between 0 and Buf::remaining(). Note that this can return a shorter slice (this allows non-continuous internal representation). Read more
Source§

fn advance(&mut self, cnt: usize)

Advance the internal cursor of the Buf Read more
Source§

fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize

Fills dst with potentially multiple slices starting at self’s current position. Read more
Source§

fn has_remaining(&self) -> bool

Returns true if there are any more bytes to consume Read more
Source§

fn copy_to_slice(&mut self, dst: &mut [u8])

Copies bytes from self into dst. Read more
Source§

fn get_u8(&mut self) -> u8

Gets an unsigned 8 bit integer from self. Read more
Source§

fn get_i8(&mut self) -> i8

Gets a signed 8 bit integer from self. Read more
Source§

fn get_u16(&mut self) -> u16

Gets an unsigned 16 bit integer from self in big-endian byte order. Read more
Source§

fn get_u16_le(&mut self) -> u16

Gets an unsigned 16 bit integer from self in little-endian byte order. Read more
Source§

fn get_u16_ne(&mut self) -> u16

Gets an unsigned 16 bit integer from self in native-endian byte order. Read more
Source§

fn get_i16(&mut self) -> i16

Gets a signed 16 bit integer from self in big-endian byte order. Read more
Source§

fn get_i16_le(&mut self) -> i16

Gets a signed 16 bit integer from self in little-endian byte order. Read more
Source§

fn get_i16_ne(&mut self) -> i16

Gets a signed 16 bit integer from self in native-endian byte order. Read more
Source§

fn get_u32(&mut self) -> u32

Gets an unsigned 32 bit integer from self in the big-endian byte order. Read more
Source§

fn get_u32_le(&mut self) -> u32

Gets an unsigned 32 bit integer from self in the little-endian byte order. Read more
Source§

fn get_u32_ne(&mut self) -> u32

Gets an unsigned 32 bit integer from self in native-endian byte order. Read more
Source§

fn get_i32(&mut self) -> i32

Gets a signed 32 bit integer from self in big-endian byte order. Read more
Source§

fn get_i32_le(&mut self) -> i32

Gets a signed 32 bit integer from self in little-endian byte order. Read more
Source§

fn get_i32_ne(&mut self) -> i32

Gets a signed 32 bit integer from self in native-endian byte order. Read more
Source§

fn get_u64(&mut self) -> u64

Gets an unsigned 64 bit integer from self in big-endian byte order. Read more
Source§

fn get_u64_le(&mut self) -> u64

Gets an unsigned 64 bit integer from self in little-endian byte order. Read more
Source§

fn get_u64_ne(&mut self) -> u64

Gets an unsigned 64 bit integer from self in native-endian byte order. Read more
Source§

fn get_i64(&mut self) -> i64

Gets a signed 64 bit integer from self in big-endian byte order. Read more
Source§

fn get_i64_le(&mut self) -> i64

Gets a signed 64 bit integer from self in little-endian byte order. Read more
Source§

fn get_i64_ne(&mut self) -> i64

Gets a signed 64 bit integer from self in native-endian byte order. Read more
Source§

fn get_u128(&mut self) -> u128

Gets an unsigned 128 bit integer from self in big-endian byte order. Read more
Source§

fn get_u128_le(&mut self) -> u128

Gets an unsigned 128 bit integer from self in little-endian byte order. Read more
Source§

fn get_u128_ne(&mut self) -> u128

Gets an unsigned 128 bit integer from self in native-endian byte order. Read more
Source§

fn get_i128(&mut self) -> i128

Gets a signed 128 bit integer from self in big-endian byte order. Read more
Source§

fn get_i128_le(&mut self) -> i128

Gets a signed 128 bit integer from self in little-endian byte order. Read more
Source§

fn get_i128_ne(&mut self) -> i128

Gets a signed 128 bit integer from self in native-endian byte order. Read more
Source§

fn get_uint(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in big-endian byte order. Read more
Source§

fn get_uint_le(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in little-endian byte order. Read more
Source§

fn get_uint_ne(&mut self, nbytes: usize) -> u64

Gets an unsigned n-byte integer from self in native-endian byte order. Read more
Source§

fn get_int(&mut self, nbytes: usize) -> i64

Gets a signed n-byte integer from self in big-endian byte order. Read more
Source§

fn get_int_le(&mut self, nbytes: usize) -> i64

Gets a signed n-byte integer from self in little-endian byte order. Read more
Source§

fn get_int_ne(&mut self, nbytes: usize) -> i64

Gets a signed n-byte integer from self in native-endian byte order. Read more
Source§

fn get_f32(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in big-endian byte order. Read more
Source§

fn get_f32_le(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in little-endian byte order. Read more
Source§

fn get_f32_ne(&mut self) -> f32

Gets an IEEE754 single-precision (4 bytes) floating point number from self in native-endian byte order. Read more
Source§

fn get_f64(&mut self) -> f64

Gets an IEEE754 double-precision (8 bytes) floating point number from self in big-endian byte order. Read more
Source§

fn get_f64_le(&mut self) -> f64

Gets an IEEE754 double-precision (8 bytes) floating point number from self in little-endian byte order. Read more
Source§

fn get_f64_ne(&mut self) -> f64

Gets an IEEE754 double-precision (8 bytes) floating point number from self in native-endian byte order. Read more
Source§

fn try_copy_to_slice(&mut self, dst: &mut [u8]) -> Result<(), TryGetError>

Copies bytes from self into dst. Read more
Source§

fn try_get_u8(&mut self) -> Result<u8, TryGetError>

Gets an unsigned 8 bit integer from self. Read more
Source§

fn try_get_i8(&mut self) -> Result<i8, TryGetError>

Gets a signed 8 bit integer from self. Read more
Source§

fn try_get_u16(&mut self) -> Result<u16, TryGetError>

Gets an unsigned 16 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_u16_le(&mut self) -> Result<u16, TryGetError>

Gets an unsigned 16 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_u16_ne(&mut self) -> Result<u16, TryGetError>

Gets an unsigned 16 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_i16(&mut self) -> Result<i16, TryGetError>

Gets a signed 16 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_i16_le(&mut self) -> Result<i16, TryGetError>

Gets an signed 16 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_i16_ne(&mut self) -> Result<i16, TryGetError>

Gets a signed 16 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_u32(&mut self) -> Result<u32, TryGetError>

Gets an unsigned 32 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_u32_le(&mut self) -> Result<u32, TryGetError>

Gets an unsigned 32 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_u32_ne(&mut self) -> Result<u32, TryGetError>

Gets an unsigned 32 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_i32(&mut self) -> Result<i32, TryGetError>

Gets a signed 32 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_i32_le(&mut self) -> Result<i32, TryGetError>

Gets a signed 32 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_i32_ne(&mut self) -> Result<i32, TryGetError>

Gets a signed 32 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_u64(&mut self) -> Result<u64, TryGetError>

Gets an unsigned 64 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_u64_le(&mut self) -> Result<u64, TryGetError>

Gets an unsigned 64 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_u64_ne(&mut self) -> Result<u64, TryGetError>

Gets an unsigned 64 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_i64(&mut self) -> Result<i64, TryGetError>

Gets a signed 64 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_i64_le(&mut self) -> Result<i64, TryGetError>

Gets a signed 64 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_i64_ne(&mut self) -> Result<i64, TryGetError>

Gets a signed 64 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_u128(&mut self) -> Result<u128, TryGetError>

Gets an unsigned 128 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_u128_le(&mut self) -> Result<u128, TryGetError>

Gets an unsigned 128 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_u128_ne(&mut self) -> Result<u128, TryGetError>

Gets an unsigned 128 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_i128(&mut self) -> Result<i128, TryGetError>

Gets a signed 128 bit integer from self in big-endian byte order. Read more
Source§

fn try_get_i128_le(&mut self) -> Result<i128, TryGetError>

Gets a signed 128 bit integer from self in little-endian byte order. Read more
Source§

fn try_get_i128_ne(&mut self) -> Result<i128, TryGetError>

Gets a signed 128 bit integer from self in native-endian byte order. Read more
Source§

fn try_get_uint(&mut self, nbytes: usize) -> Result<u64, TryGetError>

Gets an unsigned n-byte integer from self in big-endian byte order. Read more
Source§

fn try_get_uint_le(&mut self, nbytes: usize) -> Result<u64, TryGetError>

Gets an unsigned n-byte integer from self in little-endian byte order. Read more
Source§

fn try_get_uint_ne(&mut self, nbytes: usize) -> Result<u64, TryGetError>

Gets an unsigned n-byte integer from self in native-endian byte order. Read more
Source§

fn try_get_int(&mut self, nbytes: usize) -> Result<i64, TryGetError>

Gets a signed n-byte integer from self in big-endian byte order. Read more
Source§

fn try_get_int_le(&mut self, nbytes: usize) -> Result<i64, TryGetError>

Gets a signed n-byte integer from self in little-endian byte order. Read more
Source§

fn try_get_int_ne(&mut self, nbytes: usize) -> Result<i64, TryGetError>

Gets a signed n-byte integer from self in native-endian byte order. Read more
Source§

fn try_get_f32(&mut self) -> Result<f32, TryGetError>

Gets an IEEE754 single-precision (4 bytes) floating point number from self in big-endian byte order. Read more
Source§

fn try_get_f32_le(&mut self) -> Result<f32, TryGetError>

Gets an IEEE754 single-precision (4 bytes) floating point number from self in little-endian byte order. Read more
Source§

fn try_get_f32_ne(&mut self) -> Result<f32, TryGetError>

Gets an IEEE754 single-precision (4 bytes) floating point number from self in native-endian byte order. Read more
Source§

fn try_get_f64(&mut self) -> Result<f64, TryGetError>

Gets an IEEE754 double-precision (8 bytes) floating point number from self in big-endian byte order. Read more
Source§

fn try_get_f64_le(&mut self) -> Result<f64, TryGetError>

Gets an IEEE754 double-precision (8 bytes) floating point number from self in little-endian byte order. Read more
Source§

fn try_get_f64_ne(&mut self) -> Result<f64, TryGetError>

Gets an IEEE754 double-precision (8 bytes) floating point number from self in native-endian byte order. Read more
Source§

fn copy_to_bytes(&mut self, len: usize) -> Bytes

Consumes len bytes inside self and returns new instance of Bytes with this data. Read more
Source§

fn take(self, limit: usize) -> Take<Self>
where Self: Sized,

Creates an adaptor which will read at most limit bytes from self. Read more
Source§

fn chain<U>(self, next: U) -> Chain<Self, U>
where U: Buf, Self: Sized,

Creates an adaptor which will chain this buffer with another. Read more
Source§

fn reader(self) -> Reader<Self>
where Self: Sized,

Creates an adaptor which implements the Read trait for self. Read more
Source§

impl BufMut for PacketMut

Source§

fn remaining_mut(&self) -> usize

Returns the number of bytes that can be written from the current position until the end of the buffer is reached. Read more
Source§

unsafe fn advance_mut(&mut self, cnt: usize)

Advance the internal cursor of the BufMut Read more
Source§

fn chunk_mut(&mut self) -> &mut UninitSlice

Returns a mutable slice starting at the current BufMut position and of length between 0 and BufMut::remaining_mut(). Note that this can be shorter than the whole remainder of the buffer (this allows non-continuous implementation). Read more
Source§

fn has_remaining_mut(&self) -> bool

Returns true if there is space in self for more bytes. Read more
Source§

fn put<T>(&mut self, src: T)
where T: Buf, Self: Sized,

Transfer bytes into self from src and advance the cursor by the number of bytes written. Read more
Source§

fn put_slice(&mut self, src: &[u8])

Transfer bytes into self from src and advance the cursor by the number of bytes written. Read more
Source§

fn put_bytes(&mut self, val: u8, cnt: usize)

Put cnt bytes val into self. Read more
Source§

fn put_u8(&mut self, n: u8)

Writes an unsigned 8 bit integer to self. Read more
Source§

fn put_i8(&mut self, n: i8)

Writes a signed 8 bit integer to self. Read more
Source§

fn put_u16(&mut self, n: u16)

Writes an unsigned 16 bit integer to self in big-endian byte order. Read more
Source§

fn put_u16_le(&mut self, n: u16)

Writes an unsigned 16 bit integer to self in little-endian byte order. Read more
Source§

fn put_u16_ne(&mut self, n: u16)

Writes an unsigned 16 bit integer to self in native-endian byte order. Read more
Source§

fn put_i16(&mut self, n: i16)

Writes a signed 16 bit integer to self in big-endian byte order. Read more
Source§

fn put_i16_le(&mut self, n: i16)

Writes a signed 16 bit integer to self in little-endian byte order. Read more
Source§

fn put_i16_ne(&mut self, n: i16)

Writes a signed 16 bit integer to self in native-endian byte order. Read more
Source§

fn put_u32(&mut self, n: u32)

Writes an unsigned 32 bit integer to self in big-endian byte order. Read more
Source§

fn put_u32_le(&mut self, n: u32)

Writes an unsigned 32 bit integer to self in little-endian byte order. Read more
Source§

fn put_u32_ne(&mut self, n: u32)

Writes an unsigned 32 bit integer to self in native-endian byte order. Read more
Source§

fn put_i32(&mut self, n: i32)

Writes a signed 32 bit integer to self in big-endian byte order. Read more
Source§

fn put_i32_le(&mut self, n: i32)

Writes a signed 32 bit integer to self in little-endian byte order. Read more
Source§

fn put_i32_ne(&mut self, n: i32)

Writes a signed 32 bit integer to self in native-endian byte order. Read more
Source§

fn put_u64(&mut self, n: u64)

Writes an unsigned 64 bit integer to self in the big-endian byte order. Read more
Source§

fn put_u64_le(&mut self, n: u64)

Writes an unsigned 64 bit integer to self in little-endian byte order. Read more
Source§

fn put_u64_ne(&mut self, n: u64)

Writes an unsigned 64 bit integer to self in native-endian byte order. Read more
Source§

fn put_i64(&mut self, n: i64)

Writes a signed 64 bit integer to self in the big-endian byte order. Read more
Source§

fn put_i64_le(&mut self, n: i64)

Writes a signed 64 bit integer to self in little-endian byte order. Read more
Source§

fn put_i64_ne(&mut self, n: i64)

Writes a signed 64 bit integer to self in native-endian byte order. Read more
Source§

fn put_u128(&mut self, n: u128)

Writes an unsigned 128 bit integer to self in the big-endian byte order. Read more
Source§

fn put_u128_le(&mut self, n: u128)

Writes an unsigned 128 bit integer to self in little-endian byte order. Read more
Source§

fn put_u128_ne(&mut self, n: u128)

Writes an unsigned 128 bit integer to self in native-endian byte order. Read more
Source§

fn put_i128(&mut self, n: i128)

Writes a signed 128 bit integer to self in the big-endian byte order. Read more
Source§

fn put_i128_le(&mut self, n: i128)

Writes a signed 128 bit integer to self in little-endian byte order. Read more
Source§

fn put_i128_ne(&mut self, n: i128)

Writes a signed 128 bit integer to self in native-endian byte order. Read more
Source§

fn put_uint(&mut self, n: u64, nbytes: usize)

Writes an unsigned n-byte integer to self in big-endian byte order. Read more
Source§

fn put_uint_le(&mut self, n: u64, nbytes: usize)

Writes an unsigned n-byte integer to self in the little-endian byte order. Read more
Source§

fn put_uint_ne(&mut self, n: u64, nbytes: usize)

Writes an unsigned n-byte integer to self in the native-endian byte order. Read more
Source§

fn put_int(&mut self, n: i64, nbytes: usize)

Writes low nbytes of a signed integer to self in big-endian byte order. Read more
Source§

fn put_int_le(&mut self, n: i64, nbytes: usize)

Writes low nbytes of a signed integer to self in little-endian byte order. Read more
Source§

fn put_int_ne(&mut self, n: i64, nbytes: usize)

Writes low nbytes of a signed integer to self in native-endian byte order. Read more
Source§

fn put_f32(&mut self, n: f32)

Writes an IEEE754 single-precision (4 bytes) floating point number to self in big-endian byte order. Read more
Source§

fn put_f32_le(&mut self, n: f32)

Writes an IEEE754 single-precision (4 bytes) floating point number to self in little-endian byte order. Read more
Source§

fn put_f32_ne(&mut self, n: f32)

Writes an IEEE754 single-precision (4 bytes) floating point number to self in native-endian byte order. Read more
Source§

fn put_f64(&mut self, n: f64)

Writes an IEEE754 double-precision (8 bytes) floating point number to self in big-endian byte order. Read more
Source§

fn put_f64_le(&mut self, n: f64)

Writes an IEEE754 double-precision (8 bytes) floating point number to self in little-endian byte order. Read more
Source§

fn put_f64_ne(&mut self, n: f64)

Writes an IEEE754 double-precision (8 bytes) floating point number to self in native-endian byte order. Read more
Source§

fn limit(self, limit: usize) -> Limit<Self>
where Self: Sized,

Creates an adaptor which can write at most limit bytes to self. Read more
Source§

fn writer(self) -> Writer<Self>
where Self: Sized,

Creates an adaptor which implements the Write trait for self. Read more
Source§

fn chain_mut<U>(self, next: U) -> Chain<Self, U>
where U: BufMut, Self: Sized,

Creates an adapter which will chain this buffer with another. Read more
Source§

impl Buffer for PacketMut

Source§

fn extend_from_slice(&mut self, other: &[u8]) -> Result<()>

Extend this buffer from the given slice
Source§

fn truncate(&mut self, len: usize)

Truncate this buffer to the given size
Source§

fn len(&self) -> usize

Get the length of the buffer
Source§

fn is_empty(&self) -> bool

Is the buffer empty?
Source§

impl Clone for PacketMut

Source§

fn clone(&self) -> PacketMut

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PacketMut

Source§

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

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

impl Eq for PacketMut

Source§

impl<const N: usize> From<&[u8; N]> for PacketMut

Source§

fn from(value: &[u8; N]) -> Self

Converts to this type from the input type.
Source§

impl From<&[u8]> for PacketMut

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<BytesMut> for PacketMut

Source§

fn from(value: BytesMut) -> Self

Converts to this type from the input type.
Source§

impl From<PacketMut> for Packet

Source§

fn from(value: PacketMut) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for PacketMut

Source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<T> Index<T> for PacketMut
where [u8]: Index<T>,

Source§

type Output = <[u8] as Index<T>>::Output

The returned type after indexing.
Source§

fn index(&self, index: T) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<T> for PacketMut
where [u8]: IndexMut<T>,

Source§

fn index_mut(&mut self, index: T) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl LowerHex for PacketMut

Source§

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

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

impl Ord for PacketMut

Source§

fn cmp(&self, other: &PacketMut) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for PacketMut

Source§

fn eq(&self, other: &PacketMut) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PacketMut

Source§

fn partial_cmp(&self, other: &PacketMut) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for PacketMut

Source§

impl UpperHex for PacketMut

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.