Skip to main content

Prepare

Trait Prepare 

Source
pub trait Prepare<T>: SpecByteLen<T = T::V> + Consistency<Val = T::V>
where T: DeepView + ?Sized,
{ // Required method exec fn prepare(&self, v: &T) -> checked : Result<usize, PreSerializeError>; // Provided method open spec fn exec_inv(&self) -> bool { ... } }
Expand description

Checks that a value can be serialized and computes its exact output length.

Call this before allocating an output or invoking SerializerExt::serialize on a value whose consistency has not already been established.

Required Methods§

Source

exec fn prepare(&self, v: &T) -> checked : Result<usize, PreSerializeError>

requires
self.exec_inv(),
ensures
checked matches Ok(
    len,
) ==> {
    &&& self.consistent(v.deep_view())
    &&& len == self.byte_len(v.deep_view())

},

Validates v and returns its exact serialized length.

Provided Methods§

Source

open spec fn exec_inv(&self) -> bool

{ true }

Extra invariant required by the executable preparation implementation.

Implementations on Foreign Types§

Source§

impl<T, S> Prepare<T> for &S
where T: DeepView + ?Sized, S: Prepare<T>,

Source§

open spec fn exec_inv(&self) -> bool

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

exec fn prepare(&self, v: &T) -> checked : Result<usize, PreSerializeError>

Implementors§

Source§

impl Prepare<BerLength> for BerLengthFmt

Source§

impl Prepare<i8> for Integer8Fmt

Source§

impl Prepare<i8> for I8

Source§

impl Prepare<i16> for Integer16Fmt

Source§

impl Prepare<i16> for I16Be

Source§

impl Prepare<i16> for I16Le

Source§

impl Prepare<i32> for I32Be

Source§

impl Prepare<i32> for I32Le

Source§

impl Prepare<i64> for I64Be

Source§

impl Prepare<i64> for I64Le

Source§

impl Prepare<u8> for U8

Source§

impl Prepare<u16> for U16Be

Source§

impl Prepare<u16> for U16Le

Source§

impl Prepare<u32> for U24Be

Source§

impl Prepare<u32> for U24Le

Source§

impl Prepare<u32> for U32Be

Source§

impl Prepare<u32> for U32Le

Source§

impl Prepare<u64> for U64Be

Source§

impl Prepare<u64> for U64Le

Source§

impl Prepare<()> for BerEndFmt

Source§

impl Prepare<()> for Empty

Source§

impl Prepare<()> for Eof

Source§

impl Prepare<BitStringOwned> for BitStringFmt<false>

Available on crate feature alloc only.
Source§

impl Prepare<BmpString> for BmpStringFmt

Available on crate feature alloc only.
Source§

impl Prepare<Ia5StringOwned> for Ia5StringFmt

Available on crate feature alloc only.
Source§

impl Prepare<ObjectIdentifier> for ObjectIdentifierFmt

Available on crate feature alloc only.
Source§

impl Prepare<PrintableStringOwned> for PrintableStringFmt

Available on crate feature alloc only.
Source§

impl Prepare<Tag> for TagFmt

Source§

impl Prepare<TeletexStringOwned> for TeletexStringFmt

Available on crate feature alloc only.
Source§

impl Prepare<CborInitial> for CborInitialFmt

Source§

impl Prepare<ExecNever> for Void

Source§

impl Prepare<String> for UniversalStringFmt

Available on crate feature alloc only.
Source§

impl Prepare<String> for Utf8StringFmt

Available on crate feature alloc only.
Source§

impl Prepare<[u8]> for Tail

Source§

impl<'a, const DER: bool> Prepare<Any<'a>> for AnyFmt<DER>

Source§

impl<'a, const DER: bool> Prepare<Real<'a, DER>> for RealFmt<DER>

Source§

impl<'i> Prepare<&'i str> for Utf8StringFmt

Source§

impl<'i> Prepare<&'i [u8]> for Tail

Source§

impl<'i> Prepare<Integer<'i>> for EnumeratedFmt

Source§

impl<'i> Prepare<Integer<'i>> for IntegerFmt

Source§

impl<'i> Prepare<Ia5String<'i>> for Ia5StringFmt

Source§

impl<'i> Prepare<PrintableString<'i>> for PrintableStringFmt

Source§

impl<'i> Prepare<TeletexString<'i>> for TeletexStringFmt

Source§

impl<'i, Len: AsLen> Prepare<&'i [u8]> for Varied<Len>

Source§

impl<'i, const DER: bool> Prepare<BitString<'i, DER>> for BitStringFmt<DER>

Source§

impl<'i, const DER: bool> Prepare<GeneralizedTime<'i>> for GeneralizedTimeFmt<DER>

Source§

impl<'i, const DET: bool, const LIMIT: usize> Prepare<CborValue<'i>> for CborFmt<DET, LIMIT>
where CborRecBody<DET>: SpecRecBody<Param = (), T = CborValueSpec, Body = CborBodyFmt<DET>> + PrepareRecBody<CborValue<'i>, EP = ()>,

Source§

impl<'i, const N: usize> Prepare<&'i [u8]> for Fixed<N>

Source§

impl<A, AST> Prepare<Option<AST>> for OptionalEnd<A>
where A: Prepare<AST>, AST: DeepView,

Source§

impl<A, AVal, B, BVal, const CHECK: bool> Prepare<BVal> for Preceded<A, AVal, B, CHECK>
where AVal: DeepView<V = AVal>, BVal: DeepView, A: Prepare<AVal>, B: Prepare<BVal>,

Source§

impl<A, B, AVal, BVal> Prepare<(AVal, BVal)> for PairRev<A, B>
where AVal: DeepView, BVal: DeepView, A: Prepare<AVal>, B: Prepare<BVal>,

Source§

impl<A, B, BVal, T, const CHECK: bool> Prepare<T> for Terminated<A, B, BVal, CHECK>
where T: DeepView, BVal: DeepView<V = BVal>, A: Prepare<T>, B: Prepare<BVal>,

Source§

impl<A, B, C, D, E, TA, TB, TC, TD, TE> Prepare<(TA, (TB, (TC, (TD, TE))))> for Permute5<A, B, C, D, E>
where TA: DeepView, TB: DeepView, TC: DeepView, TD: DeepView, TE: DeepView, A: Prepare<TA>, B: Prepare<TB>, C: Prepare<TC>, D: Prepare<TD>, E: Prepare<TE>,

Source§

impl<A, B, C, D, TA, TB, TC, TD> Prepare<(TA, (TB, (TC, TD)))> for Permute4<A, B, C, D>
where TA: DeepView, TB: DeepView, TC: DeepView, TD: DeepView, A: Prepare<TA>, B: Prepare<TB>, C: Prepare<TC>, D: Prepare<TD>,

Source§

impl<A, B, C, TA, TB, TC> Prepare<(TA, (TB, TC))> for Permute3<A, B, C>
where TA: DeepView, TB: DeepView, TC: DeepView, A: Prepare<TA>, B: Prepare<TB>, C: Prepare<TC>,

Source§

impl<A, B, STA, STB> Prepare<(STA, STB)> for Bind<A, B>
where STA: DeepView, STB: DeepView, A: Prepare<STA>, B::O: Prepare<STB>, B: MapRef<STA, Input = STA::V>,

Source§

impl<A, B, TA, TB> Prepare<(&[TA], TB)> for Repeat<A, B>
where A: Prepare<TA> + Copy, B: Prepare<TB>, TA: DeepView, TB: DeepView,

Source§

impl<A, B, TA, TB> Prepare<(Option<TA>, TB)> for Optional<A, B>
where TA: DeepView, TB: DeepView, A: Prepare<TA>, B: Prepare<TB>,

Source§

impl<A, B, TA, TB> Prepare<Sum<TA, TB>> for Sum<A, B>
where TA: DeepView, TB: DeepView, A: Prepare<TA>, B: Prepare<TB>,

Source§

impl<A, B, TA, TB> Prepare<Sum<TA, TB>> for Choice<A, B>
where TA: DeepView, TB: DeepView, A: Prepare<TA>, B: Prepare<TB>,

Source§

impl<A, B, TA, TB> Prepare<(TA, TB)> for Pair<A, B>
where TA: DeepView, TB: DeepView, A: Prepare<TA>, B: Prepare<TB>,

Source§

impl<A, PredFn, T> Prepare<T> for Refined<A, PredFn>
where T: DeepView, A: Prepare<T>, PredFn: Pred<T>,

Source§

impl<A, T> Prepare<&[T]> for RepeatTillEnd<A>
where A: Prepare<T> + Copy, T: DeepView,

Source§

impl<A, T> Prepare<Option<T>> for Opt<A>
where T: DeepView, A: Prepare<T>,

Source§

impl<A, T> Prepare<Vec<T>> for RepeatTillEnd<A>
where A: Prepare<T> + Copy, T: DeepView,

Available on crate feature alloc only.
Source§

impl<C, Elem> Prepare<[Elem]> for SetOfFmt<C>
where Elem: DeepView, C: SpecCombinator<T = <Elem as DeepView>::V> + Prepare<Elem> + DerOrd<Elem> + Copy,

Source§

impl<C, Elem> Prepare<Vec<Elem>> for SetOfFmt<C>
where Elem: DeepView, C: SpecCombinator<T = <Elem as DeepView>::V> + Prepare<Elem> + DerOrd<Elem> + Copy,

Available on crate feature alloc only.
Source§

impl<C, T> Prepare<&[T]> for BerSequenceOfFmt<C>
where C: SpecCombinator + Prepare<T> + Copy, T: DeepView,

Source§

impl<C, T> Prepare<Vec<T>> for BerSequenceOfFmt<C>
where C: SpecCombinator + Prepare<T> + Copy, T: DeepView,

Available on crate feature alloc only.
Source§

impl<C, T> Prepare<T> for BerSequenceFmt<C>
where T: DeepView + ?Sized, C: SpecCombinator + Prepare<T> + Copy,

Source§

impl<C, T, const LIMIT: usize> Prepare<T> for BerCharStringFmt<C, LIMIT>
where T: DeepView + ?Sized, C: SpecCombinator + Copy + GoodSerializer + SPRoundTrip + Prepare<T>,

Source§

impl<Content, T, const DER: bool> Prepare<T> for ASN1Fmt<Content, DER>
where T: DeepView + ?Sized, Content: SpecCombinator + Prepare<T>,

Source§

impl<F, T> Prepare<T> for ImplicitlyTaggedFmt<F>
where T: DeepView + ?Sized, F: Retaggable + Prepare<T>,

Source§

impl<Field, Default, Rest, R, const DER: bool> Prepare<(Default, R)> for DefaultedFmt<Field, Default, Rest, DER>
where Field: SpecByteLen<T = Default> + Prepare<Default>, Rest: SpecByteLen<T = R::V> + Prepare<R>, Default: DeepView<V = Default> + PartialEq + Structural + Copy, R: DeepView,

Source§

impl<Inner, M, MRev, T> Prepare<T> for Mapped<Inner, BiMap<M, MRev>>
where T: DeepView, M: SpecMap<Input = MRev::Output, Output = T::V>, MRev: SpecMap<Input = T::V> + for<'x> Map<&'x T>, Inner: for<'x> Prepare<<MRev as Map<&'x T>>::O>,

Source§

impl<Inner, N, T> Prepare<[T]> for RepeatN<Inner, N>
where Inner: Prepare<T>, T: DeepView, N: AsLen,

Source§

impl<Inner, T> Prepare<&T> for Ref<Inner>
where T: DeepView + ?Sized, Inner: Prepare<T>,

Source§

impl<Inner, T> Prepare<[T]> for Star<Inner>
where Inner: Prepare<T>, T: DeepView,

Source§

impl<Inner, T> Prepare<T> for Const<Inner, T>
where T: DeepView<V = T> + PartialEq + Structural, Inner: Prepare<T>,

Source§

impl<Inner, T, const N: usize> Prepare<[T; N]> for Array<N, Inner>
where Inner: Prepare<T>, T: DeepView,

Source§

impl<Len, Inner, InnerST> Prepare<InnerST> for ExactLen<Inner, Len>
where Len: AsLen, InnerST: DeepView + ?Sized, Inner: Prepare<InnerST>,

Source§

impl<Len: AsLen> Prepare<[u8]> for Varied<Len>

Source§

impl<Of, TagVal, Tg, T> Prepare<T> for SuffixTagged<Of, Tg, TagVal>
where Tg: SpecByteLen<T = TagVal> + Prepare<TagVal>, TagVal: DeepView<V = TagVal> + PartialEq + Structural + Copy, T: DeepView, Of: Prepare<T>,

Source§

impl<P1, P2, T1, T2> Prepare<(T1, T2)> for Permute2<P1, P2>
where T1: DeepView, T2: DeepView, P1: Prepare<T1>, P2: Prepare<T2>,

Source§

impl<T, Inner> Prepare<T> for Cond<Inner>
where T: DeepView, Inner: Prepare<T>,

Source§

impl<T, Inner> Prepare<T> for Named<Inner>
where T: DeepView, Inner: Prepare<T>,

Source§

impl<T, Spec, Exec> Prepare<T> for FnPrepare<T, Spec, Exec>
where T: DeepView + ?Sized, Spec: SpecByteLen<T = T::V> + Consistency<Val = T::V>, Exec: Fn(&T) -> Result<usize, PreSerializeError>,

Source§

impl<T, const LIMIT: usize> Prepare<T> for BerBitStringFmt<LIMIT>
where T: DeepView<V = BitStringSpec> + ?Sized, ASN1Fmt<BitStringFmt<BER>, BER>: Prepare<T>,

Source§

impl<T, const LIMIT: usize, Body, Param> Prepare<T> for FixWith<LIMIT, Body, Param>
where T: DeepView<V = Body::T>, Param: DeepView<V = Body::Param>, Body: PrepareRecBody<T, EP = Param>,

Source§

impl<Tg, TagVal, Of, T> Prepare<T> for PrefixTagged<Tg, TagVal, Of>
where Tg: SpecByteLen<T = TagVal> + Prepare<TagVal>, TagVal: DeepView<V = TagVal> + PartialEq + Structural + Copy, T: DeepView, Of: Prepare<T>,

Source§

impl<Then, T> Prepare<T> for AndThen<Tail, Then>
where T: DeepView + ?Sized, Then: Prepare<T>,

Source§

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

Source§

impl<const DER: bool> Prepare<usize> for LengthFmt<DER>

Source§

impl<const DER: bool> Prepare<AnyOwned> for AnyFmt<DER>

Available on crate feature alloc only.
Source§

impl<const DER: bool> Prepare<UtcTime> for UtcTimeFmt<DER>

Source§

impl<const DET: bool> Prepare<CborHead> for CborHeadFmt<DET>

Source§

impl<const LIMIT: usize> Prepare<AnyOwned> for BerAnyFmt<LIMIT>

Available on crate feature alloc only.
Source§

impl<const LIMIT: usize> Prepare<Vec<u8>> for BerOctetStringFmt<LIMIT>

Available on crate feature alloc only.
Source§

impl<const LIMIT: usize> Prepare<[u8]> for BerOctetStringFmt<LIMIT>

Source§

impl<const MINIMAL: bool> Prepare<u64> for Base128Fmt<MINIMAL>

Source§

impl<const MINIMAL: bool> Prepare<u64> for VarInt<MINIMAL>

Source§

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

Source§

impl<const N: usize> Prepare<[u8]> for Fixed<N>