ump 0.13.0

Micro message passing library for threads/tasks communication.
Documentation
use ump::{channel, Error};

#[test]
fn wait_disappered_on_reply() {
  let (server, client) = channel::<String, String, ()>();

  // Generate a request that will return a wait context.
  let wctx = client.req_async(String::from("hello"));

  // Get the message (and reply context) from server end-point
  let (_msg, rctx) = server.wait().unwrap();

  // nuke the wait context
  drop(wctx);

  // Replying should fail, because wctx has been dropped
  let Err(Error::OriginDisappeared) = rctx.reply(String::from("ahoy")) else {
    panic!("Unexpected error");
  };
}

#[test]
fn wait_disappered_on_fail() {
  let (server, client) = channel::<String, String, ()>();

  // Generate a request that will return a wait context.
  let wctx = client.req_async(String::from("hello"));

  // Get the message (and reply context) from server end-point
  let (_msg, rctx) = server.wait().unwrap();

  // nuke the wait context
  drop(wctx);

  // Failing should fail, because wctx has been dropped
  let Err(Error::OriginDisappeared) = rctx.fail(()) else {
    panic!("Unexpected error");
  };
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :