use std::pin::Pin;
use futures::{Sink, Stream};
#[derive(Debug, Clone)]
pub struct TransportError(pub String);
impl core::fmt::Display for TransportError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(&self.0)
}
}
impl std::error::Error for TransportError {}
pub type ByteStream = Pin<Box<dyn Stream<Item = Vec<u8>>>>;
pub type ByteSink = Pin<Box<dyn Sink<Vec<u8>, Error = TransportError>>>;
pub struct Transport {
pub reader: ByteStream,
pub writer: ByteSink,
}
impl Transport {
pub fn new(reader: ByteStream, writer: ByteSink) -> Self {
Self { reader, writer }
}
}