Skip to main content

SafeParser

Trait SafeParser 

Source
pub trait SafeParser: SpecParser {
    // Required method
    broadcast proof fn lemma_parse_safe(&self, ibuf: Seq<u8>);

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

Parser safety.

Successful parses never consume bytes out of bounds.

Required Methods§

Source

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

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

For any successful parse Some((n, _)), 0 <= n <= ibuf.len().

Provided Methods§

Source

open spec fn safe_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<P: SafeParser> SafeParser for &P

Source§

open spec fn safe_inv(&self) -> bool

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

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

Source§

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

Source§

open spec fn safe_inv(&self) -> bool

{ self.0.safe_inv() }
Source§

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

Source§

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

Source§

open spec fn safe_inv(&self) -> bool

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

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

Implementors§

Source§

impl SafeParser for BerEndFmt

Source§

impl SafeParser for Integer8Fmt

Source§

impl SafeParser for Integer16Fmt

Source§

impl SafeParser for BerLengthFmt

Source§

impl SafeParser for BmpStringFmt

Source§

impl SafeParser for EnumeratedFmt

Source§

impl SafeParser for Ia5StringFmt

Source§

impl SafeParser for IntegerFmt

Source§

impl SafeParser for ObjectIdentifierFmt

Source§

impl SafeParser for PrintableStringFmt

Source§

impl SafeParser for TagFmt

Source§

impl SafeParser for TeletexStringFmt

Source§

impl SafeParser for UniversalStringFmt

Source§

impl SafeParser for Utf8StringFmt

Source§

impl SafeParser for CborInitialFmt

Source§

impl SafeParser for Empty

Source§

impl SafeParser for Void

Source§

impl SafeParser for I8

Source§

impl SafeParser for I16Be

Source§

impl SafeParser for I16Le

Source§

impl SafeParser for I32Be

Source§

impl SafeParser for I32Le

Source§

impl SafeParser for I64Be

Source§

impl SafeParser for I64Le

Source§

impl SafeParser for Eof

Source§

impl SafeParser for Tail

Source§

impl SafeParser for U8

Source§

impl SafeParser for U16Be

Source§

impl SafeParser for U16Le

Source§

impl SafeParser for U24Be

Source§

impl SafeParser for U24Le

Source§

impl SafeParser for U32Be

Source§

impl SafeParser for U32Le

Source§

impl SafeParser for U64Be

Source§

impl SafeParser for U64Le

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<F> SafeParser for ImplicitlyTaggedFmt<F>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<Inner: SafeParser> SafeParser for Cond<Inner>

Source§

impl<Inner: SafeParser> SafeParser for Named<Inner>

Source§

impl<Inner: SafeParser> SafeParser for Ref<Inner>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> SafeParser for BundledSpecs<T>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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