pub struct Uninit<T>(/* private fields */);
Expand description
A Slice
that only exposes uninitialized bytes.
Uninit
can be created with IoBuf::uninit
.
§Examples
Creating an uninit slice
use compio_buf::IoBuf;
let mut buf = Vec::from(b"hello world");
buf.reserve_exact(10);
let slice = buf.uninit();
assert_eq!(slice.as_slice(), b"");
assert_eq!(slice.buf_capacity(), 10);
Implementations§
Source§impl<T> Uninit<T>
impl<T> Uninit<T>
Sourcepub fn begin(&self) -> usize
pub fn begin(&self) -> usize
Offset in the underlying buffer at which uninitialized bytes starts.
Sourcepub fn as_inner(&self) -> &T
pub fn as_inner(&self) -> &T
Gets a reference to the underlying buffer.
This method escapes the slice’s view.
Sourcepub fn as_inner_mut(&mut self) -> &mut T
pub fn as_inner_mut(&mut self) -> &mut T
Gets a mutable reference to the underlying buffer.
This method escapes the slice’s view.
Trait Implementations§
Source§impl<T: IoBuf> IoBuf for Uninit<T>
impl<T: IoBuf> IoBuf for Uninit<T>
Source§fn buf_capacity(&self) -> usize
fn buf_capacity(&self) -> usize
Total size of the buffer, including uninitialized memory, if any. Read more
Source§fn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>where
Self: Sized,
fn slice(self, range: impl RangeBounds<usize>) -> Slice<Self>where
Self: Sized,
Returns a view of the buffer with the specified range. Read more
Source§impl<T: IoBufMut> IoBufMut for Uninit<T>
impl<T: IoBufMut> IoBufMut for Uninit<T>
Source§fn as_buf_mut_ptr(&mut self) -> *mut u8
fn as_buf_mut_ptr(&mut self) -> *mut u8
Returns a raw mutable pointer to the vector’s buffer. Read more
Source§fn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>]
fn as_mut_slice(&mut self) -> &mut [MaybeUninit<u8>]
Get the uninitialized part of the buffer.
Source§unsafe fn as_io_slice_mut(&mut self) -> IoSliceMut
unsafe fn as_io_slice_mut(&mut self) -> IoSliceMut
Create an
IoSliceMut
of the uninitialized part of the buffer. Read moreSource§impl<T: Ord> Ord for Uninit<T>
impl<T: Ord> Ord for Uninit<T>
Source§impl<T: PartialOrd> PartialOrd for Uninit<T>
impl<T: PartialOrd> PartialOrd for Uninit<T>
Source§impl<T: SetBufInit + IoBuf> SetBufInit for Uninit<T>
impl<T: SetBufInit + IoBuf> SetBufInit for Uninit<T>
Source§unsafe fn set_buf_init(&mut self, len: usize)
unsafe fn set_buf_init(&mut self, len: usize)
Set the buffer length. If
len
is less than the current length, nothing
should happen. Read moreimpl<T: Copy> Copy for Uninit<T>
impl<T: Eq> Eq for Uninit<T>
impl<T> StructuralPartialEq for Uninit<T>
Auto Trait Implementations§
impl<T> Freeze for Uninit<T>where
T: Freeze,
impl<T> RefUnwindSafe for Uninit<T>where
T: RefUnwindSafe,
impl<T> Send for Uninit<T>where
T: Send,
impl<T> Sync for Uninit<T>where
T: Sync,
impl<T> Unpin for Uninit<T>where
T: Unpin,
impl<T> UnwindSafe for Uninit<T>where
T: UnwindSafe,
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