pub struct SessionChannel { /* private fields */ }Expand description
A typed session channel enforcing a protocol.
Implementations§
Source§impl SessionChannel
impl SessionChannel
Sourcepub fn new(protocol: Vec<SessionAction>) -> Self
pub fn new(protocol: Vec<SessionAction>) -> Self
Create a channel with the given protocol.
Sourcepub fn send(&mut self, msg: impl Into<String>) -> Result<(), String>
pub fn send(&mut self, msg: impl Into<String>) -> Result<(), String>
Attempt to perform a send action.
Returns Ok(()) if the protocol expects a send at this point.
Sourcepub fn recv(&mut self) -> Result<Option<String>, String>
pub fn recv(&mut self) -> Result<Option<String>, String>
Attempt to perform a receive action.
Returns the next message if the protocol expects a receive.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the protocol has been fully followed.
Sourcepub fn remaining_steps(&self) -> usize
pub fn remaining_steps(&self) -> usize
Number of steps remaining in the protocol.
Auto Trait Implementations§
impl Freeze for SessionChannel
impl RefUnwindSafe for SessionChannel
impl Send for SessionChannel
impl Sync for SessionChannel
impl Unpin for SessionChannel
impl UnsafeUnpin for SessionChannel
impl UnwindSafe for SessionChannel
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