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 for Uninit<T>where
T: IoBuf,
impl<T> IoBuf for Uninit<T>where
T: IoBuf,
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 for Uninit<T>where
T: IoBufMut,
impl<T> IoBufMut for Uninit<T>where
T: IoBufMut,
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 for Uninit<T>where
T: Ord,
impl<T> Ord for Uninit<T>where
T: Ord,
Source§impl<T> PartialOrd for Uninit<T>where
T: PartialOrd,
impl<T> PartialOrd for Uninit<T>where
T: PartialOrd,
Source§impl<T> SetBufInit for Uninit<T>where
T: SetBufInit + IoBuf,
impl<T> SetBufInit for Uninit<T>where
T: SetBufInit + IoBuf,
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 for Uninit<T>where
T: Copy,
impl<T> Eq for Uninit<T>where
T: Eq,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more