Async Wrapper


Back to index

Hyperpipe

How to use


  • Construct two pipe endpoints (in some directory)
  • Push data in, pull data out
  • Pull does not block to wait for data
fn main() {
    let pipe_path = Path::new("buffer-dir");

    let mut p1 = HyperPipe::new(pipe_path).unwrap();
    let v1 = vec![1, 2, 3, 4, 5, 6];
    p1.push(v1.clone()).unwrap();

    let mut p2 = HyperPipe::new(pipe_path).unwrap();
    let v2 = p2.pull().unwrap();
    assert_eq!(v1, v2);
}

AsyncHyperPipe


  • Construct a HyperPipe
  • Create a polling future
  • Remember to wake yourself

    pub struct AsyncHyperPipe {
        inner: HyperPipe
    }
    
    impl Future for AsyncHyperPipe {
        type Output = Vec<u8>;
        fn poll(self: Pin<&mut Self>, ctx: &mut Context) -> Poll<Self::Output> {
            todo!()
        }
    }
    

let pipe = AsyncHypePipe::new();
if let Some(data) = pipe.await {
    println("hmmm,,, data: {:?}", data);
}

Back to index