Skip to main content

IOPort

Struct IOPort 

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

IO Port for Bridge layer.

Holds the receiving end of input channel and sending end of output channel. Owned by ClientRunner.

Implementations§

Source§

impl IOPort

Source

pub fn new( channel_id: ChannelId, buffer_size: usize, ) -> (Self, IOInputHandle, IOOutputHandle)

Creates a new IOPort with associated handles.

Returns a tuple of:

  • IOPort: For the Bridge layer (ClientRunner)
  • IOInputHandle: For the View layer to send input
  • IOOutputHandle: For the View layer to receive output
§Arguments
  • channel_id - The channel this port belongs to
  • buffer_size - Buffer size for the channels
Source

pub fn with_defaults( channel_id: ChannelId, ) -> (Self, IOInputHandle, IOOutputHandle)

Creates a new IOPort with default buffer size.

Source

pub fn channel_id(&self) -> ChannelId

Returns the channel ID.

Source

pub async fn recv(&mut self) -> Option<IOInput>

Receives input from View layer (async, waits for input).

Returns None if all input handles have been dropped.

Source

pub fn try_recv(&mut self) -> Option<IOInput>

Tries to receive input without blocking.

Returns None if no input is available.

Source

pub async fn send(&self, output: IOOutput) -> Result<(), SendError<IOOutput>>

Sends output to View layer.

§Errors

Returns error if the output handle has been dropped.

Source

pub fn try_send(&self, output: IOOutput) -> Result<(), TrySendError<IOOutput>>

Tries to send output without blocking.

§Errors

Returns error if the channel is full or closed.

Source

pub fn drain_input(&mut self) -> Vec<IOInput>

Drains all available input without blocking.

Useful for batch processing of queued input.

Source

pub fn is_output_closed(&self) -> bool

Returns true if the output channel is closed.

Trait Implementations§

Source§

impl Debug for IOPort

Source§

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

Formats the value using the given formatter. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more