Enum Pattern

Source
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

Source

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

Source

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

Source

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

Source

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

Source

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
Source

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

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.