graph_api_lib/walker/steps/
empty.rs1use crate::ElementId;
2use crate::graph::Graph;
3use crate::walker::{VertexWalker, Walker};
4use std::marker::PhantomData;
5
6pub struct Empty<Graph, Context> {
21 _phantom: PhantomData<Graph>,
22 context: Context,
23}
24
25impl<Graph> Default for Empty<Graph, ()> {
26 fn default() -> Self {
27 Self {
28 _phantom: PhantomData,
29 context: (),
30 }
31 }
32}
33
34impl<Graph, Context> Empty<Graph, Context> {
35 pub(crate) fn with_context(context: Context) -> Self {
36 Self {
37 _phantom: PhantomData,
38 context,
39 }
40 }
41}
42
43impl<'graph, Graph: crate::Graph, Context> Walker<'graph> for Empty<Graph, Context>
44where
45 Context: Clone + 'static,
46{
47 type Graph = Graph;
48 type Context = Context;
49
50 fn next_element(&mut self, _graph: &'graph Self::Graph) -> Option<ElementId<Self::Graph>> {
51 None
52 }
53
54 fn ctx(&self) -> &Self::Context {
55 &self.context
56 }
57
58 fn ctx_mut(&mut self) -> &mut Self::Context {
59 &mut self.context
60 }
61}
62
63impl<'graph, G: Graph, Context> VertexWalker<'graph> for Empty<G, Context>
64where
65 Context: Clone + 'static,
66{
67 fn next(&mut self, _graph: &'graph Self::Graph) -> Option<<Self::Graph as Graph>::VertexId> {
68 None
69 }
70}