Struct IoSlice
struct 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.
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(self: &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: 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!;
impl<'a> Clone for IoSlice<'a>
fn clone(self: &Self) -> IoSlice<'a>
impl<'a> Copy for IoSlice<'a>
impl<'a> Debug for IoSlice<'a>
fn fmt(self: &Self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result
impl<'a> Deref for IoSlice<'a>
fn deref(self: &Self) -> &[u8]
impl<'a> Freeze for IoSlice<'a>
impl<'a> RefUnwindSafe for IoSlice<'a>
impl<'a> Send for IoSlice<'a>
impl<'a> Sync for IoSlice<'a>
impl<'a> Unpin for IoSlice<'a>
impl<'a> UnwindSafe for IoSlice<'a>
impl<P, T> Receiver for IoSlice<'a>
impl<T> Any for IoSlice<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for IoSlice<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for IoSlice<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for IoSlice<'a>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for IoSlice<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for IoSlice<'a>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for IoSlice<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for IoSlice<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for IoSlice<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>