Skip to main content

NoLookAhead

Trait NoLookAhead 

Source
pub trait NoLookAhead: SafeParser {
    // Required method
    proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>);

    // Provided methods
    open spec fn no_lookahead_inv(&self) -> bool { ... }
    fn corollary_non_extensible(&self, i1: Seq<u8>, i2: Seq<u8>) { ... }
}
Expand description

No-lookahead property for parsers.

Intuitively: the parser’s behavior does not depend on “future” bytes beyond the consumed prefix (i.e., it does not need to “look ahead”/“peek” at them to decide how to parse the prefix).

Formally: if two buffers share a common prefix that successfully parses, then they parse to the same value.

Required Methods§

Source

proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)

requires
self.safe_inv(),
self.no_lookahead_inv(),
ensures
self
    .spec_parse(
        i1,
    ) matches Some(
    (n, v),
) ==> 0 <= n <= i2.len()
    ==> (i2[0..n] == i1[0..n] ==> self.spec_parse(i2) == Some((n, v))),

Provided Methods§

Source

open spec fn no_lookahead_inv(&self) -> bool

{ true }
Source

proof fn corollary_non_extensible(&self, i1: Seq<u8>, i2: Seq<u8>)

requires
self.safe_inv(),
self.no_lookahead_inv(),
ensures
self.spec_parse(i1) matches Some((n, v)) ==> self.spec_parse(i1 + i2) == Some((n, v)),

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl NoLookAhead for BerLengthFmt

Source§

impl NoLookAhead for CborInitialFmt

Source§

impl NoLookAhead for Empty

Source§

impl NoLookAhead for I8

Source§

impl NoLookAhead for I16Be

Source§

impl NoLookAhead for I16Le

Source§

impl NoLookAhead for I32Be

Source§

impl NoLookAhead for I32Le

Source§

impl NoLookAhead for I64Be

Source§

impl NoLookAhead for I64Le

Source§

impl NoLookAhead for TagFmt

Source§

impl NoLookAhead for U8

Source§

impl NoLookAhead for U16Be

Source§

impl NoLookAhead for U16Le

Source§

impl NoLookAhead for U24Be

Source§

impl NoLookAhead for U24Le

Source§

impl NoLookAhead for U32Be

Source§

impl NoLookAhead for U32Le

Source§

impl NoLookAhead for U64Be

Source§

impl NoLookAhead for U64Le

Source§

impl NoLookAhead for Void

Source§

impl<A, B, const CHECK: bool> NoLookAhead for Preceded<A, A::PVal, B, CHECK>
where A: NoLookAhead, B: NoLookAhead,

Source§

impl<A, B, const CHECK: bool> NoLookAhead for Terminated<A, B, B::PVal, CHECK>
where A: NoLookAhead, B: NoLookAhead,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<A: NoLookAhead, B: NoLookAhead> NoLookAhead for Repeat<A, B>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<F> NoLookAhead for ImplicitlyTaggedFmt<F>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<Inner, M> NoLookAhead for TryMap<Inner, M>
where Inner: NoLookAhead, M: LossyMapper<In = Inner::PVal>,

Source§

impl<Inner: NoLookAhead> NoLookAhead for Cond<Inner>

Source§

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

Source§

impl<Inner: NoLookAhead> NoLookAhead for Named<Inner>

Source§

impl<Inner: NoLookAhead> NoLookAhead for Ref<Inner>

Source§

impl<Inner: SafeParser, Len: AsLen> NoLookAhead for ExactLen<Inner, Len>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> NoLookAhead for BundledSpecs<T>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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