Struct regex_automata::util::start::StartByteMap
source · pub(crate) struct StartByteMap {
map: [Start; 256],
}
Expand description
A map from every possible byte value to its corresponding starting configuration.
This map is used in order to lookup the start configuration for a particular position in a haystack. This start configuration is then used in combination with things like the anchored mode and pattern ID to fully determine the start state.
Generally speaking, this map is only used for fully compiled DFAs and lazy DFAs. For NFAs (including the one-pass DFA), the start state is generally selected by virtue of traversing the NFA state graph. DFAs do the same thing, but at build time and not search time. (Well, technically the lazy DFA does it at search time, but it does enough work to cache the full result of the epsilon closure that the NFA engines tend to need to do.)
Fields§
§map: [Start; 256]
Implementations§
source§impl StartByteMap
impl StartByteMap
sourcepub(crate) fn new(lookm: &LookMatcher) -> StartByteMap
pub(crate) fn new(lookm: &LookMatcher) -> StartByteMap
Create a new map from byte values to their corresponding starting configurations. The map is determined, in part, by how look-around assertions are matched via the matcher given.
sourcepub(crate) fn get(&self, byte: u8) -> Start
pub(crate) fn get(&self, byte: u8) -> Start
Return the starting configuration for the given look-behind byte.
If no look-behind exists, callers should use Start::Text
.
sourcepub(crate) fn from_bytes(
slice: &[u8],
) -> Result<(StartByteMap, usize), DeserializeError>
pub(crate) fn from_bytes( slice: &[u8], ) -> Result<(StartByteMap, usize), DeserializeError>
Deserializes a byte class map from the given slice. If the slice is of insufficient length or otherwise contains an impossible mapping, then an error is returned. Upon success, the number of bytes read along with the map are returned. The number of bytes read is always a multiple of 8.
sourcepub(crate) fn write_to(&self, dst: &mut [u8]) -> Result<usize, SerializeError>
pub(crate) fn write_to(&self, dst: &mut [u8]) -> Result<usize, SerializeError>
Writes this map to the given byte buffer. if the given buffer is too small, then an error is returned. Upon success, the total number of bytes written is returned. The number of bytes written is guaranteed to be a multiple of 8.
sourcepub(crate) fn write_to_len(&self) -> usize
pub(crate) fn write_to_len(&self) -> usize
Returns the total number of bytes written by write_to
.
Trait Implementations§
source§impl Clone for StartByteMap
impl Clone for StartByteMap
source§fn clone(&self) -> StartByteMap
fn clone(&self) -> StartByteMap
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more