Skip to main content

SearchBodySource

Trait SearchBodySource 

pub trait SearchBodySource: Send + Sync {
    // Required methods
    fn segment_count(&self) -> usize;
    fn piece_count(&self, segment: usize) -> usize;
    fn piece(&self, segment: usize, piece: usize) -> Option<BodyPiece<'_>>;

    // Provided method
    fn location(&self, _segment: usize) -> Option<SearchResult> { ... }
}
Expand description

Prose a catalogue record can be found by, owned by the app.

A body is a sequence of segments (the unit a hit points at: a paragraph, a block, a line) and each segment a sequence of BodyPieces (runs of styled text, say). The source must be immutable: the catalogue indexes it as it is when the record is added.

Required Methods§

fn segment_count(&self) -> usize

fn piece_count(&self, segment: usize) -> usize

fn piece(&self, segment: usize, piece: usize) -> Option<BodyPiece<'_>>

Provided Methods§

fn location(&self, _segment: usize) -> Option<SearchResult>

The hit to report for a match in segment. None reports the record’s own result instead, once.

Implementations on Foreign Types§

§

impl SearchBodySource for String

A single-segment body of plain text.

§

fn segment_count(&self) -> usize

§

fn piece_count(&self, segment: usize) -> usize

§

fn piece(&self, segment: usize, piece: usize) -> Option<BodyPiece<'_>>

§

impl SearchBodySource for Vec<String>

One segment per string, separated by word breaks.

§

fn segment_count(&self) -> usize

§

fn piece_count(&self, segment: usize) -> usize

§

fn piece(&self, segment: usize, piece: usize) -> Option<BodyPiece<'_>>

Implementors§