Skip to main content

Parser

Trait Parser 

Source
pub trait Parser<Input: View<V = Seq<u8>>>: SpecParser {
    type PT: DeepView<V = Self::PVal>;

    // Required method
    exec fn parse(&self, ibuf: &Input) -> r : PResult<Self::PT>;

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

An executable parser proved equivalent to a pure SpecParser.

Input is normally &[u8]. Successful parsing returns both the consumed byte count and a value whose deep view is exactly the value returned by SpecParser::spec_parse.

Required Associated Types§

Source

type PT: DeepView<V = Self::PVal>

Executable value returned by this parser.

Required Methods§

Source

exec fn parse(&self, ibuf: &Input) -> r : PResult<Self::PT>

requires
self.exec_inv(),
ensures
parse_matches_spec(r, self.spec_parse(ibuf@)),

Parses a prefix of ibuf.

Provided Methods§

Source

open spec fn exec_inv(&self) -> bool

{ true }

Extra invariant required by this parser’s executable implementation.

Most formats leave this as true; functional and recursive parser callbacks use it to connect executable code to their specifications.

Implementations on Foreign Types§

Source§

impl<I, P> Parser<I> for &P
where I: View<V = Seq<u8>>, P: Parser<I>,

Source§

open spec fn exec_inv(&self) -> bool

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

exec fn parse(&self, ibuf: &I) -> r : PResult<Self::PT>

Source§

type PT = <P as Parser<I>>::PT

Source§

impl<I, T, Spec, Exec> Parser<I> for (Spec, Exec)
where I: View<V = Seq<u8>>, T: DeepView<V = Spec::PVal>, Spec: SpecParser, Exec: Fn(&I) -> PResult<T>,

Source§

open spec fn exec_inv(&self) -> bool

{
    &&& forall |i: &I| call_requires(self.1, (i,))
    &&& forall |i: &I, r: PResult<T>| {
        call_ensures(self.1, (i,), r) ==> parse_matches_spec(r, self.spec_parse(i@))
    }

}
Source§

exec fn parse(&self, ibuf: &I) -> r : PResult<T>

Source§

type PT = T

Implementors§

Source§

impl Parser<&[u8]> for BerLengthFmt

Source§

impl Parser<&[u8]> for ObjectIdentifierFmt

Available on crate feature alloc only.
Source§

impl Parser<&[u8]> for TagFmt

Source§

impl Parser<&[u8]> for I8

Source§

type PT = i8

Source§

impl Parser<&[u8]> for I16Be

Source§

impl Parser<&[u8]> for I16Le

Source§

impl Parser<&[u8]> for I32Be

Source§

impl Parser<&[u8]> for I32Le

Source§

impl Parser<&[u8]> for I64Be

Source§

impl Parser<&[u8]> for I64Le

Source§

impl Parser<&[u8]> for U8

Source§

type PT = u8

Source§

impl Parser<&[u8]> for U16Be

Source§

impl Parser<&[u8]> for U16Le

Source§

impl Parser<&[u8]> for U24Be

Source§

impl Parser<&[u8]> for U24Le

Source§

impl Parser<&[u8]> for U32Be

Source§

impl Parser<&[u8]> for U32Le

Source§

impl Parser<&[u8]> for U64Be

Source§

impl Parser<&[u8]> for U64Le

Source§

impl<'a, const DER: bool> Parser<&'a [u8]> for AnyFmt<DER>

Source§

type PT = Any<'a>

Source§

impl<'a, const DER: bool> Parser<&'a [u8]> for RealFmt<DER>

Source§

type PT = Real<'a, DER>

Source§

impl<'i> Parser<&'i [u8]> for BerEndFmt

Source§

type PT = ()

Source§

impl<'i> Parser<&'i [u8]> for Integer8Fmt

Source§

type PT = i8

Source§

impl<'i> Parser<&'i [u8]> for Integer16Fmt

Source§

impl<'i> Parser<&'i [u8]> for BmpStringFmt

Available on crate feature alloc only.
Source§

impl<'i> Parser<&'i [u8]> for EnumeratedFmt

Source§

type PT = Integer<'i>

Source§

impl<'i> Parser<&'i [u8]> for Ia5StringFmt

Source§

impl<'i> Parser<&'i [u8]> for IntegerFmt

Source§

type PT = Integer<'i>

Source§

impl<'i> Parser<&'i [u8]> for PrintableStringFmt

Source§

impl<'i> Parser<&'i [u8]> for TeletexStringFmt

Source§

impl<'i> Parser<&'i [u8]> for UniversalStringFmt

Available on crate feature alloc only.
Source§

impl<'i> Parser<&'i [u8]> for Utf8StringFmt

Source§

type PT = &'i str

Source§

impl<'i> Parser<&'i [u8]> for CborInitialFmt

Source§

impl<'i, C> Parser<&'i [u8]> for BerSequenceFmt<C>
where C: SpecCombinator + Parser<&'i [u8]> + SafeParser + Copy,

Source§

type PT = <C as Parser<&'i [u8]>>::PT

Source§

impl<'i, C> Parser<&'i [u8]> for BerSequenceOfFmt<C>
where C: SpecCombinator + Parser<&'i [u8]> + Productive + Copy,

Available on crate feature alloc only.
Source§

type PT = Vec<<C as Parser<&'i [u8]>>::PT>

Source§

impl<'i, C> Parser<&'i [u8]> for SetOfFmt<C>
where C: Parser<&'i [u8]> + SafeParser + Productive + Copy,

Available on crate feature alloc only.
Source§

type PT = Vec<<C as Parser<&'i [u8]>>::PT>

Source§

impl<'i, C, const LIMIT: usize> Parser<&'i [u8]> for BerCharStringFmt<C, LIMIT>
where C: BerDecoderOwned,

Available on crate feature alloc only.
Source§

impl<'i, Content, const DER: bool> Parser<&'i [u8]> for ASN1Fmt<Content, DER>
where Content: SpecCombinator + Parser<&'i [u8]>,

Source§

type PT = <Content as Parser<&'i [u8]>>::PT

Source§

impl<'i, const DER: bool> Parser<&'i [u8]> for BitStringFmt<DER>

Source§

type PT = BitString<'i, DER>

Source§

impl<'i, const DER: bool> Parser<&'i [u8]> for GeneralizedTimeFmt<DER>

Source§

impl<'i, const DER: bool> Parser<&'i [u8]> for UtcTimeFmt<DER>

Source§

impl<'i, const DET: bool> Parser<&'i [u8]> for CborHeadFmt<DET>

Source§

impl<'i, const DET: bool, const LIMIT: usize> Parser<&'i [u8]> for CborFmt<DET, LIMIT>
where CborRecBody<DET>: SpecRecBody<Param = (), T = CborValueSpec, Body = CborBodyFmt<DET>> + ParserRecBody<&'i [u8], EP = (), O = CborValue<'i>>, <CborRecBody<DET> as SpecRecBody>::Body: Productive,

Source§

impl<'i, const LIMIT: usize> Parser<&'i [u8]> for BerAnyFmt<LIMIT>

Available on crate feature alloc only.
Source§

impl<'i, const LIMIT: usize> Parser<&'i [u8]> for BerBitStringFmt<LIMIT>

Available on crate feature alloc only.
Source§

impl<'i, const LIMIT: usize> Parser<&'i [u8]> for BerOctetStringFmt<LIMIT>

Available on crate feature alloc only.
Source§

type PT = Vec<u8>

Source§

impl<'i, const MINIMAL: bool> Parser<&'i [u8]> for VarInt<MINIMAL>

Source§

impl<I, A> Parser<I> for Opt<A>
where I: View<V = Seq<u8>>, A: Parser<I>,

Source§

type PT = Option<<A as Parser<I>>::PT>

Source§

impl<I, A> Parser<I> for OptionalEnd<A>
where I: InputBuf, A: Parser<I> + SafeParser,

Source§

type PT = Option<<A as Parser<I>>::PT>

Source§

impl<I, A> Parser<I> for RepeatTillEnd<A>
where I: InputBuf, A: Parser<I> + SafeParser + Productive + Copy,

Available on crate feature alloc only.
Source§

type PT = Vec<<A as Parser<I>>::PT>

Source§

impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, false>
where I: InputBuf, A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>, B: Parser<I> + SafeParser, AVal: DeepView<V = AVal>,

Source§

type PT = <B as Parser<I>>::PT

Source§

impl<I, A, AVal, B> Parser<I> for Preceded<A, AVal, B, true>
where I: InputBuf, A: Parser<I, PT = AVal> + SafeParser<PVal = AVal>, B: Parser<I> + SafeParser, AVal: DeepView<V = AVal> + PartialEq + Structural,

Source§

type PT = <B as Parser<I>>::PT

Source§

impl<I, A, B> Parser<I> for Sum<A, B>
where I: View<V = Seq<u8>>, A: Parser<I>, B: Parser<I>,

Source§

type PT = Sum<<A as Parser<I>>::PT, <B as Parser<I>>::PT>

Source§

impl<I, A, B> Parser<I> for Choice<A, B>
where I: View<V = Seq<u8>>, A: Parser<I>, B: Parser<I>,

Source§

type PT = Sum<<A as Parser<I>>::PT, <B as Parser<I>>::PT>

Source§

impl<I, A, B> Parser<I> for Optional<A, B>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I> + SafeParser,

Source§

type PT = (Option<<A as Parser<I>>::PT>, <B as Parser<I>>::PT)

Source§

impl<I, A, B> Parser<I> for Repeat<A, B>
where I: InputBuf, A: Parser<I> + SafeParser + Productive + Copy, B: Parser<I> + SafeParser + Copy,

Available on crate feature alloc only.
Source§

type PT = (Vec<<A as Parser<I>>::PT>, <B as Parser<I>>::PT)

Source§

impl<I, A, B> Parser<I> for Bind<A, B>
where I: InputBuf, A: Parser<I> + SafeParser, B::O: Parser<I> + SafeParser, B: MapRef<A::PT, Input = A::PVal>,

Source§

type PT = (<A as Parser<I>>::PT, <<B as MapRef<<A as Parser<I>>::PT>>::O as Parser<I>>::PT)

Source§

impl<I, A, B> Parser<I> for Pair<A, B>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I> + SafeParser,

Source§

type PT = (<A as Parser<I>>::PT, <B as Parser<I>>::PT)

Source§

impl<I, A, B, BVal> Parser<I> for Terminated<A, B, BVal, false>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I, PT = BVal> + SafeParser<PVal = BVal>, BVal: DeepView<V = BVal>,

Source§

type PT = <A as Parser<I>>::PT

Source§

impl<I, A, B, BVal> Parser<I> for Terminated<A, B, BVal, true>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I, PT = BVal> + SafeParser<PVal = BVal>, BVal: DeepView<V = BVal> + PartialEq + Structural,

Source§

type PT = <A as Parser<I>>::PT

Source§

impl<I, A, B, C> Parser<I> for Permute3<A, B, C>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I> + SafeParser, C: Parser<I> + SafeParser,

Source§

type PT = (<A as Parser<I>>::PT, (<B as Parser<I>>::PT, <C as Parser<I>>::PT))

Source§

impl<I, A, B, C, D> Parser<I> for Permute4<A, B, C, D>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I> + SafeParser, C: Parser<I> + SafeParser, D: Parser<I> + SafeParser,

Source§

type PT = (<A as Parser<I>>::PT, (<B as Parser<I>>::PT, (<C as Parser<I>>::PT, <D as Parser<I>>::PT)))

Source§

impl<I, A, B, C, D, E> Parser<I> for Permute5<A, B, C, D, E>
where I: InputBuf, A: Parser<I> + SafeParser, B: Parser<I> + SafeParser, C: Parser<I> + SafeParser, D: Parser<I> + SafeParser, E: Parser<I> + SafeParser,

Source§

type PT = (<A as Parser<I>>::PT, (<B as Parser<I>>::PT, (<C as Parser<I>>::PT, (<D as Parser<I>>::PT, <E as Parser<I>>::PT))))

Source§

impl<I, A, PredFn> Parser<I> for Refined<A, PredFn>
where I: View<V = Seq<u8>>, A: Parser<I>, PredFn: Pred<A::PT>,

Source§

type PT = <A as Parser<I>>::PT

Source§

impl<I, Field, Rest, const DER: bool> Parser<I> for DefaultedFmt<Field, Field::T, Rest, DER>
where I: InputBuf, Field: Parser<I, PT = Field::T> + SafeParser<PVal = Field::T> + SpecByteLen, Rest: Parser<I> + SafeParser<PVal = Rest::T> + SpecByteLen, Field::T: DeepView<V = Field::T> + PartialEq + Structural + Copy,

Source§

type PT = (<Field as Parser<I>>::PT, <Rest as Parser<I>>::PT)

Source§

impl<I, Inner> Parser<I> for Cond<Inner>
where I: View<V = Seq<u8>>, Inner: Parser<I>,

Source§

type PT = <Inner as Parser<I>>::PT

Source§

impl<I, Inner> Parser<I> for Named<Inner>
where I: View<V = Seq<u8>>, Inner: Parser<I>,

Source§

type PT = <Inner as Parser<I>>::PT

Source§

impl<I, Inner> Parser<I> for Ref<Inner>
where I: View<V = Seq<u8>>, Inner: Parser<I>,

Source§

type PT = <Inner as Parser<I>>::PT

Source§

impl<I, Inner> Parser<I> for Star<Inner>
where I: InputBuf, Inner: Parser<I> + Productive,

Available on crate feature alloc only.
Source§

type PT = Vec<<Inner as Parser<I>>::PT>

Source§

impl<I, Inner, M, MRev> Parser<I> for Mapped<Inner, BiMap<M, MRev>>
where I: View<V = Seq<u8>>, Inner: Parser<I>, M: Map<Inner::PT, Input = Inner::PVal>, MRev: SpecMap<Input = M::Output, Output = M::Input>,

Source§

type PT = <M as Map<<Inner as Parser<I>>::PT>>::O

Source§

impl<I, Inner, N> Parser<I> for RepeatN<Inner, N>
where I: InputBuf, Inner: Parser<I> + SafeParser, N: AsLen,

Available on crate feature alloc only.
Source§

type PT = Vec<<Inner as Parser<I>>::PT>

Source§

impl<I, Inner, T> Parser<I> for Const<Inner, T>
where I: InputBuf, Inner: Parser<I, PT = T, PVal = T>, T: DeepView<V = T> + PartialEq + Structural,

Source§

type PT = <Inner as SpecParser>::PVal

Source§

impl<I, Inner, const N: usize> Parser<I> for Array<N, Inner>
where I: InputBuf, Inner: Parser<I> + SafeParser,

Source§

type PT = [<Inner as Parser<I>>::PT; N]

Source§

impl<I, Len, Inner> Parser<I> for ExactLen<Inner, Len>
where I: InputBuf, Len: AsLen, Inner: Parser<I>,

Source§

type PT = <Inner as Parser<I>>::PT

Source§

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

Source§

type PT = O

Source§

impl<I, Of, Tg, TagVal> Parser<I> for SuffixTagged<Of, Tg, TagVal>
where I: InputBuf, Tg: SpecByteLen<T = TagVal> + Parser<I, PT = TagVal, PVal = TagVal> + SafeParser, TagVal: DeepView<V = TagVal> + PartialEq + Structural + Copy, Of: Parser<I> + SafeParser,

Source§

type PT = <Of as Parser<I>>::PT

Source§

impl<I, P1, P2> Parser<I> for Permute2<P1, P2>
where I: InputBuf, P1: Parser<I> + SafeParser, P2: Parser<I> + SafeParser,

Source§

type PT = (<P1 as Parser<I>>::PT, <P2 as Parser<I>>::PT)

Source§

impl<I, Tg, TagVal, Of> Parser<I> for PrefixTagged<Tg, TagVal, Of>
where I: InputBuf, Tg: SpecByteLen<T = TagVal> + Parser<I, PT = TagVal, PVal = TagVal> + SafeParser, TagVal: DeepView<V = TagVal> + PartialEq + Structural + Copy, Of: Parser<I> + SafeParser,

Source§

type PT = <Of as Parser<I>>::PT

Source§

impl<I: InputBuf> Parser<I> for Eof

Source§

type PT = ()

Source§

impl<I: InputBuf> Parser<I> for Tail

Source§

type PT = I

Source§

impl<I: InputBuf, A, Then> Parser<I> for AndThen<A, Then>
where A: Parser<I, PT = I, PVal = Seq<u8>>, Then: Parser<I>,

Source§

type PT = <Then as Parser<I>>::PT

Source§

impl<I: View<V = Seq<u8>>> Parser<I> for Empty

Source§

type PT = ()

Source§

impl<I: View<V = Seq<u8>>> Parser<I> for Void

Source§

impl<Input, F> Parser<Input> for ImplicitlyTaggedFmt<F>
where Input: InputBuf, F: Retaggable + Parser<Input>,

Source§

type PT = <F as Parser<Input>>::PT

Source§

impl<Len: AsLen, I: InputBuf> Parser<I> for Varied<Len>

Source§

type PT = I

Source§

impl<const DER: bool> Parser<&[u8]> for BoolFmt<DER>

Source§

impl<const DER: bool> Parser<&[u8]> for LengthFmt<DER>

Source§

impl<const LIMIT: usize, Body, Param, I> Parser<I> for FixWith<LIMIT, Body, Param>
where I: InputBuf, Param: DeepView<V = Body::Param>, Body: ParserRecBody<I, EP = Param> + ProductiveRecBody, Body::Body: Productive,

Source§

type PT = <Body as ParserRecBody<I>>::O

Source§

impl<const MINIMAL: bool> Parser<&[u8]> for Base128Fmt<MINIMAL>

Source§

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

Source§

type PT = [u8; N]

Source§

impl<const N: usize, I: InputBuf> Parser<I> for Fixed<N>

Source§

type PT = I

Source§

impl<const NONDETERMINISTIC: bool, I, A, B> Parser<I> for Alt<A, B, NONDETERMINISTIC>
where I: View<V = Seq<u8>>, A: Parser<I>, B: Parser<I, PVal = A::PVal, PT = A::PT>,

Source§

type PT = <A as Parser<I>>::PT