Expand description
§Overview
When parsing byte streams from a network socket, the same pattern tends to appear:
- Read bytes from the socket into a buffer.
- Check the buffer for complete message. a. If the buffer has a complete message, split it off and process it. b. If the buffer does not have a complete message yet, go to 1.
This crate implements a byte buffer, Buf specifically for this use case.
The crate is organized into three parts:
Structs§
- Buf
- A byte buffer whose contents can be matched with Patterns.
- Byte
Lookup Table - See
oneof - Choice
- See
Pattern::or - Element
Range - See
range() - Eof
- See
end - Not
- See
not - One
- See
one - Prefix
- See
prefix - Repetition
- Exppresses pattern repetition.
- Sequence
- See
Pattern::then
Traits§
- Pattern
- Expresses that the implementing type may be used to match a byte slice.
Functions§
- alpha
- Returns a pattern that will match any ascii letter at the start of the input
- any
- Returns a new pattern that matches as many repetitions as possible of the given
pattern, including 0. - at_
least - Returns a new pattern that matches at least
nrepetitions ofpattern. - at_most
- Returns a new pattern that matches at most
nrepetitions ofpattern. - between
- Returns a new pattern that matches between
loandhirepetitions ofpattern. - count
- Returns a new pattern that matches exactly
nrepetitions ofpattern. - digit
- Returns a pattern that will match any ascii digit at the start of the input
- end
- Returns a pattern that matches the end of the slice.
- hex
- Returns a pattern that will match any hexadecimal character at the start of the input
- noneof
- Inverse of
oneof. - not
- Returns a new pattern that matches only if
patterndoes not match. - one
- Returns a new pattern that always matches the next element in the input if it exists.
- oneof
- Returns a pattern that will match any byte in
bytesat the start of the input - optional
- Returns a new pattern that matches 0 or 1 repetitions of
pattern - prefix
- Returns a new pattern that will match if
sliceis a prefix of the input. - range
- Returns a new pattern that will match an element in the closed interval
[lo, hi] - utf8
- Returns a new pattern that will match the utf8 string slice
sat the start of the input.