[−][src]Trait uninit::read::ReadIntoUninit
feature="std"
only.Trait for a Read
able
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_buf
is a prefix slice ofbuf
.-
this property is equivalent to:
init_buf.as_mut_ptr() == buf.as_mut_ptr() as *mut u8
andinit_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.
ⓘImportant traits for Chain<R1, R2>fn chain<R: ReadIntoUninit>(self, next: R) -> Chain<Self, R> where
Self: Sized,
Self: Sized,
feature="std"
and feature="chain"
only.Chains / concats two ReadIntoUninit
readers into one.
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]>
Implementors
impl<R1, R2> ReadIntoUninit for Chain<R1, R2> where
R1: ReadIntoUninit,
R2: ReadIntoUninit,
[src]
R1: ReadIntoUninit,
R2: ReadIntoUninit,
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 R
[src]
default 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]>
default fn read_into_uninit_exact<'buf>(
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>
[src]
&mut self,
buf: Out<'buf, [u8]>
) -> Result<&'buf mut [u8]>