pub struct NoLeft;
impl Left for NoLeft {
fn left_in_blocked(&self) -> bool {
unreachable!()
}
fn set_left_in_blocked(&mut self, _: bool) -> () {}
fn left_lens(&self) -> (usize, usize) {
unreachable!()
}
fn left_set_lens(&mut self, _: usize, _: usize) -> () {
unreachable!()
}
fn left_bufs_mut<'d>(&'d mut self) -> (InBuffer<'d>, &mut [u8]) {
unreachable!()
}
fn is_ready(&self) -> bool {
unreachable!()
}
fn set_ready(&mut self, _: bool) -> bool {
unreachable!()
}
fn left_want_read(&self) -> bool {
unreachable!()
}
fn set_left_want_read(&mut self, _: bool) -> () {
unreachable!()
}
fn left_want_write(&self) -> bool {
unreachable!()
}
fn set_left_want_write(&mut self, _: bool) -> () {
unreachable!()
}
}
pub enum InBuffer<'d> {
Single(&'d mut [u8]),
Double(&'d mut [u8], &'d mut [u8]),
}
pub trait Left {
fn left_in_blocked(&self) -> bool;
fn set_left_in_blocked(&mut self, _: bool) -> ();
fn left_lens(&self) -> (usize, usize);
fn left_set_lens(&mut self, _: usize, _: usize) -> ();
fn left_bufs_mut<'d>(&'d mut self) -> (InBuffer<'d>, &'d mut [u8]);
fn is_ready(&self) -> bool;
fn set_ready(&mut self, _: bool) -> bool;
fn left_want_read(&self) -> bool;
fn set_left_want_read(&mut self, _: bool) -> ();
fn left_want_write(&self) -> bool;
fn set_left_want_write(&mut self, _: bool) -> ();
}
pub struct NoRight;
impl Right for NoRight {
fn right_lens(&self) -> (usize, usize) {
unreachable!()
}
fn buf_right_out(&self) -> &[u8] {
unreachable!()
}
fn wants_right_next_in(&self) -> bool {
unreachable!()
}
fn set_wants_right_next_in(&mut self, _: bool) -> () {
unreachable!()
}
fn all_sent_right_out(&mut self) -> () {
unreachable!()
}
fn add_right_out(&mut self, _: &[u8]) -> () {
unreachable!()
}
fn add_right_in(&mut self, _: &[u8]) -> () {
unreachable!()
}
}
pub trait Right {
fn right_lens(&self) -> (usize, usize);
fn buf_right_out(&self) -> &[u8];
fn wants_right_next_in(&self) -> bool;
fn set_wants_right_next_in(&mut self, _: bool) -> ();
fn all_sent_right_out(&mut self) -> ();
fn add_right_out(&mut self, _: &[u8]) -> ();
fn add_right_in(&mut self, _: &[u8]) -> ();
}
pub trait Portal {
type Position;
fn trade<R: Right, L: Left>(&mut self, _: R, _: L) -> Self::Position;
}
pub trait Orbit {
type Position;
type Error;
fn advance_with<B, L: Left, R: Right>(
&mut self,
_: &mut B,
_: &mut L,
_: &mut R,
) -> Result<Self::Position, Self::Error>;
}
pub trait BluePrint<O: Orbit> {
type Config;
type Error;
fn with_defaults() -> Result<O, Self::Error>;
fn with_configuration(_: Self::Config) -> Result<O, Self::Error>;
}