pub struct ByteClass<T: AsRef<[u8]>, S: StateID = usize>(/* private fields */);
Expand description
A sparse DFA that shrinks its alphabet.
Alphabet shrinking is achieved by using a set of equivalence classes instead of using all possible byte values. Any two bytes belong to the same equivalence class if and only if they can be used interchangeably anywhere in the DFA while never discriminating between a match and a non-match.
Unlike dense DFAs, sparse DFAs do not tend to benefit nearly as much from using byte classes. In some cases, using byte classes can even marginally increase the size of a sparse DFA’s transition table. The reason for this is that a sparse DFA already compacts each state’s transitions separate from whether byte classes are used.
Generally, it isn’t necessary to use this type directly, since a
SparseDFA
can be used for searching directly. One possible reason why
one might want to use this type directly is if you are implementing your
own search routines by walking a DFA’s transitions directly. In that case,
you’ll want to use this type (or any of the other DFA variant types)
directly, since they implement next_state
more efficiently.
Trait Implementations§
Source§impl<T: AsRef<[u8]>, S: StateID> DFA for ByteClass<T, S>
impl<T: AsRef<[u8]>, S: StateID> DFA for ByteClass<T, S>
Source§fn start_state(&self) -> S
fn start_state(&self) -> S
Source§fn is_match_state(&self, id: S) -> bool
fn is_match_state(&self, id: S) -> bool
Source§fn is_dead_state(&self, id: S) -> bool
fn is_dead_state(&self, id: S) -> bool
Source§fn is_match_or_dead_state(&self, id: S) -> bool
fn is_match_or_dead_state(&self, id: S) -> bool
is_match_state(id)
or is_dead_state(id)
must return true. Read moreSource§fn is_anchored(&self) -> bool
fn is_anchored(&self) -> bool
Source§fn next_state(&self, current: S, input: u8) -> S
fn next_state(&self, current: S, input: u8) -> S
Source§unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S
unsafe fn next_state_unchecked(&self, current: S, input: u8) -> S
next_state
, but its implementation may look up the next state
without memory safety checks such as bounds checks. As such, callers
must ensure that the given identifier corresponds to a valid DFA
state. Implementors must, in turn, ensure that this routine is safe
for all valid state identifiers and for all possible u8
values.Source§fn is_match(&self, bytes: &[u8]) -> bool
fn is_match(&self, bytes: &[u8]) -> bool
Source§fn shortest_match(&self, bytes: &[u8]) -> Option<usize>
fn shortest_match(&self, bytes: &[u8]) -> Option<usize>
Source§fn find(&self, bytes: &[u8]) -> Option<usize>
fn find(&self, bytes: &[u8]) -> Option<usize>
None
is returned. Read moreSource§fn rfind(&self, bytes: &[u8]) -> Option<usize>
fn rfind(&self, bytes: &[u8]) -> Option<usize>
None
is returned. In other words, this has the same
match semantics as find
, but in reverse. Read moreSource§fn is_match_at(&self, bytes: &[u8], start: usize) -> bool
fn is_match_at(&self, bytes: &[u8], start: usize) -> bool
is_match
, but starts the search at the given
offset. Read moreSource§fn shortest_match_at(&self, bytes: &[u8], start: usize) -> Option<usize>
fn shortest_match_at(&self, bytes: &[u8], start: usize) -> Option<usize>
shortest_match
, but starts the search at the
given offset. Read moreAuto Trait Implementations§
impl<T, S> Freeze for ByteClass<T, S>
impl<T, S> RefUnwindSafe for ByteClass<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for ByteClass<T, S>
impl<T, S> Sync for ByteClass<T, S>
impl<T, S> Unpin for ByteClass<T, S>
impl<T, S> UnwindSafe for ByteClass<T, S>where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)