pub trait SpecMapper {
type In;
type Out;
// Required methods
spec fn spec_map(&self, i: Self::In) -> Self::Out;
spec fn spec_map_rev(&self, o: Self::Out) -> Self::In;
// Provided methods
open spec fn wf_in(&self, i: Self::In) -> bool { ... }
fn wf_out(&self, o: Self::Out) -> bool { ... }
}Expand description
A bidirectional mapping between two types (forward for parsing, reverse for
serialization). For roundtrip guarantees, implement and prove
LossyMapper or LosslessMapper as appropriate.
Required Associated Types§
Required Methods§
Sourcespec fn spec_map_rev(&self, o: Self::Out) -> Self::In
spec fn spec_map_rev(&self, o: Self::Out) -> Self::In
Reverse mapping (used during serialization).
Provided Methods§
Sourceopen spec fn wf_in(&self, i: Self::In) -> bool
open spec fn wf_in(&self, i: Self::In) -> bool
{ true }Optional refinement predicates on the input type.
This is the precondition for LosslessMapper::lemma_lossless_mapper.
Sourceopen spec fn wf_out(&self, o: Self::Out) -> bool
open spec fn wf_out(&self, o: Self::Out) -> bool
{ true }Optional refinement predicates on the output type.
This is the precondition for LossyMapper::lemma_sound_mapper.