pub trait Encoding: Sized {
type Index: Sized + 'static;
type IndexShift: Sized;
// Required methods
fn zero_index() -> Self::Index;
fn zero_shift() -> Self::IndexShift;
fn get_index(value: &Self::Index, utf8_index: usize) -> usize;
fn get_shift(value: &Self::IndexShift, utf8_shift: isize) -> isize;
fn calculate_indices<'a>(
content: &str,
match_visitor: impl Iterator<Item = EncodeIndices<'a, Self>>,
);
fn adjust_shift(shift: &mut Self::IndexShift, before: &str, after: &str);
}
Expand description
Specifies how indices are calculated for rule matches
Required Associated Types§
Required Methods§
fn zero_index() -> Self::Index
fn zero_shift() -> Self::IndexShift
fn get_index(value: &Self::Index, utf8_index: usize) -> usize
fn get_shift(value: &Self::IndexShift, utf8_shift: isize) -> isize
Sourcefn calculate_indices<'a>(
content: &str,
match_visitor: impl Iterator<Item = EncodeIndices<'a, Self>>,
)
fn calculate_indices<'a>( content: &str, match_visitor: impl Iterator<Item = EncodeIndices<'a, Self>>, )
A iterator of indices. You are given the UTF-8 indices, and need to calculate the “custom” indices. The UTF-8 indices are guaranteed to be sorted in ascending order by the start index.
Sourcefn adjust_shift(shift: &mut Self::IndexShift, before: &str, after: &str)
fn adjust_shift(shift: &mut Self::IndexShift, before: &str, after: &str)
Calculates the change of an index from replacing before
with after
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.