Struct fidl::handle::fuchsia_handles::Fifo
source · pub struct Fifo<R = UnspecifiedFifoElement, W = R>(/* private fields */);
Expand description
An object representing a Zircon fifo.
As essentially a subtype of Handle
, 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(
&self,
bytes: &mut [MaybeUninit<R>],
) -> Result<&mut [R], Status>
pub fn read_uninit( &self, bytes: &mut [MaybeUninit<R>], ) -> Result<&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.
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<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
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: Instant<MonotonicTimeline>,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> 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<R, W> From<Fifo> for Fifo<R, W>where
R: FromBytes + IntoBytes,
W: FromBytes + IntoBytes,
impl<R, W> From<Fifo> for Fifo<R, W>where
R: FromBytes + IntoBytes,
W: FromBytes + IntoBytes,
source§impl<R, W> HandleBased for Fifo<R, W>
impl<R, W> HandleBased for Fifo<R, W>
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 from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
source§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
source§fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn is_invalid_handle(&self) -> bool
source§impl<R, W> Ord for Fifo<R, W>
impl<R, W> Ord for Fifo<R, W>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<R, W> PartialEq for Fifo<R, W>
impl<R, W> PartialEq for Fifo<R, W>
source§impl<R, W> PartialOrd for Fifo<R, W>
impl<R, W> PartialOrd for Fifo<R, W>
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 more