[−][src]Trait uninit::read::ReadIntoUninit
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), theninit_bufis a prefix slice ofbuf.-
this property is equivalent to:
init_buf.as_mut_ptr() == buf.as_mut_ptr() as *mut u8andinit_buf.len() <= buf.len() -
as well as:
buf[.. init_buf.len()]is sound toassume_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]>
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
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.
Provided methods
fn read_into_uninit_exact<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
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.
Implementations on Foreign Types
impl<'_, R: ReadIntoUninit + ?Sized> ReadIntoUninit for &'_ mut R[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<'_> ReadIntoUninit for &'_ [u8][src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<R: Read> ReadIntoUninit for BufReader<R>[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<T: AsRef<[u8]>> ReadIntoUninit for Cursor<T>[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl ReadIntoUninit for Empty[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<'_> ReadIntoUninit for StdinLock<'_>[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<T: BufRead> ReadIntoUninit for Take<T>[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
impl<R: ReadIntoUninit + ?Sized> ReadIntoUninit for Box<R>[src]
fn read_into_uninit<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>