pub struct PacketRef<'pool> { /* private fields */ }Expand description
Owned handle to a PacketBuffer allocated from a PacketPool.
Provides Deref/DerefMut access to the underlying buffer and
automatically returns it to the pool on drop. Use into_index
when the buffer must be handed off by index (e.g. to a ring buffer)
without triggering the auto-free.
Implementations§
Source§impl PacketRef<'_>
impl PacketRef<'_>
Sourcepub fn into_index(self) -> u32
pub fn into_index(self) -> u32
Consumes the handle and returns the raw buffer index without freeing the buffer back to the pool.
The caller is responsible for eventually freeing the buffer
(e.g. via PacketPool::free_by_index).
Methods from Deref<Target = PacketBuffer>§
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Returns the buffer data as a mutable slice.
Sourcepub fn as_full_slice(&self) -> &[u8] ⓘ
pub fn as_full_slice(&self) -> &[u8] ⓘ
Returns the full buffer capacity.
Sourcepub fn as_full_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_full_mut_slice(&mut self) -> &mut [u8] ⓘ
Returns the full buffer as mutable.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Returns a mutable pointer to the buffer data.
Trait Implementations§
Source§impl Deref for PacketRef<'_>
impl Deref for PacketRef<'_>
Source§type Target = PacketBuffer
type Target = PacketBuffer
The resulting type after dereferencing.
Source§fn deref(&self) -> &PacketBuffer
fn deref(&self) -> &PacketBuffer
Dereferences the value.
Source§impl DerefMut for PacketRef<'_>
impl DerefMut for PacketRef<'_>
Source§fn deref_mut(&mut self) -> &mut PacketBuffer
fn deref_mut(&mut self) -> &mut PacketBuffer
Mutably dereferences the value.
Auto Trait Implementations§
impl<'pool> !RefUnwindSafe for PacketRef<'pool>
impl<'pool> !UnwindSafe for PacketRef<'pool>
impl<'pool> Freeze for PacketRef<'pool>
impl<'pool> Send for PacketRef<'pool>
impl<'pool> Sync for PacketRef<'pool>
impl<'pool> Unpin for PacketRef<'pool>
impl<'pool> UnsafeUnpin for PacketRef<'pool>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more