pub enum CodecDefaultDecode {
Datum,
TermInEvalDatumOtherwise,
}Expand description
A codec’s policy for choosing a DecodeTarget from a DecodePosition.
Data codecs always yield data; eval-aware codecs yield a term in eval position and data otherwise.
Variants§
Datum
Always decode to a Datum, regardless of position.
TermInEvalDatumOtherwise
Decode to a Term in DecodePosition::Eval, otherwise to a Datum.
Implementations§
Source§impl CodecDefaultDecode
impl CodecDefaultDecode
Sourcepub fn target_for(self, position: DecodePosition) -> DecodeTarget
pub fn target_for(self, position: DecodePosition) -> DecodeTarget
Resolve the DecodeTarget for position under this policy.
§Examples
use sim_codec::{CodecDefaultDecode, DecodePosition, DecodeTarget};
let policy = CodecDefaultDecode::TermInEvalDatumOtherwise;
assert_eq!(policy.target_for(DecodePosition::Eval), DecodeTarget::Term);
assert_eq!(policy.target_for(DecodePosition::Data), DecodeTarget::Datum);
// A pure data codec always yields data.
assert_eq!(
CodecDefaultDecode::Datum.target_for(DecodePosition::Eval),
DecodeTarget::Datum,
);Sourcepub fn as_symbol_name(self) -> &'static str
pub fn as_symbol_name(self) -> &'static str
The stable kebab-case name of this policy, for metadata and display.
Trait Implementations§
Source§impl Clone for CodecDefaultDecode
impl Clone for CodecDefaultDecode
Source§fn clone(&self) -> CodecDefaultDecode
fn clone(&self) -> CodecDefaultDecode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CodecDefaultDecode
Source§impl Debug for CodecDefaultDecode
impl Debug for CodecDefaultDecode
impl Eq for CodecDefaultDecode
Source§impl PartialEq for CodecDefaultDecode
impl PartialEq for CodecDefaultDecode
Source§fn eq(&self, other: &CodecDefaultDecode) -> bool
fn eq(&self, other: &CodecDefaultDecode) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CodecDefaultDecode
Auto Trait Implementations§
impl Freeze for CodecDefaultDecode
impl RefUnwindSafe for CodecDefaultDecode
impl Send for CodecDefaultDecode
impl Sync for CodecDefaultDecode
impl Unpin for CodecDefaultDecode
impl UnsafeUnpin for CodecDefaultDecode
impl UnwindSafe for CodecDefaultDecode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more