[][src]Struct lifeline::request::Request

pub struct Request<Send, Recv> { /* fields omitted */ }

If you need synchronous RPC, you can use this utility

use lifeline::request::Request;

struct Send(usize);
#[derive(Debug, Eq, PartialEq)]
struct Recv(usize);

lifeline::test::block_on(async {
  let (request, mut recv) = Request::send(Send(42));

  // send the request along a channel, and in a service:
  request.reply(|send| async move { Recv(send.0) }).await;

  let resp = recv.await;
  assert_eq!(Ok(Recv(42)), resp);
})

Implementations

impl<Send, Recv> Request<Send, Recv>[src]

pub fn send(send: Send) -> (Self, Receiver<Recv>)[src]

Constructs a pair of Request, and Receiver for the response

pub async fn reply<Fn, Fut>(self, respond: Fn) -> Result<(), Recv> where
    Fn: FnOnce(Send) -> Fut,
    Fut: Future<Output = Recv>, 
[src]

Asynchronously replies to the given request, using the provided closure

Auto Trait Implementations

impl<Send, Recv> !RefUnwindSafe for Request<Send, Recv>[src]

impl<Send, Recv> Send for Request<Send, Recv> where
    Recv: Send,
    Send: Send
[src]

impl<Send, Recv> Sync for Request<Send, Recv> where
    Recv: Send,
    Send: Sync
[src]

impl<Send, Recv> Unpin for Request<Send, Recv> where
    Send: Unpin
[src]

impl<Send, Recv> !UnwindSafe for Request<Send, Recv>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.