mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-16 09:25:04 +01:00
migrate cluelessh-faked to cluelessh-tokio
This commit is contained in:
parent
01d6a861f1
commit
b6d0675976
11 changed files with 513 additions and 137 deletions
|
|
@ -1 +1,33 @@
|
|||
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<ChannelUpdateKind>,
|
||||
ops_send: tokio::sync::mpsc::Sender<ChannelOperation>,
|
||||
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<ChannelUpdateKind> {
|
||||
self.updates_recv
|
||||
.recv()
|
||||
.await
|
||||
.ok_or_eyre("channel has been closed")
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> &ChannelKind {
|
||||
&self.kind
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue