Skip to main content

Productive

Trait Productive 

Source
pub trait Productive: SafeParser {
    // Required method
    broadcast proof fn lemma_productive(&self, s: Seq<u8>);

    // Provided method
    open spec fn productive_inv(&self) -> bool { ... }
}
Expand description

Productivity for parsers.

A productive parser always consumes at least one byte when it succeeds.

Inherently unproductive combinators are:

  • Empty: Always succeeds and never consumes any bytes.
  • Eof: Asserts the end of the input. It only succeeds if the buffer is entirely empty, thus always consuming 0 bytes.
  • Tail: Consumes all remaining bytes in the buffer. If the buffer is already empty, it successfully consumes 0 bytes.
  • Opt<A>: Evaluates an optional field. If A fails, Opt<A> successfully returns None while consuming 0 bytes.
  • Star<A>: The Kleene star for zero-or-more repetitions. It can successfully parse zero occurrences of A, consuming 0 bytes.
  • OptionalEnd<C> & RepeatTillEnd<C>: These are syntax sugar for Optional<C, Eof> and Repeat<C, Eof>.

The above combinators still implement the Productive trait in order for sequencing combinators like Pair to remain productive, but their productive_inv would return false (so lemma_productive would not apply to them).

Required Methods§

Source

broadcast proof fn lemma_productive(&self, s: Seq<u8>)

requires
self.safe_inv(),
self.productive_inv(),
ensures
#[trigger] self.spec_parse(s) matches Some((n, _)) ==> n > 0,

Provided Methods§

Source

open spec fn productive_inv(&self) -> bool

{ true }

Implementations on Foreign Types§

Source§

impl<P: Productive> Productive for &P

Source§

open spec fn productive_inv(&self) -> bool

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

proof fn lemma_productive(&self, s: Seq<u8>)

Source§

impl<Spec, Exec> Productive for (Spec, Exec)
where Spec: Productive,

Source§

open spec fn productive_inv(&self) -> bool

{ self.0.productive_inv() }
Source§

proof fn lemma_productive(&self, input: Seq<u8>)

Source§

impl<SpecP, Cnstcy, Blen> Productive for (SpecP, Cnstcy, Blen)
where Blen: SpecByteLen, SpecP: SpecParser<PVal = Blen::T>, Cnstcy: Consistency<Val = Blen::T>,

Source§

open spec fn productive_inv(&self) -> bool

{
    let (p, _, _) = *self;
    let p_fn = |ibuf| p.spec_parse(ibuf);
    productive_parser(p_fn)
}
Source§

proof fn lemma_productive(&self, ibuf: Seq<u8>)

Implementors§

Source§

impl Productive for BerEndFmt

Source§

impl Productive for Integer8Fmt

Source§

impl Productive for Integer16Fmt

Source§

impl Productive for BerLengthFmt

Source§

impl Productive for BmpStringFmt

Source§

impl Productive for EnumeratedFmt

Source§

impl Productive for Ia5StringFmt

Source§

impl Productive for IntegerFmt

Source§

impl Productive for ObjectIdentifierFmt

Source§

impl Productive for PrintableStringFmt

Source§

impl Productive for TagFmt

Source§

impl Productive for TeletexStringFmt

Source§

impl Productive for UniversalStringFmt

Source§

impl Productive for Utf8StringFmt

Source§

impl Productive for CborInitialFmt

Source§

impl Productive for Empty

Source§

impl Productive for Void

Source§

impl Productive for I8

Source§

impl Productive for I16Be

Source§

impl Productive for I16Le

Source§

impl Productive for I32Be

Source§

impl Productive for I32Le

Source§

impl Productive for I64Be

Source§

impl Productive for I64Le

Source§

impl Productive for Eof

Source§

impl Productive for Tail

Source§

impl Productive for U8

Source§

impl Productive for U16Be

Source§

impl Productive for U16Le

Source§

impl Productive for U24Be

Source§

impl Productive for U24Le

Source§

impl Productive for U32Be

Source§

impl Productive for U32Le

Source§

impl Productive for U64Be

Source§

impl Productive for U64Le

Source§

impl<A, B> Productive for Preceded<A, A::PVal, B, false>
where A: Productive, B: Productive,

Source§

impl<A, B> Productive for Preceded<A, A::PVal, B, true>
where A: Productive, B: Productive,

Source§

impl<A, B> Productive for Terminated<A, B, B::PVal, false>
where A: Productive, B: Productive,

Source§

impl<A, B> Productive for Terminated<A, B, B::PVal, true>
where A: Productive, B: Productive,

Source§

impl<A, B> Productive for Bind<A, B>
where A: Productive, B: SpecMap<Input = A::PVal>, B::Output: Productive,

Source§

impl<A, Then> Productive for AndThen<A, Then>
where A: BytesCombinator + Productive<PVal = Seq<u8>>, Then: SafeParser,

Source§

impl<A: SafeParser> Productive for Opt<A>

Source§

impl<A: SafeParser> Productive for Star<A>

Source§

impl<A: SafeParser, B: Productive> Productive for Repeat<A, B>

Source§

impl<A: Productive, B: StaticByteLen + SafeParser<PVal = B::T>> Productive for PairRev<A, B>

Source§

impl<A: Productive, B: Productive> Productive for Sum<A, B>

Source§

impl<A: Productive, B: Productive> Productive for Choice<A, B>

Source§

impl<A: Productive, B: Productive> Productive for Optional<A, B>

Source§

impl<A: Productive, B: Productive> Productive for Pair<A, B>

Source§

impl<A: Productive, B: Productive, C: Productive> Productive for Permute3<A, B, C>

Source§

impl<A: Productive, B: Productive, C: Productive, D: Productive> Productive for Permute4<A, B, C, D>

Source§

impl<A: Productive, B: Productive, C: Productive, D: Productive, E: Productive> Productive for Permute5<A, B, C, D, E>

Source§

impl<A: Productive, Pred: SpecPred<A::PVal>> Productive for Refined<A, Pred>

Source§

impl<C: SafeParser> Productive for SetOfFmt<C>

Source§

impl<C: SafeParser> Productive for OptionalEnd<C>

Source§

impl<C: SafeParser> Productive for RepeatTillEnd<C>

Source§

impl<C: SpecCombinator + SafeParser + Productive> Productive for BerSequenceFmt<C>

Source§

impl<C: SpecCombinator + SafeParser> Productive for BerSequenceOfFmt<C>

Source§

impl<C: SpecCombinator, const LIMIT: usize> Productive for BerCharStringFmt<C, LIMIT>

Source§

impl<C: Productive, N: AsLen> Productive for RepeatN<C, N>

Source§

impl<Content: SpecCombinator + Productive, const DER: bool> Productive for ASN1Fmt<Content, DER>

Source§

impl<F> Productive for ImplicitlyTaggedFmt<F>

Source§

impl<Field, Rest, const DER: bool> Productive for DefaultedFmt<Field, Field::PVal, Rest, DER>
where Field: SpecByteLen + Productive<PVal = Field::T>, Rest: SpecByteLen + Productive<PVal = Rest::T>,

Source§

impl<Head, Tail> Productive for Implicit<Head, Tail>
where Head: Productive, Tail: DepCombinator<Key = Head::PVal>, Tail::Body: Productive<PVal = Tail::Val>,

Source§

impl<I, O, Spec, Exec> Productive for FnParser<I, O, Spec, Exec>
where I: View<V = Seq<u8>>, O: DeepView, Spec: Productive<PVal = O::V>, Exec: Fn(&I) -> PResult<O>,

Source§

impl<Inner, Len> Productive for ExactLen<Inner, Len>
where Inner: SafeParser, Len: AsLen,

Source§

impl<Inner, M> Productive for Mapped<Inner, M>
where Inner: Productive, M: SpecMapper<In = Inner::PVal>,

Source§

impl<Inner, M> Productive for TryMap<Inner, M>
where Inner: Productive, M: SpecMapper<In = Inner::PVal>,

Source§

impl<Inner, M, MRev> Productive for Mapped<Inner, BiMap<M, MRev>>
where Inner: Productive, M: SpecMap<Input = Inner::PVal>, MRev: SpecMap<Input = M::Output, Output = M::Input>,

Source§

impl<Inner: Productive> Productive for Cond<Inner>

Source§

impl<Inner: Productive> Productive for Named<Inner>

Source§

impl<Inner: Productive> Productive for Ref<Inner>

Source§

impl<Inner: Productive> Productive for Const<Inner, Inner::PVal>

Source§

impl<Inner: Productive, Out> Productive for Mapped<Inner, FnSpec<(Inner::PVal,), Out>>

Source§

impl<Len: AsLen> Productive for Varied<Len>

Source§

impl<Of, Tg> Productive for SuffixTagged<Of, Tg, Tg::T>
where Tg: SpecByteLen + Productive<PVal = Tg::T>, Of: Productive,

Source§

impl<P1: Productive, P2: Productive> Productive for Permute2<P1, P2>

Source§

impl<Repr, Tuple, Nominal> Productive for Bits<Repr, Tuple, Nominal>
where Repr: SpecByteLen + Productive<PVal = Repr::T>,

Source§

impl<T> Productive for BundledSpecs<T>

Source§

impl<T, C: Productive, const N: usize> Productive for Dispatch<T, C, N>

Source§

impl<Tg, Of> Productive for PrefixTagged<Tg, Tg::T, Of>
where Tg: SpecByteLen + Productive<PVal = Tg::T>, Of: Productive,

Source§

impl<const DER: bool> Productive for AnyFmt<DER>

Source§

impl<const DER: bool> Productive for BitStringFmt<DER>

Source§

impl<const DER: bool> Productive for BoolFmt<DER>

Source§

impl<const DER: bool> Productive for GeneralizedTimeFmt<DER>

Source§

impl<const DER: bool> Productive for LengthFmt<DER>

Source§

impl<const DER: bool> Productive for NatLengthFmt<DER>

Source§

impl<const DER: bool> Productive for RealFmt<DER>

Source§

impl<const DER: bool> Productive for UtcTimeFmt<DER>

Source§

impl<const DET: bool> Productive for CborHeadFmt<DET>

Source§

impl<const DET: bool, const LIMIT: usize> Productive for CborFmt<DET, LIMIT>

Source§

impl<const LIMIT: usize> Productive for BerAnyFmt<LIMIT>

Source§

impl<const LIMIT: usize> Productive for BerBitStringFmt<LIMIT>

Source§

impl<const LIMIT: usize> Productive for BerOctetStringFmt<LIMIT>

Source§

impl<const LIMIT: usize, Body, Param> Productive for FixWith<LIMIT, Body, Param>
where Body: ProductiveRecBody, Body::Body: Productive, Param: DeepView<V = Body::Param>,

Source§

impl<const MINIMAL: bool> Productive for Base128Fmt<MINIMAL>

Source§

impl<const MINIMAL: bool> Productive for VarInt<MINIMAL>

Source§

impl<const MINIMAL: bool, const N: usize> Productive for ULeb128<MINIMAL, N>

Source§

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

Source§

impl<const N: usize> Productive for Const<Fixed<N>, [u8; N]>

Source§

impl<const N: usize, C: Productive> Productive for Array<N, C>

Source§

impl<const NONDETERMINISTIC: bool, A, B> Productive for Alt<A, B, NONDETERMINISTIC>
where A: Productive, B: Productive<PVal = A::PVal>,