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
impl IOPort
Sourcepub fn new(
channel_id: ChannelId,
buffer_size: usize,
) -> (Self, IOInputHandle, IOOutputHandle)
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 inputIOOutputHandle: For the View layer to receive output
§Arguments
channel_id- The channel this port belongs tobuffer_size- Buffer size for the channels
Sourcepub fn with_defaults(
channel_id: ChannelId,
) -> (Self, IOInputHandle, IOOutputHandle)
pub fn with_defaults( channel_id: ChannelId, ) -> (Self, IOInputHandle, IOOutputHandle)
Creates a new IOPort with default buffer size.
Sourcepub fn channel_id(&self) -> ChannelId
pub fn channel_id(&self) -> ChannelId
Returns the channel ID.
Sourcepub async fn recv(&mut self) -> Option<IOInput>
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.
Sourcepub fn try_recv(&mut self) -> Option<IOInput>
pub fn try_recv(&mut self) -> Option<IOInput>
Tries to receive input without blocking.
Returns None if no input is available.
Sourcepub fn drain_input(&mut self) -> Vec<IOInput>
pub fn drain_input(&mut self) -> Vec<IOInput>
Drains all available input without blocking.
Useful for batch processing of queued input.
Sourcepub fn is_output_closed(&self) -> bool
pub fn is_output_closed(&self) -> bool
Returns true if the output channel is closed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IOPort
impl RefUnwindSafe for IOPort
impl Send for IOPort
impl Sync for IOPort
impl Unpin for IOPort
impl UnsafeUnpin for IOPort
impl UnwindSafe for IOPort
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more