pub enum Pattern {
Show 25 variants
Exact(Vec<u8>),
U8,
I8,
LeU16,
LeU32,
LeU64,
BeU16,
BeU32,
BeU64,
LeI16,
LeI32,
LeI64,
BeI16,
BeI32,
BeI64,
LeF32,
LeF64,
BeF32,
BeF64,
CStr,
Array(Box<Pattern>, Expr),
AnyOf(Vec<Pattern>),
AllOf(Vec<Pattern>),
Store(Box<Pattern>, i64),
Map(Box<Pattern>, Box<dyn Fn(&Scope, Data) -> Result<Data, ParseError>>),
}
Variants§
Exact(Vec<u8>)
U8
I8
LeU16
LeU32
LeU64
BeU16
BeU32
BeU64
LeI16
LeI32
LeI64
BeI16
BeI32
BeI64
LeF32
LeF64
BeF32
BeF64
CStr
Array(Box<Pattern>, Expr)
AnyOf(Vec<Pattern>)
AllOf(Vec<Pattern>)
Store(Box<Pattern>, i64)
Map(Box<Pattern>, Box<dyn Fn(&Scope, Data) -> Result<Data, ParseError>>)
Implementations§
Source§impl Pattern
impl Pattern
pub fn map<F: Fn(&Scope, Data) -> Result<Data, ParseError> + 'static>( self, f: F, ) -> Pattern
pub fn mapval<D: Into<Data>>(self, d: D) -> Pattern
pub fn store<K: Into<i64>>(self, key: K) -> Pattern
pub fn parse(&self, bytes: &[u8]) -> Result<Data, ParseError>
Sourcepub fn add<D: Into<Data>>(self, rhs: D) -> Pattern
pub fn add<D: Into<Data>>(self, rhs: D) -> Pattern
convenience method that returns a new Pattern mapped by adding the given value to the resulting value
- numeric types can be added to each other, with two integral types, the result is an intgral value otherwise, you get a Float value
- string types can be added to each other to create a concatenated string
Sourcepub fn label<D: Into<Data>>(self, name: D) -> Pattern
pub fn label<D: Into<Data>>(self, name: D) -> Pattern
if self -> X, this changes this pattern so that it returns [name, X] instead. Primarily for debugging purposes, when you want to see what value comes from what pattern
Sourcepub fn to_map<K: Into<i64> + Debug>(self, keys: Vec<K>) -> Pattern
pub fn to_map<K: Into<i64> + Debug>(self, keys: Vec<K>) -> Pattern
convenience method that accepts a list of keys and returns a Pattern that when parsed will return a map of list of (name, value) pairs, where the names are generated from Debug of the keys and value comes from lookup up the Scope
Auto Trait Implementations§
impl Freeze for Pattern
impl !RefUnwindSafe for Pattern
impl !Send for Pattern
impl !Sync for Pattern
impl Unpin for Pattern
impl !UnwindSafe for Pattern
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
Mutably borrows from an owned value. Read more