pub type ResultHandle<I, O, E> = Handle<I, Result<O, E>>;Expand description
Handle return value is a Result
Aliased Type§
pub struct ResultHandle<I, O, E> {
pub n: usize,
/* private fields */
}Fields§
§n: usizeImplementations§
Source§impl<I, O, E> ResultHandle<I, O, E>
impl<I, O, E> ResultHandle<I, O, E>
Sourcepub fn and<U, V, EN>(
self,
rhs: ResultHandle<U, V, EN>,
) -> ResultHandle<(I, U), (O, V), Error>
pub fn and<U, V, EN>( self, rhs: ResultHandle<U, V, EN>, ) -> ResultHandle<(I, U), (O, V), Error>
ResultHandle<I, O, E> + ResultHandle<U, V, EN> => ResultHandle<(I, U), (O, V), anyhow::Error>
use tokiactor::*;
use tokio;
use thiserror;
#[derive(Debug, thiserror::Error)]
pub enum Error{}
tokio::runtime::Runtime::new().unwrap().block_on(
async move {
let r = Handle::new(1)
.spawn(move |i: i32| {
Result::<i32, Error>::Ok(i+1)
})
.and(
Handle::new(1).spawn(move |i: i32| {
Result::<i32, Error>::Ok(i*1)
})
).handle((1, 1)).await;
assert_eq!(r.unwrap(), (2, 1));
}
);Sourcepub fn and_then<P, EN>(
self,
rhs: ResultHandle<O, P, EN>,
) -> ResultHandle<I, P, Error>
pub fn and_then<P, EN>( self, rhs: ResultHandle<O, P, EN>, ) -> ResultHandle<I, P, Error>
ResultHandle<I, O, E> | ResultHandle<O, P, EN> => ResultHandle<I, P, anyhow::Error>
use tokiactor::*;
use tokio;
use thiserror;
#[derive(Debug, thiserror::Error)]
pub enum Error{}
tokio::runtime::Runtime::new().unwrap().block_on(
async move {
let r = Handle::new(1)
.spawn(move |i: i32| {
Result::<i32, Error>::Ok(i+1)
})
.and_then(
Handle::new(1).spawn(move |i: i32| {
Result::<i32, Error>::Ok(i*10)
})
).handle(1).await;
assert_eq!(r.unwrap(), 20);
}
);Sourcepub fn map<P>(self, rhs: Handle<O, P>) -> ResultHandle<I, P, E>where
P: Send + 'static,
pub fn map<P>(self, rhs: Handle<O, P>) -> ResultHandle<I, P, E>where
P: Send + 'static,
ResultHandle<I, O, E> | Handle<O, P> => ResultHandle<I, P, E>
use tokiactor::*;
use tokio;
use thiserror;
#[derive(Debug, thiserror::Error)]
pub enum Error{}
tokio::runtime::Runtime::new().unwrap().block_on(
async move {
let r = Handle::new(1)
.spawn(move |i: i32| {
Result::<i32, Error>::Ok(i+1)
})
.map(
Handle::new(1).spawn(move |i: i32| {
i*10
})
).handle(1).await;
assert_eq!(r.unwrap(), 20);
}
);Sourcepub fn ok(self) -> OptionHandle<I, O>
pub fn ok(self) -> OptionHandle<I, O>
ResultHandle<I, O, E> => OptionHandle<I, O>
use tokiactor::*;
use tokio;
use thiserror;
#[derive(Debug, thiserror::Error)]
pub enum Error{}
tokio::runtime::Runtime::new().unwrap().block_on(
async move {
let r = Handle::new(1)
.spawn(move |i: i32| {
Result::<i32, Error>::Ok(i+1)
}).ok().handle(1).await;
assert_eq!(r.unwrap(), 2);
}
);