starina_api::channel

Struct Channel

Source
pub struct Channel { /* private fields */ }
Expand description

An asynchronous, bounded, and bi-directional message-passing mechanism between processes.

Implementations§

Source§

impl Channel

Source

pub fn from_handle(handle: OwnedHandle) -> Channel

Creates a new channel from a handle.

Source

pub fn create() -> Result<(Channel, Channel), FtlError>

Creates a new channel pair, connected to each other.

Source

pub fn handle(&self) -> &OwnedHandle

Returns the handle of the channel.

Source

pub fn split(self) -> (ChannelSender, ChannelReceiver)

Splits the channel into sender/receiver halves.

Currently, it’s no more than Arc<Channel>, but splitting a channel whenever you can is recommended for future compatibility.

Source

pub fn send<M: MessageSerialize>(&self, msg: M) -> Result<(), FtlError>

Sends a message to the channel’s peer. Non-blocking.

§Note

If the peer’s message queue is full, this method will return an error immediately without blocking.

Source

pub fn send_with_buffer<M: MessageSerialize>( &self, buffer: &mut MessageBuffer, msg: M, ) -> Result<(), FtlError>

Sends a message to the channel’s peer using the provided buffer. Non-blocking.

Source

pub fn try_recv<'a, M: MessageDeserialize>( &self, buffer: &'a mut MessageBuffer, ) -> Result<Option<M::Reader<'a>>, RecvError>

Receives a message from the channel’s peer. Non-blocking.

See Self::recv for more details.

Source

pub fn recv<'a, M: MessageDeserialize>( &self, msgbuffer: &'a mut MessageBuffer, ) -> Result<M::Reader<'a>, RecvError>

Receives a message from the channel’s peer using the provided buffer. Blocking.

Kernel writes the received message into the buffer (msgbuffer), this library deserializes the message, and returns a typed message object.

§Example
use starina_api::types::message::MessageBuffer;

let mut msgbuffer = MessageBuffer::new();
let reply = ch.recv::<PingReply>(&mut msgbuffer);
debug!("reply = {}", reply.value);
Source

pub fn call<'a, M>( &self, msgbuffer: &'a mut MessageBuffer, request: M, ) -> Result<<M::Reply as MessageDeserialize>::Reader<'a>, CallError>
where M: MessageCallable,

Send a message and then receive a reply. Blocking.

See Self::recv for more details on buffer.

Trait Implementations§

Source§

impl Debug for Channel

Source§

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

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

impl From<Channel> for (ChannelSender, ChannelReceiver)

Source§

fn from(channel: Channel) -> (ChannelSender, ChannelReceiver)

Converts to this type from the input type.
Source§

impl From<Channel> for HandleField

Source§

fn from(channel: Channel) -> HandleField

Converts to this type from the input type.
Source§

impl From<Channel> for MovedHandle

Source§

fn from(channel: Channel) -> MovedHandle

Converts to this type from the input type.
Source§

impl From<MovedHandle> for Channel

Source§

fn from(moved_handle: MovedHandle) -> Channel

Converts to this type from the input type.

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.