Skip to main content

ReferenceExtractor

Struct ReferenceExtractor 

Source
pub struct ReferenceExtractor { /* private fields */ }
Expand description

Finds parseable Bible passages embedded in arbitrary prose.

Results are returned from left to right, never overlap, and prefer the longest successful parse beginning at a given byte offset.

Implementations§

Source§

impl ReferenceExtractor

Source

pub fn new() -> ReferenceExtractor

Construct an extractor with a default PassageParser.

Source

pub fn builder() -> ReferenceExtractorBuilder

Start configuring an extractor.

Source

pub fn from_parser(parser: PassageParser) -> ReferenceExtractor

Construct an extractor around an existing parser.

Source

pub fn with_options( parser: PassageParser, include_bare_books: bool, max_lookbehind: usize, max_lookahead: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>

Construct an extractor from validated configuration values.

Source

pub const fn parser(&self) -> &PassageParser

Return the parser used to validate candidate spans.

Source

pub const fn include_bare_books(&self) -> bool

Return whether whole-book passages are included.

Source

pub const fn max_lookbehind(&self) -> usize

Return the normalized-byte search distance before numeric anchors.

Source

pub const fn max_lookahead(&self) -> usize

Return the normalized-byte search distance after numeric anchors.

Source

pub fn with_include_bare_books(self, include: bool) -> ReferenceExtractor

Return a copy configured to include or exclude whole-book passages.

Source

pub fn with_max_lookbehind( self, value: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>

Return a copy with a validated lookbehind window.

Source

pub fn with_max_lookahead( self, value: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>

Return a copy with a validated lookahead window.

Source

pub fn extract(&self, source: &str) -> Vec<PassageMatch>

Find deterministic, non-overlapping passages in source.

Source

pub fn extract_with_language( &self, source: &str, language: Language, ) -> Vec<PassageMatch>

Find passages while resolving book names in one explicit language.

Source

pub fn find_all(&self, source: &str) -> Vec<PassageMatch>

Alias for Self::extract.

Source

pub fn find_all_with_language( &self, source: &str, language: Language, ) -> Vec<PassageMatch>

Language-specific alias for Self::extract_with_language.

Source

pub fn replace_matches<F, R>(&self, source: &str, replacement: F) -> String
where F: FnMut(&PassageMatch) -> R, R: Display,

Replace all matches in one pass without scanning replacement text.

Source

pub fn replace_matches_with_language<F, R>( &self, source: &str, language: Language, replacement: F, ) -> String
where F: FnMut(&PassageMatch) -> R, R: Display,

Replace language-specific matches in one pass.

Source

pub fn linkify<F, R>(&self, source: &str, link_builder: F) -> String
where F: FnMut(&PassageMatch) -> R, R: Display,

Linkify matches with a caller-provided renderer.

Source

pub fn linkify_with_language<F, R>( &self, source: &str, language: Language, link_builder: F, ) -> String
where F: FnMut(&PassageMatch) -> R, R: Display,

Linkify matches resolved with one explicit language.

Source

pub fn linkify_markdown<F, U>(&self, source: &str, uri_builder: F) -> String
where F: FnMut(&PassageMatch) -> U, U: Display,

Linkify matches as Markdown using each exact source slice as its label.

Source

pub fn linkify_markdown_with_language<F, U>( &self, source: &str, language: Language, uri_builder: F, ) -> String
where F: FnMut(&PassageMatch) -> U, U: Display,

Linkify explicitly localized matches as Markdown using exact source labels.

Source

pub fn linkify_markdown_with_label<F, U, L>( &self, source: &str, uri_builder: F, label_builder: L, ) -> String
where F: FnMut(&PassageMatch) -> U, U: Display, L: FnMut(&PassageMatch) -> String,

Linkify matches as Markdown with caller-provided labels and destinations.

Source

pub fn linkify_markdown_with_label_and_language<F, U, L>( &self, source: &str, language: Language, uri_builder: F, label_builder: L, ) -> String
where F: FnMut(&PassageMatch) -> U, U: Display, L: FnMut(&PassageMatch) -> String,

Linkify explicitly localized matches with custom Markdown labels.

Source

pub fn markdown_linkify<F, U>(&self, source: &str, uri_builder: F) -> String
where F: FnMut(&PassageMatch) -> U, U: Display,

Source

pub fn markdown_linkify_with_language<F, U>( &self, source: &str, language: Language, uri_builder: F, ) -> String
where F: FnMut(&PassageMatch) -> U, U: Display,

Language-specific alias for Self::linkify_markdown_with_language.

Trait Implementations§

Source§

impl Clone for ReferenceExtractor

Source§

fn clone(&self) -> ReferenceExtractor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReferenceExtractor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ReferenceExtractor

Source§

fn default() -> ReferenceExtractor

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.