[][src]Trait uninit::read::ReadIntoUninit

pub unsafe trait ReadIntoUninit: Read {
    fn read_into_uninit<'buf>(
        &mut self,
        buf: Out<'buf, [u8]>
    ) -> Result<&'buf mut [u8]>; fn read_into_uninit_exact<'buf>(
        &mut self,
        buf: Out<'buf, [u8]>
    ) -> Result<&'buf mut [u8]> { ... }
fn chain<R: ReadIntoUninit>(self, next: R) -> Chain<Self, R>
    where
        Self: Sized
, { ... } }
This is supported on feature="std" only.

Trait for a Readable type that can output the bytes read into uninitialised memory.

Safety

The trait is marked unsafe because it needs to guarantee that:

  • if let Ok(init_buf) = self.read_into_uninit(buf), then init_buf is a prefix slice of buf.

    • this property is equivalent to:

      init_buf.as_mut_ptr() == buf.as_mut_ptr() as *mut u8 and init_buf.len() <= buf.len()

    • as well as:

      buf[.. init_buf.len()] is sound to assume_init

unsafe code can assume this property to skip checks or manual initialization, and that's why incorrectly impl-ementing this marker trait can compromise memory safety.

Required methods

fn read_into_uninit<'buf>(
    &mut self,
    buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>

This is supported on feature="std" only.

Single attempt to read bytes from Self into buf.

On success, it returns the bytes having been read. This returned slice is guaranteed to be a prefix slice of buf.

This is not guaranteed to read buf.len() bytes, see the docs of .read() for more information.

Loading content...

Provided methods

fn read_into_uninit_exact<'buf>(
    &mut self,
    buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>

This is supported on feature="std" only.

Attempts to fill buf through multiple .read() calls if necessary.

On success, it returns the bytes having been read. This returned slice is guaranteed to be buf.

See the docs of .read_exact() for more information.

Important traits for Chain<R1, R2>
fn chain<R: ReadIntoUninit>(self, next: R) -> Chain<Self, R> where
    Self: Sized

This is supported on feature="std" and feature="chain" only.

Chains / concats two ReadIntoUninit readers into one.

Loading content...

Implementations on Foreign Types

impl<'_, R: ReadIntoUninit + ?Sized> ReadIntoUninit for &'_ mut R[src]

impl<'_> ReadIntoUninit for &'_ [u8][src]

impl<R: Read> ReadIntoUninit for BufReader<R>[src]

impl<T: AsRef<[u8]>> ReadIntoUninit for Cursor<T>[src]

impl ReadIntoUninit for Empty[src]

impl<'_> ReadIntoUninit for StdinLock<'_>[src]

impl<T: BufRead> ReadIntoUninit for Take<T>[src]

impl<R: ReadIntoUninit + ?Sized> ReadIntoUninit for Box<R>[src]

Loading content...

Implementors

impl<R1, R2> ReadIntoUninit for Chain<R1, R2> where
    R1: ReadIntoUninit,
    R2: ReadIntoUninit
[src]

impl<R: Read> ReadIntoUninit for R[src]

Loading content...