Struct IoSlice
#[repr(transparent)]
pub struct IoSlice<'a>(pub(in ::io::io_slice) IoSlice<'a>);
A buffer type used with Write::write_vectored.
It is semantically a wrapper around a &[u8], but is guaranteed to be
ABI compatible with the iovec type on Unix platforms and WSABUF on
Windows.
Fields
0: IoSlice<'a>
Implementations
impl<'a> IoSlice<'a>
fn new(buf: &'a [u8]) -> IoSlice<'a>Creates a new
IoSlicewrapping a byte slice.Panics
Panics on Windows if the slice is larger than 4GB.
fn advance(&mut self, n: usize)Advance the internal cursor of the slice.
Also see
IoSlice::advance_slicesto advance the cursors of multiple buffers.Panics
Panics when trying to advance beyond the end of the slice.
Examples
use IoSlice; use Deref; let data = ; let mut buf = new; // Mark 3 bytes as read. buf.advance; assert_eq!;fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize)Advance a slice of slices.
Shrinks the slice to remove any
IoSlices that are fully advanced over. If the cursor ends up in the middle of anIoSlice, it is modified to start at that cursor.For example, if we have a slice of two 8-byte
IoSlices, and we advance by 10 bytes, the result will only include the secondIoSlice, advanced by 2 bytes.Panics
Panics when trying to advance beyond the end of the slices.
Examples
use IoSlice; use Deref; let buf1 = ; let buf2 = ; let buf3 = ; let mut bufs = &mut ; // Mark 10 bytes as written. advance_slices; assert_eq!; assert_eq!;const fn as_slice(self) -> &'a [u8]Get the underlying bytes as a slice with the original lifetime.
This doesn't borrow from
self, so is less restrictive than calling.deref(), which does.Examples
use IoSlice; let data = b"abcdef"; let mut io_slice = new; let tail = &io_slice.as_slice; // This works because `tail` doesn't borrow `io_slice` io_slice = new; assert_eq!;
Trait Implementations
impl<'a> Clone for IoSlice<'a>
fn clone(&self) -> IoSlice<'a>
impl<'a> Copy for IoSlice<'a>
impl<'a> Debug for IoSlice<'a>
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<'a> Deref for IoSlice<'a>
type Target = [u8];fn deref(&self) -> &[u8]
impl<'a> Send for IoSlice<'a>
impl<'a> Sync for IoSlice<'a>
impl<'a> TrivialClone for IoSlice<'a>
Auto Trait Implementations
impl<'a> Freeze for IoSlice<'a>
impl<'a> RefUnwindSafe for IoSlice<'a>
impl<'a> Unpin for IoSlice<'a>
impl<'a> UnsafeUnpin for IoSlice<'a>
impl<'a> UnwindSafe for IoSlice<'a>
Blanket Implementations
impl<P, T> Receiver for IoSlice<'a>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for IoSlice<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for IoSlice<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for IoSlice<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for IoSlice<'a>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for IoSlice<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Printable for IoSlice<'a>
where
T: Copy + Debug,
impl<T> SizeHint for IoSlice<'a>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for IoSlice<'a>
impl<T, U> Into<U> for IoSlice<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for IoSlice<'a>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for IoSlice<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>