pub mod client; pub mod server; use cluelessh_connection::{ChannelKind, ChannelNumber, ChannelOperation, ChannelOperationKind}; use cluelessh_protocol::ChannelUpdateKind; use eyre::{OptionExt, Result}; pub struct Channel { number: ChannelNumber, updates_recv: tokio::sync::mpsc::Receiver, ops_send: tokio::sync::mpsc::Sender, kind: ChannelKind, } impl Channel { pub async fn send(&mut self, op: ChannelOperationKind) -> Result<()> { self.ops_send .send(self.number.construct_op(op)) .await .map_err(Into::into) } pub async fn next_update(&mut self) -> Result { self.updates_recv .recv() .await .ok_or_eyre("channel has been closed") } pub fn kind(&self) -> &ChannelKind { &self.kind } }