1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#[cfg(any(test, feature = "experimental"))]
use std::ops::ControlFlow;
use futures::future::BoxFuture;
pub trait Collapse<A, Wrapped> {
fn collapse_layers<F: FnMut(Wrapped) -> A>(self, collapse_layer: F) -> A;
}
pub trait Expand<A, Wrapped> {
fn expand_layers<F: Fn(A) -> Wrapped>(a: A, expand_layer: F) -> Self;
}
#[cfg(any(test, feature = "experimental"))]
pub trait ExpandCF<Seed, Break, Wrapped> {
fn expand_layers_cf<F: Fn(Seed) -> ControlFlow<Break, Wrapped>>(
a: Seed,
expand_layer: F,
) -> ControlFlow<Break, Self>
where
Self: Sized;
}
pub trait ExpandAsync<A, Wrapped> {
fn expand_layers_async<
'a,
E: Send + 'a,
F: Fn(A) -> BoxFuture<'a, Result<Wrapped, E>> + Send + Sync + 'a,
>(
a: A,
expand_layer: F,
) -> BoxFuture<'a, Result<Self, E>>
where
Self: Sized,
A: Send + 'a;
}