Skip to main content

Sink

Trait Sink 

Source
pub trait Sink {
    type Error: SinkError;

    // Required method
    fn matched(
        &mut self,
        _searcher: &Searcher,
        _mat: &SinkMatch<'_>,
    ) -> Result<bool, Self::Error>;

    // Provided methods
    fn begin(&mut self, _searcher: &Searcher) -> Result<bool, Self::Error> { ... }
    fn finish(
        &mut self,
        _searcher: &Searcher,
        _: &SinkFinish,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

A trait that defines how results from searchers are handled.

The searcher follows the “push” model: the searcher drives execution and pushes results back to the caller via this trait.

Required Associated Types§

Source

type Error: SinkError

The type of an error that should be reported by a searcher.

Required Methods§

Source

fn matched( &mut self, _searcher: &Searcher, _mat: &SinkMatch<'_>, ) -> Result<bool, Self::Error>

This method is called whenever a match is found.

If this returns true, then searching continues. If this returns false, then searching is stopped immediately and finish is called.

Provided Methods§

Source

fn begin(&mut self, _searcher: &Searcher) -> Result<bool, Self::Error>

This method is called when a search has begun, before any search is executed. By default, this does nothing.

Source

fn finish( &mut self, _searcher: &Searcher, _: &SinkFinish, ) -> Result<(), Self::Error>

This method is called when a search has completed. By default, this does nothing.

Implementations on Foreign Types§

Source§

impl<S: Sink> Sink for &mut S

Source§

type Error = <S as Sink>::Error

Source§

fn matched( &mut self, searcher: &Searcher, mat: &SinkMatch<'_>, ) -> Result<bool, S::Error>

Source§

fn begin(&mut self, searcher: &Searcher) -> Result<bool, S::Error>

Source§

fn finish( &mut self, searcher: &Searcher, sink_finish: &SinkFinish, ) -> Result<(), S::Error>

Implementors§