[][src]Enum dbin::Pattern

pub enum Pattern {
    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)

Implementations

impl Pattern[src]

pub fn map<F: Fn(&Scope, Data) -> Result<Data, ParseError> + 'static>(
    self,
    f: F
) -> Pattern
[src]

pub fn mapval<D: Into<Data>>(self, d: D) -> Pattern[src]

pub fn store<K: Into<i64>>(self, key: K) -> Pattern[src]

pub fn parse(&self, bytes: &[u8]) -> Result<Data, ParseError>[src]

pub fn add<D: Into<Data>>(self, rhs: D) -> Pattern[src]

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

pub fn label<D: Into<Data>>(self, name: D) -> Pattern[src]

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

pub fn to_map<K: Into<i64> + Debug>(self, keys: Vec<K>) -> Pattern[src]

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 !RefUnwindSafe for Pattern

impl !Send for Pattern

impl !Sync for Pattern

impl Unpin for Pattern

impl !UnwindSafe for Pattern

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.