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 PartialEq for Stream
impl PartialEq for Stream
source§impl PartialOrd for Stream
impl PartialOrd for Stream
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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
)