[−][src]Struct ioslice::IoSliceMut
A #![no_std]
-friendly wrapper over the std::io::IoSliceMut
.
Internally, the struct will store the following based on crate features:
std
- wrappingstd::io::IoSliceMut
directly, with accessors for it as well as conversion functions and From impls.libc
(with#[cfg(unix)]
- wrapping [libc::iovec
] directly on platforms that support it, together with a marker making rustc think this stores a&'a mut [u8]
.- (none) - wrapping a regular slice, that may not have the same ABI guarantees as the types from std or libc have.
Implementations
impl<'a, I: Initialization> IoSliceMut<'a, I>
[src]
pub fn new(slice: &'a mut [u8]) -> Self
[src]
Construct a new mutable I/O slice, from an existing initialized slice. The initializedness
is determined based on the generic parameter I
, while the original slice obviously has to
be initialized since its type is u8
and not [MaybeUninit<u8>
].
pub unsafe fn assume_init(self) -> IoSliceMut<'a, Initialized>
[src]
Unsafely cast a possibly uninitialized slice into an initialized slice.
NOTE: THIS MUST NOT BE USED FOR INITIALIZATION; THAT IS DIRECT UB
Safety
For this to be safe, the initialization invariant must be upheld. Refer to the
std::mem::MaybeUninit
docs.
pub unsafe fn assume_init_ref(&self) -> &IoSliceMut<'a, Initialized>
[src]
Unsafely cast a possibly uninitialized slice into an initialized slice, by reference.
Safety
This must uphold the initialization invariant.
pub unsafe fn assume_init_mut(&mut self) -> &mut IoSliceMut<'a, Initialized>
[src]
Unsafely cast a possibly uninitialized slice into an initialized slice, by mutable reference.
Safety
This must uphold the initialization invariant.
pub fn into_uninit(self) -> IoSliceMut<'a, Uninitialized>
[src]
Cast an I/O slice, being Initialized
or not, into an Uninitialized
I/O slice.
pub fn as_uninit(&self) -> &IoSliceMut<'a, Uninitialized>
[src]
Cast an I/O slice, being Initialized
or not, into an Uninitialized
I/O slice, by
reference.
pub fn as_uninit_mut(&mut self) -> &mut IoSliceMut<'a, Uninitialized>
[src]
Cast an I/O slice, being Initialized
or not, into an Uninitialized
I/O slice, by
mutable reference.
pub fn advance(&mut self, count: usize)
[src]
Advance the start offset of a single slice by count
bytes, reducing the length as well.
Panics
This will panic if count
is greater than the current length.
#[must_use]pub fn advance_within(slices: &mut [Self], n: usize) -> Option<&mut [Self]>
[src]
Advance multiple slices by n
, skipping and truncating slices until there are n
less
total bytes.
They are always advanced from start to end, and only the last slice will actually be
changed if the count turned out to be uneven. None
is returned if n
turns out to be
greater than the total length of the slices, so that counting beforehand becomes
unnecessary.
pub fn inner_data(&self) -> &[I::DerefTargetItem]
[src]
Retrieve the "inner data" immutably, pointed to by the I/O slice, being to either &[u8]
or &[MaybeUninit<u8>]
depending on the generic type parameter I
.
pub fn inner_data_mut(&mut self) -> &mut [I::DerefTargetItem]
[src]
Retrieve the "inner data" mutably, pointed to by the I/O slice, being to either &mut [u8]
or &mut [MaybeUninit<u8>]
depending on the generic type parameter I
.
pub fn into_inner_data(self) -> &'a mut [I::DerefTargetItem]
[src]
Get the "inner data" mutably, but with the lifetime 'a
rather than the lifetime of
self
.
pub fn from_inner_data(inner_data: &'a mut [I::DerefTargetItem]) -> Self
[src]
Convert a regular slice that points to either u8
or MaybeUninit<u8>
, into
IoSliceMut
.
pub fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<u8>]
[src]
pub fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<u8>]
[src]
#[must_use]pub fn zeroed(self) -> IoSliceMut<'a, Initialized>
[src]
#[must_use]pub fn zeroed_by_ref<'b>(&'b mut self) -> &'b mut IoSliceMut<'a, Initialized>
[src]
impl<'a> IoSliceMut<'a, Initialized>
[src]
pub fn as_slice(&self) -> &[u8]
[src]
Retrieve the inner slice immutably. This requires the I/O slice to be initialized.
Unlike the immutable IoSlice
, this will require a secondary lifetime of self
, to
prevent aliasing when the data can be mutated. If it is necessary to obtain a byte slice
with lifetime 'a
, use to_slice
.
pub fn into_slice(self) -> &'a [u8]
[src]
Take an IoSliceMut
by value, turning it into an immutable byte slice of lifetime 'a
.
pub fn as_slice_mut(&mut self) -> &mut [u8]
[src]
Retrieve the inner slice mutably. This requires the I/O slice to be initialized.
Note that unlike into_slice_mut
, this will have the lifetime of self
, not 'a
.
pub fn into_slice_mut(self) -> &'a mut [u8]
[src]
Take an IoSliceMut
by value, turning it into a mutable byte slice of lifetime 'a
.
pub fn cast_to_std_ioslices<'b>(slices: &'b [Self]) -> &'b [IoSlice<'a>]
[src]
Cast &[IoSliceMut]
to &[std::io::IoSlice]
.
pub fn cast_to_std_mut_ioslices<'b>(slices: &'b [Self]) -> &'b [IoSliceMut<'a>]
[src]
Cast &[IoSliceMut]
to &[std::io::IoSliceMut]
.
pub fn cast_to_std_ioslices_mut<'b>(
slices: &'b mut [Self]
) -> &'b mut [IoSlice<'a>]
[src]
slices: &'b mut [Self]
) -> &'b mut [IoSlice<'a>]
Cast &mut [IoSliceMut]
to &mut [std::io::IoSlice]
.
pub fn cast_to_std_mut_ioslices_mut(
slices: &'a mut [Self]
) -> &'a mut [IoSliceMut<'a>]
[src]
slices: &'a mut [Self]
) -> &'a mut [IoSliceMut<'a>]
Cast &mut [IoSliceMut]
to &mut [std::io::IoSliceMut]
.
Trait Implementations
impl<'a, I: Initialization> AsMut<[<I as Initialization>::DerefTargetItem]> for IoSliceMut<'a, I>
[src]
fn as_mut(&mut self) -> &mut [I::DerefTargetItem]
[src]
impl<'a, I: Initialization> AsRef<[<I as Initialization>::DerefTargetItem]> for IoSliceMut<'a, I>
[src]
fn as_ref(&self) -> &[I::DerefTargetItem]
[src]
impl<'a, I: Initialization> Borrow<[<I as Initialization>::DerefTargetItem]> for IoSliceMut<'a, I>
[src]
fn borrow(&self) -> &[I::DerefTargetItem]
[src]
impl<'a, I: Initialization> BorrowMut<[<I as Initialization>::DerefTargetItem]> for IoSliceMut<'a, I>
[src]
fn borrow_mut(&mut self) -> &mut [I::DerefTargetItem]
[src]
impl<'a, I: Initialization> Debug for IoSliceMut<'a, I>
[src]
impl<'a, I: Initialization> Deref for IoSliceMut<'a, I>
[src]
type Target = [I::DerefTargetItem]
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'a, I: Initialization> DerefMut for IoSliceMut<'a, I>
[src]
impl<'a> Eq for IoSliceMut<'a, Initialized>
[src]
impl<'a, I: Initialization> From<&'a mut [<I as Initialization>::DerefTargetItem]> for IoSliceMut<'a, I>
[src]
fn from(slice: &'a mut [I::DerefTargetItem]) -> Self
[src]
impl<'a> From<&'a mut [u8]> for IoSliceMut<'a, Uninitialized>
[src]
impl<'a> Hash for IoSliceMut<'a, Initialized>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a> Ord for IoSliceMut<'a, Initialized>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> PartialEq<[u8]> for IoSliceMut<'a, Initialized>
[src]
impl<'a, 'b> PartialEq<IoSlice<'b, Initialized>> for IoSliceMut<'a, Initialized>
[src]
fn eq(&self, other: &IoSlice<'b>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<IoSliceMut<'a, Initialized>> for IoSliceMut<'a, Initialized>
[src]
impl<'a, 'b> PartialEq<IoSliceMut<'b, Initialized>> for IoSlice<'a, Initialized>
[src]
fn eq(&self, other: &IoSliceMut<'b>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<[u8]> for IoSliceMut<'a, Initialized>
[src]
fn partial_cmp(&self, other: &[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialOrd<IoSlice<'b, Initialized>> for IoSliceMut<'a, Initialized>
[src]
fn partial_cmp(&self, other: &IoSlice<'b, Initialized>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialOrd<IoSliceMut<'a, Initialized>> for IoSliceMut<'a, Initialized>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> PartialOrd<IoSliceMut<'b, Initialized>> for IoSlice<'a, Initialized>
[src]
fn partial_cmp(&self, other: &IoSliceMut<'b>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, I: Initialization> RefUnwindSafe for IoSliceMut<'a, I>
[src]
impl<'a, I: Initialization> Send for IoSliceMut<'a, I>
[src]
impl<'a, I: Initialization> Sync for IoSliceMut<'a, I>
[src]
impl<'a, I: Initialization> Unpin for IoSliceMut<'a, I>
[src]
impl<'a, I: Initialization> UnwindSafe for IoSliceMut<'a, I>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,