SpecCombinator

Trait SpecCombinator 

Source
pub trait SpecCombinator {
    type Type;

    // Required methods
    spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>;
    spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>;

    // Provided methods
    open spec fn wf(&self, v: Self::Type) -> bool { ... }
    fn requires(&self) -> bool { ... }
}
Expand description

Specification for parser and serializer Combinators. All Vest combinators must implement this trait.

Required Associated Types§

Source

type Type

The view of [Combinator::Result].

Required Methods§

Source

spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>

The specification of Combinator::parse.

Source

spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>

The specification of Combinator::serialize.

Provided Methods§

Source

open spec fn wf(&self, v: Self::Type) -> bool

{ true }

Well-formedness of the format [Self::type] (e.g., refinements on the type).

Source

open spec fn requires(&self) -> bool

{ true }

Pre-conditions for parsing and serialization.

§Examples

Implementations on Foreign Types§

Source§

impl<C: SpecCombinator> SpecCombinator for &C

Source§

open spec fn wf(&self, v: Self::Type) -> bool

{ (*self).wf(v) }
Source§

open spec fn requires(&self) -> bool

{ (*self).requires() }
Source§

open spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>

{ (*self).spec_parse(s) }
Source§

open spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>

{ (*self).spec_serialize(v) }
Source§

type Type = <C as SpecCombinator>::Type

Source§

impl<C: SpecCombinator> SpecCombinator for Box<C>

Source§

open spec fn wf(&self, v: Self::Type) -> bool

{ (**self).wf(v) }
Source§

open spec fn requires(&self) -> bool

{ (**self).requires() }
Source§

open spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>

{ (**self).spec_parse(s) }
Source§

open spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>

{ (**self).spec_serialize(v) }
Source§

type Type = <C as SpecCombinator>::Type

Source§

impl<Fst: SecureSpecCombinator, Snd: SpecCombinator> SpecCombinator for (Fst, Snd)

Source§

open spec fn requires(&self) -> bool

{ Pair::spec_new(self.0, |r: Fst::Type| self.1).requires() }
Source§

open spec fn wf(&self, v: Self::Type) -> bool

{ Pair::spec_new(self.0, |r: Fst::Type| self.1).wf(v) }
Source§

open spec fn spec_parse(&self, s: Seq<u8>) -> Option<(int, Self::Type)>

{ Pair::spec_new(self.0, |r: Fst::Type| self.1).spec_parse(s) }
Source§

open spec fn spec_serialize(&self, v: Self::Type) -> Seq<u8>

{ Pair::spec_new(self.0, |r: Fst::Type| self.1).spec_serialize(v) }
Source§

type Type = (<Fst as SpecCombinator>::Type, <Snd as SpecCombinator>::Type)

Implementors§

Source§

impl SpecCombinator for BtcVarint

Source§

impl SpecCombinator for Tail

Source§

type Type = Seq<u8>

Source§

impl SpecCombinator for Variable

Source§

type Type = Seq<u8>

Source§

impl SpecCombinator for End

Source§

impl SpecCombinator for Fail

Source§

impl SpecCombinator for UnsignedLEB128

Source§

impl SpecCombinator for Success

Source§

impl SpecCombinator for U8

Source§

impl SpecCombinator for U16Be

Source§

impl SpecCombinator for U16Le

Source§

impl SpecCombinator for U24Be

Source§

impl SpecCombinator for U24Le

Source§

impl SpecCombinator for U32Be

Source§

impl SpecCombinator for U32Le

Source§

impl SpecCombinator for U64Be

Source§

impl SpecCombinator for U64Le

Source§

impl<C: SecureSpecCombinator> SpecCombinator for Repeat<C>

Source§

type Type = Seq<<C as SpecCombinator>::Type>

Source§

impl<C: SecureSpecCombinator> SpecCombinator for RepeatN<C>

Source§

type Type = Seq<<C as SpecCombinator>::Type>

Source§

impl<Fst, Snd> SpecCombinator for Choice<Fst, Snd>
where Fst: SpecCombinator, Snd: SpecCombinator + DisjointFrom<Fst>,

Source§

impl<Fst, Snd> SpecCombinator for OptThen<Fst, Snd>

Source§

type Type = (<Opt<Fst> as SpecCombinator>::Type, <Snd as SpecCombinator>::Type)

Source§

impl<Fst, Snd> SpecCombinator for SpecPair<Fst, Snd>

Source§

type Type = (<Fst as SpecCombinator>::Type, <Snd as SpecCombinator>::Type)

Source§

impl<Fst: SecureSpecCombinator<Type = ()>, Snd: SpecCombinator> SpecCombinator for Preceded<Fst, Snd>

Source§

impl<Fst: SecureSpecCombinator, Snd: SpecCombinator<Type = ()>> SpecCombinator for Terminated<Fst, Snd>

Source§

impl<Inner, M> SpecCombinator for Mapped<Inner, M>
where Inner: SpecCombinator, M: SpecIso<Src = Inner::Type>, Inner::Type: SpecFrom<M::Dst>, M::Dst: SpecFrom<Inner::Type>,

Source§

type Type = <M as SpecIso>::Dst

Source§

impl<Inner, M> SpecCombinator for TryMap<Inner, M>
where Inner: SpecCombinator, M: SpecPartialIso<Src = Inner::Type>, Inner::Type: SpecTryFrom<M::Dst>, M::Dst: SpecTryFrom<Inner::Type>,

Source§

impl<Inner, P> SpecCombinator for Refined<Inner, P>
where Inner: SpecCombinator, P: SpecPred<Inner::Type>,

Source§

type Type = <Inner as SpecCombinator>::Type

Source§

impl<Inner: SpecCombinator> SpecCombinator for Cond<Inner>

Source§

type Type = <Inner as SpecCombinator>::Type

Source§

impl<Inner: SpecCombinator<Type = T>, T> SpecCombinator for Tag<Inner, T>

Source§

impl<Next: SpecCombinator> SpecCombinator for AndThen<Variable, Next>

Source§

type Type = <Next as SpecCombinator>::Type

Source§

impl<T: SecureSpecCombinator> SpecCombinator for Opt<T>

Source§

impl<const N: usize> SpecCombinator for Fixed<N>

Source§

type Type = Seq<u8>