pub trait MapReducer {
type Label: ToOwned + ?Sized;
type Error;
// Required methods
fn map(
&mut self,
node: NodeId,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>;
fn reduce<'a, I: Iterator<Item = &'a Self::Label>>(
&mut self,
first_label: <Self::Label as ToOwned>::Owned,
other_labels: I,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>
where Self::Label: 'a;
// Provided methods
fn map_reduce(
&mut self,
node: NodeId,
successors_label: <Self::Label as ToOwned>::Owned,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error> { ... }
fn on_node_traversed(
&mut self,
_node: NodeId,
_label: Option<&Self::Label>,
) -> Result<(), Self::Error> { ... }
}Expand description
Callbacks for MapReduce
Required Associated Types§
Required Methods§
Sourcefn map(
&mut self,
node: NodeId,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>
fn map( &mut self, node: NodeId, ) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>
Returns the label to assign to the given node, independently of its successors, if any
Sourcefn reduce<'a, I: Iterator<Item = &'a Self::Label>>(
&mut self,
first_label: <Self::Label as ToOwned>::Owned,
other_labels: I,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>where
Self::Label: 'a,
fn reduce<'a, I: Iterator<Item = &'a Self::Label>>(
&mut self,
first_label: <Self::Label as ToOwned>::Owned,
other_labels: I,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>where
Self::Label: 'a,
Given the labels of the children of a node, merge them into a single label.
Not guaranteed to be called for every node.
Provided Methods§
Sourcefn map_reduce(
&mut self,
node: NodeId,
successors_label: <Self::Label as ToOwned>::Owned,
) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>
fn map_reduce( &mut self, node: NodeId, successors_label: <Self::Label as ToOwned>::Owned, ) -> Result<Option<<Self::Label as ToOwned>::Owned>, Self::Error>
Special-case of Self::reduce for merging a node’s label with its successors’ label
Defaults to calling Self::map then Self::reduce.
Specialized implementations must have an equivalent implementation (which may be
optimized), as there is no guarantee which is called by MapReduce.
Not guaranteed to be called for every node.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.