Struct Config

pub struct Config { /* private fields */ }

The configuration for a packed multiple pattern searcher.

The configuration is currently limited only to being able to select the match semantics (leftmost-first or leftmost-longest) of a searcher. In the future, more knobs may be made available.

A configuration produces a packed::Builder, which in turn can be used to construct a packed::Searcher for searching.

Example

This example shows how to use leftmost-longest semantics instead of the default (leftmost-first).

use aho_corasick::{packed::{Config, MatchKind}, PatternID};

# fn example() -> Option<()> {
let searcher = Config::new()
    .match_kind(MatchKind::LeftmostLongest)
    .builder()
    .add("foo")
    .add("foobar")
    .build()?;
let matches: Vec<PatternID> = searcher
    .find_iter("foobar")
    .map(|mat| mat.pattern())
    .collect();
assert_eq!(vec![PatternID::must(1)], matches);
# Some(()) }
# if cfg!(all(feature = "std", any(
#     target_arch = "x86_64", target_arch = "aarch64",
# ))) {
#     example().unwrap()
# } else {
#     assert!(example().is_none());
# }

Implementations

impl Config

fn new() -> Config

Create a new default configuration. A default configuration uses leftmost-first match semantics.

fn builder(&self) -> Builder

Create a packed builder from this configuration. The builder can be used to accumulate patterns and create a Searcher from them.

fn match_kind(&mut self, kind: MatchKind) -> &mut Config

Set the match semantics for this configuration.

fn heuristic_pattern_limits(&mut self, yes: bool) -> &mut Config

Request that heuristic limitations on the number of patterns be employed. This useful to disable for benchmarking where one wants to explore how Teddy performs on large number of patterns even if the heuristics would otherwise refuse construction.

This is enabled by default.

Trait Implementations

impl Clone for Config

fn clone(&self) -> Self

impl Debug for Config

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

impl Default for Config

fn default() -> Config

Auto Trait Implementations

impl Freeze for Config

impl RefUnwindSafe for Config

impl Send for Config

impl Sync for Config

impl Unpin for Config

impl UnsafeUnpin for Config

impl UnwindSafe for Config

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Config

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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