pub struct Fifo<R = UnspecifiedFifoElement, W = R>(/* private fields */);Expand description
An object representing a Zircon fifo.
As essentially a subtype of NullableHandle, it can be freely interconverted.
Encodes the element type in the type. Defaults to () for the entry type to allow for untyped
IPC. Use Fifo::cast() to convert an IPC-transferred fifo to one of the specific type required
that will support reads and writes.
Implementations§
Source§impl<R, W> Fifo<R, W>where
R: IntoBytes + FromBytes,
W: IntoBytes + FromBytes,
impl<R, W> Fifo<R, W>where
R: IntoBytes + FromBytes,
W: IntoBytes + FromBytes,
Sourcepub fn create(elem_count: usize) -> Result<(Fifo<R, W>, Fifo<W, R>), Status>
pub fn create(elem_count: usize) -> Result<(Fifo<R, W>, Fifo<W, R>), Status>
Create a pair of fifos and return their endpoints. Writing to one endpoint enqueues an element into the fifo from which the opposing endpoint reads.
Wraps the zx_fifo_create syscall.
Sourcepub fn write(&self, buf: &[W]) -> Result<usize, Status>
pub fn write(&self, buf: &[W]) -> Result<usize, Status>
Attempts to write some number of elements into the fifo. On success, returns the number of elements actually written.
Wraps zx_fifo_write.
Sourcepub fn write_one(&self, elem: &W) -> Result<(), Status>
pub fn write_one(&self, elem: &W) -> Result<(), Status>
Attempts to write a single element into the fifo.
Wraps zx_fifo_write.
Sourcepub unsafe fn write_raw(
&self,
buf: *const W,
count: usize,
) -> Result<usize, Status>
pub unsafe fn write_raw( &self, buf: *const W, count: usize, ) -> Result<usize, Status>
Attempts to write some number of elements into the fifo. On success, returns the number of elements actually written.
Wraps zx_fifo_write.
§Safety
The caller is responsible for ensuring buf is valid to write to for count elements.
Sourcepub fn read(&self, buf: &mut [R]) -> Result<usize, Status>
pub fn read(&self, buf: &mut [R]) -> Result<usize, Status>
Attempts to read some elements out of the fifo. On success, returns the number of elements actually read.
Wraps zx_fifo_read.
Sourcepub fn read_one(&self) -> Result<R, Status>
pub fn read_one(&self) -> Result<R, Status>
Attempts to read a single element out of the fifo.
Wraps zx_fifo_read.
Sourcepub fn read_uninit<'a>(
&self,
bytes: &'a mut [MaybeUninit<R>],
) -> Result<&'a mut [R], Status>
pub fn read_uninit<'a>( &self, bytes: &'a mut [MaybeUninit<R>], ) -> Result<&'a mut [R], Status>
Attempts to read some number of elements out of the fifo. On success, returns a slice of initialized elements.
Wraps zx_fifo_read.
Sourcepub unsafe fn read_raw(
&self,
buf: *mut R,
count: usize,
) -> Result<usize, Status>
pub unsafe fn read_raw( &self, buf: *mut R, count: usize, ) -> Result<usize, Status>
Attempts to read some number of elements out of the fifo. On success, returns the number of elements actually read.
Wraps zx_fifo_read.
§Safety
The caller is responsible for ensuring bytes points to valid (albeit
not necessarily initialized) memory at least len bytes long.
Sourcepub fn into_raw(self) -> u32
pub fn into_raw(self) -> u32
Return the raw handle’s integer value without closing it when self is dropped.
Sourcepub fn duplicate(&self, rights: Rights) -> Result<Fifo<R, W>, Status>
pub fn duplicate(&self, rights: Rights) -> Result<Fifo<R, W>, Status>
Wraps the
zx_handle_duplicate
syscall.
Sourcepub fn replace(self, rights: Rights) -> Result<Fifo<R, W>, Status>
pub fn replace(self, rights: Rights) -> Result<Fifo<R, W>, Status>
Wraps the
zx_handle_replace
syscall.
Sourcepub fn signal(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
pub fn signal( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Wraps the
zx_object_signal
syscall.
Sourcepub fn wait_one(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
pub fn wait_one( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
Wraps the
zx_object_wait_one
syscall.
Trait Implementations§
Source§impl<R, W> AsHandleRef for Fifo<R, W>
impl<R, W> AsHandleRef for Fifo<R, W>
Source§fn as_handle_ref(&self) -> Unowned<'_, NullableHandle>
fn as_handle_ref(&self) -> Unowned<'_, NullableHandle>
object_wait_many.