Skip to main content

SoundParser

Trait SoundParser 

Source
pub trait SoundParser:
    SpecByteLen
    + SpecParser<PVal = Self::T>
    + Consistency<Val = Self::T> {
    // Required methods
    proof fn lemma_parse_sound_consumption(&self, ibuf: Seq<u8>);
    broadcast proof fn lemma_parse_sound_value(&self, ibuf: Seq<u8>);

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

Parser soundness.

This trait specifies semantic soundness w.r.t. the format spec, independent from the orthogonal safety property captured by SafeParser.

Required Methods§

Source

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

requires
self.sound_inv(),
ensures
self.spec_parse(ibuf) matches Some((n, v)) ==> n == self.byte_len(v),

For any successful parse Some((n, v)), n == self.byte_len(v).

Source

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

requires
self.sound_inv(),
ensures
#[trigger] self.spec_parse(ibuf) matches Some((_, v)) ==> self.consistent(v),

For any successful parse Some((_, v)), v is consistent with the format’s spec.

Provided Methods§

Source

open spec fn sound_inv(&self) -> bool

{ true }

Optional invariant (used by spec-function combinators; struct-based combinators typically leave this as true).

Implementations on Foreign Types§

Source§

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

Source§

open spec fn sound_inv(&self) -> bool

{
    let (p, c, b) = *self;
    let (p_fn, c_fn, b_fn) = (
        |ibuf| p.spec_parse(ibuf),
        |v| c.consistent(v),
        |v| b.byte_len(v),
    );
    sound_parser(p_fn, c_fn, b_fn)
}
Source§

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

Source§

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

Implementors§

Source§

impl SoundParser for Integer8Fmt

Source§

impl SoundParser for Integer16Fmt

Source§

impl SoundParser for AnyFmt<true>

Source§

impl SoundParser for BmpStringFmt

Source§

impl SoundParser for EnumeratedFmt

Source§

impl SoundParser for GeneralizedTimeFmt<true>

Source§

impl SoundParser for Ia5StringFmt

Source§

impl SoundParser for IntegerFmt

Source§

impl SoundParser for LengthFmt<true>

Source§

impl SoundParser for NatLengthFmt<true>

Source§

impl SoundParser for ObjectIdentifierFmt

Source§

impl SoundParser for PrintableStringFmt

Source§

impl SoundParser for TagFmt

Source§

impl SoundParser for TeletexStringFmt

Source§

impl SoundParser for UniversalStringFmt

Source§

impl SoundParser for UtcTimeFmt<true>

Source§

impl SoundParser for Utf8StringFmt

Source§

impl SoundParser for CborHeadFmt<true>

Source§

impl SoundParser for CborInitialFmt

Source§

impl SoundParser for Empty

Source§

impl SoundParser for Void

Source§

impl SoundParser for I8

Source§

impl SoundParser for I16Be

Source§

impl SoundParser for I16Le

Source§

impl SoundParser for I32Be

Source§

impl SoundParser for I32Le

Source§

impl SoundParser for I64Be

Source§

impl SoundParser for I64Le

Source§

impl SoundParser for Eof

Source§

impl SoundParser for Tail

Source§

impl SoundParser for U8

Source§

impl SoundParser for U16Be

Source§

impl SoundParser for U16Le

Source§

impl SoundParser for U24Be

Source§

impl SoundParser for U24Le

Source§

impl SoundParser for U32Be

Source§

impl SoundParser for U32Le

Source§

impl SoundParser for U64Be

Source§

impl SoundParser for U64Le

Source§

impl SoundParser for Base128Fmt<true>

Source§

impl SoundParser for VarInt<true>

Source§

impl<A> SoundParser for Opt<A>
where A: SoundParser,

Source§

impl<A> SoundParser for Star<A>
where A: SoundParser,

Source§

impl<A, B> SoundParser for Optional<A, B>
where A: SoundParser, B: SoundParser,

Source§

impl<A, B> SoundParser for Preceded<A, A::PVal, B, false>

Source§

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

Source§

impl<A, B> SoundParser for Repeat<A, B>
where A: SoundParser, B: SoundParser,

Source§

impl<A, B> SoundParser for PairRev<A, B>

Source§

impl<A, B> SoundParser for Terminated<A, B, B::PVal, false>

Source§

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

Source§

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

Source§

impl<A, B> SoundParser for Pair<A, B>
where A: SoundParser, B: SoundParser,

Source§

impl<A, Pred> SoundParser for Refined<A, Pred>
where A: SoundParser, Pred: SpecPred<A::PVal>,

Source§

impl<A, Then> SoundParser for AndThen<A, Then>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<C> SoundParser for OptionalEnd<C>
where C: SoundParser,

Source§

impl<C> SoundParser for RepeatTillEnd<C>
where C: SoundParser,

Source§

impl<C: SoundParser + PSRoundTrip> SoundParser for SetOfFmt<C>

Source§

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

Source§

impl<Content: SpecCombinator + SoundParser> SoundParser for ASN1Fmt<Content, true>

Source§

impl<F> SoundParser for ImplicitlyTaggedFmt<F>

Source§

impl<Field, Rest, const DER: bool> SoundParser for DefaultedFmt<Field, Field::PVal, Rest, DER>
where Field: SoundParser, Rest: SoundParser,

Source§

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

Source§

impl<Inner> SoundParser for Const<Inner, Inner::PVal>
where Inner: SoundParser,

Source§

impl<Inner, M> SoundParser for Mapped<Inner, M>
where Inner: SoundParser, M: LosslessMapper<In = Inner::PVal>,

Source§

impl<Inner, M> SoundParser for TryMap<Inner, M>
where Inner: SoundParser, M: LosslessMapper<In = Inner::PVal>,

Source§

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

Source§

impl<Inner: SoundParser> SoundParser for Cond<Inner>

Source§

impl<Inner: SoundParser> SoundParser for Named<Inner>

Source§

impl<Inner: SoundParser> SoundParser for Ref<Inner>

Source§

impl<Inner: SoundParser, Len: AsLen> SoundParser for ExactLen<Inner, Len>

Source§

impl<Inner: SoundParser, Out> SoundParser for Mapped<Inner, FnSpecMapper<Inner::PVal, Out>>

Source§

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

Source§

impl<Of, Tg> SoundParser for SuffixTagged<Of, Tg, Tg::T>

Source§

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

Source§

impl<Repr, Tuple, Nominal> SoundParser for Bits<Repr, Tuple, Nominal>
where Repr: SoundParser,

Source§

impl<T> SoundParser for BundledSpecs<T>

Source§

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

Source§

impl<Tg, Of> SoundParser for PrefixTagged<Tg, Tg::T, Of>

Source§

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

Source§

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

Source§

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

Source§

impl<const LIMIT: usize> SoundParser for CborFmt<true, LIMIT>

Source§

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

Source§

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

Source§

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

Source§

impl<const N: usize> SoundParser for ULeb128<true, N>

Source§

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

Source§

impl<const NONDETERMINISTIC: bool, A, B> SoundParser for Alt<A, B, NONDETERMINISTIC>
where A: SoundParser, B: SoundParser<T = A::T>,