use pipecircuit::{Inline, Pipe, PipeSender, ScopedSender, StateMachine, StepInputOf};
struct Bytes;
impl Pipe for Bytes { type In<'a> = &'a mut [u8]; type Out<'a> = usize; }
pipecircuit::pipe_roster! { mod program { client: super::Bytes } }
struct Batch<'batch> { staged: Option<&'batch mut [u8]> }
impl PipeSender<Bytes> for Batch<'_> {
type Outcome<'a> = usize;
fn send<'a>(&mut self, input: <Bytes as Pipe>::In<'a>) -> Self::Outcome<'a> { input.len() }
}
impl<'batch> ScopedSender<'batch, Bytes> for Batch<'batch> {
fn submit(&mut self, input: &'batch mut [u8]) -> usize {
let length = input.len();
self.staged = Some(input);
length
}
}
struct Length;
impl StateMachine for Length {}
impl StepInputOf<Length> for &mut [u8] {
type Outcome = usize;
fn step(self, _: &mut Length) -> usize { self.len() }
}
fn conduct(mut senders: impl program::Dispatch<Inline<Length, Bytes>>) {
let mut local = [7; 2];
let _outcome = senders.submit(program::To::Client(&mut local));
}
fn main() {}