pub struct Stream(/* private fields */);
Expand description
An object representing a Zircon stream.
As essentially a subtype of Handle
, it can be freely interconverted.
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn create(
options: StreamOptions,
vmo: &Vmo,
offset: u64,
) -> Result<Self, Status>
pub fn create( options: StreamOptions, vmo: &Vmo, offset: u64, ) -> Result<Self, Status>
See zx_stream_create
Sourcepub unsafe fn readv(
&self,
options: StreamReadOptions,
iovecs: &mut [zx_iovec_t],
) -> Result<usize, Status>
pub unsafe fn readv( &self, options: StreamReadOptions, iovecs: &mut [zx_iovec_t], ) -> Result<usize, Status>
Wraps the
zx_stream_readv
syscall.
§Safety
The caller is responsible for ensuring that the buffers in iovecs
point to valid (albeit
not necessarily initialized) memory.
Sourcepub fn read_uninit(
&self,
options: StreamReadOptions,
buffer: &mut [MaybeUninit<u8>],
) -> Result<usize, Status>
pub fn read_uninit( &self, options: StreamReadOptions, buffer: &mut [MaybeUninit<u8>], ) -> Result<usize, Status>
Attempts to read buffer.len()
bytes from the stream starting at the stream’s current seek
offset. Only the number of bytes read from the stream will be initialized in buffer
.
Returns the number of bytes read from the stream.
See zx_stream_readv.
Sourcepub fn read_to_vec(
&self,
options: StreamReadOptions,
length: usize,
) -> Result<Vec<u8>, Status>
pub fn read_to_vec( &self, options: StreamReadOptions, length: usize, ) -> Result<Vec<u8>, Status>
Attempts to read length
bytes from the stream starting at the stream’s current seek
offset. Returns the read bytes as a Vec
.
See zx_stream_readv.
Sourcepub unsafe fn readv_at(
&self,
options: StreamReadOptions,
offset: u64,
iovecs: &mut [zx_iovec_t],
) -> Result<usize, Status>
pub unsafe fn readv_at( &self, options: StreamReadOptions, offset: u64, iovecs: &mut [zx_iovec_t], ) -> Result<usize, Status>
Wraps the
zx_stream_readv_at
syscall.
§Safety
The caller is responsible for ensuring that the buffers in iovecs
point to valid (albeit
not necessarily initialized) memory.
Sourcepub fn read_at_uninit(
&self,
options: StreamReadOptions,
offset: u64,
buffer: &mut [MaybeUninit<u8>],
) -> Result<usize, Status>
pub fn read_at_uninit( &self, options: StreamReadOptions, offset: u64, buffer: &mut [MaybeUninit<u8>], ) -> Result<usize, Status>
Attempts to read buffer.len()
bytes from the stream starting at offset
. Only the number
of bytes read from the stream will be initialized in buffer
. Returns the number of bytes
read from the stream.
See zx_stream_readv_at.
Sourcepub fn read_at_to_vec(
&self,
options: StreamReadOptions,
offset: u64,
length: usize,
) -> Result<Vec<u8>, Status>
pub fn read_at_to_vec( &self, options: StreamReadOptions, offset: u64, length: usize, ) -> Result<Vec<u8>, Status>
Attempts to read length
bytes from the stream starting at offset
. Returns the read bytes
as a Vec
.
See zx_stream_readv_at.
Sourcepub fn writev(
&self,
options: StreamWriteOptions,
iovecs: &[zx_iovec_t],
) -> Result<usize, Status>
pub fn writev( &self, options: StreamWriteOptions, iovecs: &[zx_iovec_t], ) -> Result<usize, Status>
Wraps the
zx_stream_writev
syscall.
Sourcepub fn write(
&self,
options: StreamWriteOptions,
buffer: &[u8],
) -> Result<usize, Status>
pub fn write( &self, options: StreamWriteOptions, buffer: &[u8], ) -> Result<usize, Status>
Writes buffer
to the stream at the stream’s current seek offset. Returns the number of
bytes written.
See zx_stream_writev.
Sourcepub fn writev_at(
&self,
options: StreamWriteOptions,
offset: u64,
iovecs: &[zx_iovec_t],
) -> Result<usize, Status>
pub fn writev_at( &self, options: StreamWriteOptions, offset: u64, iovecs: &[zx_iovec_t], ) -> Result<usize, Status>
Wraps the
zx_stream_writev_at
syscall.
Sourcepub fn write_at(
&self,
options: StreamWriteOptions,
offset: u64,
buffer: &[u8],
) -> Result<usize, Status>
pub fn write_at( &self, options: StreamWriteOptions, offset: u64, buffer: &[u8], ) -> Result<usize, Status>
Writes buffer
to the stream at `offset``. Returns the number of bytes written.
See zx_stream_writev_at.
Trait Implementations§
Source§impl AsHandleRef for Stream
impl AsHandleRef for Stream
Source§fn as_handle_ref(&self) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
object_wait_many
.Source§fn raw_handle(&self) -> zx_handle_t
fn raw_handle(&self) -> zx_handle_t
Source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Source§fn wait_handle(
&self,
signals: Signals,
deadline: MonotonicInstant,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: MonotonicInstant, ) -> Result<Signals, Status>
Source§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
Source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
Source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
Source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
Source§impl HandleBased for Stream
impl HandleBased for Stream
Source§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
Source§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
Source§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
Source§fn into_raw(self) -> zx_handle_t
fn into_raw(self) -> zx_handle_t
Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Source§fn into_handle_based<H: HandleBased>(self) -> H
fn into_handle_based<H: HandleBased>(self) -> H
Source§fn from_handle_based<H: HandleBased>(h: H) -> Self
fn from_handle_based<H: HandleBased>(h: H) -> Self
fn is_invalid_handle(&self) -> bool
Source§impl Ord for Stream
impl Ord for Stream
Source§impl PartialOrd for Stream
impl PartialOrd for Stream
Source§impl Read for Stream
impl Read for Stream
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreSource§impl Seek for Stream
impl Seek for Stream
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len
)Source§impl Write for Stream
impl Write for Stream
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)