1pub mod bfs;
2pub mod dfs;
3
4pub use bfs::Bfs;
5pub use dfs::Dfs;
6
7use async_trait::async_trait;
8use futures::stream::{FuturesOrdered, Stream};
9use futures::Future;
10use std::hash::Hash;
11use std::pin::Pin;
12use std::sync::Arc;
13
14type Stack<N, E> = Vec<(usize, NodeStream<N, E>)>;
15
16type NewNodesFut<N, E> =
17 Pin<Box<dyn Future<Output = (usize, Result<NodeStream<N, E>, E>)> + Unpin + Send + 'static>>;
18
19type StreamQueue<N, E> = FuturesOrdered<NewNodesFut<N, E>>;
20
21pub type NodeStream<N, E> = Pin<Box<dyn Stream<Item = Result<N, E>> + Unpin + Send>>;
26
27#[async_trait]
28pub trait Node
33where
34 Self: Sized + Hash + Eq + std::fmt::Debug,
35{
36 type Error: std::fmt::Debug;
38
39 async fn children(
48 self: Arc<Self>,
49 depth: usize,
50 ) -> Result<NodeStream<Self, Self::Error>, Self::Error>;
51}