[][src]Enum dbin::Spec

pub enum Spec {
    Int {
        little_endian: bool,
        signed: bool,
        nbytes: usize,
        expected: Option<i64>,
    },
    Array {
        size: Expr,
        member: Box<Spec>,
    },
    Enum(Vec<(Key, Spec)>),
    Struct(Vec<Spec>),
    Scope {
        args: Vec<(Key, Expr)>,
        body: Box<Spec>,
    },
    Store(KeyBox<Spec>),
}

Dead simple, quick and dirty binary data parser combinator

Variants

Int

Fields of Int

little_endian: boolsigned: boolnbytes: usizeexpected: Option<i64>

Expected value for the parse to succeed (e.g. for magic)

Array

Fields of Array

size: Exprmember: Box<Spec>
Enum(Vec<(Key, Spec)>)
Struct(Vec<Spec>)
Scope

Fields of Scope

args: Vec<(Key, Expr)>body: Box<Spec>
Store(KeyBox<Spec>)

Implementations

impl Spec[src]

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

impl Spec[src]

pub fn args() -> SpecArgs[src]

pub fn pairs() -> SpecPairs[src]

pub fn le_magic_u64(value: u64) -> Spec[src]

pub fn be_magic_u64(value: u64) -> Spec[src]

pub fn magic_u64(little_endian: bool, value: u64) -> Spec[src]

pub fn magic(little_endian: bool, nbytes: usize, value: i64) -> Spec[src]

pub fn le_magic(nbytes: usize, value: i64) -> Spec[src]

pub fn be_magic(nbytes: usize, value: i64) -> Spec[src]

pub fn int(little_endian: bool, signed: bool, nbytes: usize) -> Spec[src]

pub fn le_int(signed: bool, nbytes: usize) -> Spec[src]

pub fn be_int(signed: bool, nbytes: usize) -> Spec[src]

pub fn le_sint(nbytes: usize) -> Spec[src]

pub fn le_uint(nbytes: usize) -> Spec[src]

pub fn be_sint(nbytes: usize) -> Spec[src]

pub fn be_uint(nbytes: usize) -> Spec[src]

pub fn arr<E: Into<Expr>>(p: Spec, e: E) -> Spec[src]

pub fn en<K: Into<Key>>(vec: Vec<(K, Spec)>) -> Spec[src]

Enum -- will try each of the alternatives in order, and return the first successful variant The variant will be tagged in the resulting Data (as a Data::Enum)

pub fn st(vec: Vec<Spec>) -> Spec[src]

Struct -- all alternatives must succeed in order

pub fn scope<K: Into<Key>, E: Into<Expr>>(args: Vec<(K, E)>, p: Spec) -> Spec[src]

pub fn store<K: Into<Key>>(key: K, p: Spec) -> Spec[src]

Stores the result of a parse into a key for later use (e.g. as length of an array)

Auto Trait Implementations

impl !RefUnwindSafe for Spec

impl !Send for Spec

impl !Sync for Spec

impl Unpin for Spec

impl UnwindSafe for Spec

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.