Skip to main content

fdf_channel_read

Struct fdf_channel_read 

Source
#[repr(C)]
pub struct fdf_channel_read { pub state: async_state_t, pub handler: fdf_channel_read_handler_t, pub channel: fdf_handle_t, pub options: u32, }
Expand description

A bi-directional in-process message transport capable of sending arena-managed raw data bytes as well as handles from one side to the other.

§Thread safety

Most operations on channel objects are thread-safe, except for |fdf_channel_cancel_wait|.

§Example

// Read handler for asynchronous channel reads. void read_handler(fdf_dispatcher_t* dispatcher, fdf_channel_read_t* read, zx_status_t status);

// Sends a request to the peer of |channel| and asynchronously waits for a response. void send_request(fdf_handle_t channel, fdf_dispatcher_t* dispatcher dispatcher) { fdf_arena_t* arena; zx_status_t status = fdf_arena_create(0, ‘exam’, 0, &arena);

void* data = fdf_arena_allocate(arena, 0x1000);
// Set the data to transfer
...

// Write the request to the channel.
status = fdf_channel_write(ch0, 0, arena, data, 0x1000, NULL, 0);

// Asynchronously wait for a response.
fdf_channel_read_t* channel_read = calloc(1, sizeof(fdf_channel_read_t));
channel_read->handler = read_handler;
channel_read->channel = ch0;
status = fdf_channel_wait_async(dispatcher, channel_read, 0);

// We are done with the arena.
fdf_arena_drop_ref(arena);

}

void read_handler(fdf_dispatcher_t* dispatcher, fdf_channel_read_t* read, zx_status_t status) { fdf_arena_t* arena; void* data data; uint32_t data_size; zx_handle_t* handles; uint32_t num_handles; zx_status_t status = fdf_channel_read(read->channel, 0, &arena, &data, &data_size, &handles, &num_handles); // Process the read data. …

// Read provides you with an arena which you may reuse for other requests.
// You are in charge of destroying the reference.
fdf_arena_drop_ref(arena);
free(read);

}

Fields§

§state: async_state_t§handler: fdf_channel_read_handler_t§channel: fdf_handle_t§options: u32

Trait Implementations§

Source§

impl Debug for fdf_channel_read

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for fdf_channel_read

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.