pub struct BMByte { /* private fields */ }
Expand description

Using Boyer-Moore-MagicLen to search byte sub-sequences in any byte sequence, including self-synchronizing string encoding data such as UTF-8.

Implementations§

source§

impl BMByte

source

pub fn from<T: BMByteSearchable>(pattern: T) -> Option<BMByte>

Create a BMByte instance from a pattern (the needle).

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();
source§

impl BMByte

source

pub fn find_full_all_in<T: BMByteSearchable>(&self, text: T) -> Vec<usize>

Find and return the positions of all matched sub-sequences in any text (the haystack).

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![1, 4, 7], bmb.find_full_all_in("coocoocoocoo"));
source

pub fn find_full_in<T: BMByteSearchable>( &self, text: T, limit: usize ) -> Vec<usize>

Find and return the positions of matched sub-sequences in any text (the haystack). If the limit is set to 0, all sub-sequences will be found.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![1, 4], bmb.find_full_in("coocoocoocoo", 2));
source§

impl BMByte

source

pub fn rfind_full_all_in<T: BMByteSearchable>(&self, text: T) -> Vec<usize>

Find and return the positions of all matched sub-sequences in any text (the haystack) from its tail to its head.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![7, 4, 1], bmb.rfind_full_all_in("coocoocoocoo"));
source

pub fn rfind_full_in<T: BMByteSearchable>( &self, text: T, limit: usize ) -> Vec<usize>

Find and return the positions of matched sub-sequences in any text (the haystack) from its tail to its head. If the limit is set to 0, all sub-sequences will be found.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![7, 4], bmb.rfind_full_in("coocoocoocoo", 2));
source§

impl BMByte

source

pub fn find_all_in<T: BMByteSearchable>(&self, text: T) -> Vec<usize>

Find and return the positions of all matched sub-sequences in any text (the haystack) but not including the overlap.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![1, 7], bmb.find_all_in("coocoocoocoo"));
source

pub fn find_first_in<T: BMByteSearchable>(&self, text: T) -> Option<usize>

Find and return the position of the first matched sub-sequence in any text (the haystack).

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(Some(1), bmb.find_first_in("coocoocoocoo"));
source

pub fn find_in<T: BMByteSearchable>(&self, text: T, limit: usize) -> Vec<usize>

Find and return the positions of matched sub-sequences in any text (the haystack) but not including the overlap. If the limit is set to 0, all sub-sequences will be found.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![1], bmb.find_in("coocoocoocoo", 1));
source§

impl BMByte

source

pub fn rfind_all_in<T: BMByteSearchable>(&self, text: T) -> Vec<usize>

Find and return the positions of all matched sub-sequences in any text (the haystack) but not including the overlap from its tail to its head.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![7, 1], bmb.rfind_all_in("coocoocoocoo"));
source

pub fn rfind_first_in<T: BMByteSearchable>(&self, text: T) -> Option<usize>

Find and return the position of the first matched sub-sequence in any text (the haystack) from its tail to its head.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(Some(7), bmb.rfind_first_in("coocoocoocoo"));
source

pub fn rfind_in<T: BMByteSearchable>(&self, text: T, limit: usize) -> Vec<usize>

Find and return the positions of matched sub-sequences in any text (the haystack) but not including the overlap from its tail to its head. If the limit is set to 0, all sub-sequences will be found.

use boyer_moore_magiclen::BMByte;

let bmb = BMByte::from("oocoo").unwrap();

assert_eq!(vec![7], bmb.rfind_in("coocoocoocoo", 1));

Trait Implementations§

source§

impl Debug for BMByte

source§

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

Formats the value using the given formatter. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.