pub struct HLAextendableVariantRecord { /* private fields */ }Expand description
HLAextendableVariantRecord: a variant record whose encoding states the length of the alternative,
so that a receiver skips alternatives it does not know and other FOM modules can add alternatives.
Decoding a discriminant without association is therefore not an error: the discriminant becomes the
active one, the octets of its alternative are kept in Self::unknown_alternative, and
Self::value fails as the standard APIs prescribe.
The exact layout is described, with its caveat, in the extendable module.
Implementations§
Source§impl HLAextendableVariantRecord
impl HLAextendableVariantRecord
Sourcepub fn set_variant(
&mut self,
discriminant: impl DataElement,
value: impl DataElement,
) -> Result<&mut Self, EncoderError>
pub fn set_variant( &mut self, discriminant: impl DataElement, value: impl DataElement, ) -> Result<&mut Self, EncoderError>
Associates value with discriminant and makes that discriminant the active one.
A previous association of the same discriminant is replaced.
The discriminant must have the datatype of the discriminant prototype.
Sourcepub fn set_empty_variant(
&mut self,
discriminant: impl DataElement,
) -> Result<&mut Self, EncoderError>
pub fn set_empty_variant( &mut self, discriminant: impl DataElement, ) -> Result<&mut Self, EncoderError>
Registers discriminant as an enumerator without alternative data and makes it the
active one.
Sourcepub fn set_discriminant(
&mut self,
discriminant: impl DataElement,
) -> Result<&mut Self, EncoderError>
pub fn set_discriminant( &mut self, discriminant: impl DataElement, ) -> Result<&mut Self, EncoderError>
Makes discriminant the active one. It needs no association yet, but encoding fails
until it has one.
Sourcepub fn discriminant(&self) -> &DynElement
pub fn discriminant(&self) -> &DynElement
The active discriminant.
Sourcepub fn discriminant_as<T: DataElement>(&self) -> Option<&T>
pub fn discriminant_as<T: DataElement>(&self) -> Option<&T>
The active discriminant as a T, if it is one.
Sourcepub fn value_as<T: DataElement>(&self) -> Option<&T>
pub fn value_as<T: DataElement>(&self) -> Option<&T>
The active alternative as a T, if there is one and it is a T.
Sourcepub fn has_variant(&self, discriminant: &DynElement) -> bool
pub fn has_variant(&self, discriminant: &DynElement) -> bool
True if discriminant has been registered with Self::set_variant or
Self::set_empty_variant.
Sourcepub fn variant_count(&self) -> usize
pub fn variant_count(&self) -> usize
Number of registered discriminants.
Source§impl HLAextendableVariantRecord
impl HLAextendableVariantRecord
Sourcepub fn new(discriminant_prototype: impl DataElement) -> Self
pub fn new(discriminant_prototype: impl DataElement) -> Self
A record whose discriminants have the datatype of discriminant_prototype, which is also the
initial active discriminant.
Sourcepub fn value(&self) -> Result<&DynElement, EncoderError>
pub fn value(&self) -> Result<&DynElement, EncoderError>
The alternative of the active discriminant.
Fails with EncoderError::NoVariantForDiscriminant when the active discriminant has no
association or no alternative data.
Sourcepub fn value_mut(&mut self) -> Result<&mut DynElement, EncoderError>
pub fn value_mut(&mut self) -> Result<&mut DynElement, EncoderError>
The alternative of the active discriminant, mutable.
Sourcepub fn unknown_alternative(&self) -> Option<&[u8]>
pub fn unknown_alternative(&self) -> Option<&[u8]>
The octets of the alternative that the last decoding skipped because its discriminant has no
association; None when the last decoded discriminant was a registered one.
Trait Implementations§
Source§impl Clone for HLAextendableVariantRecord
impl Clone for HLAextendableVariantRecord
Source§impl DataElement for HLAextendableVariantRecord
impl DataElement for HLAextendableVariantRecord
Source§fn octet_boundary(&self) -> usize
fn octet_boundary(&self) -> usize
Source§fn encode_into(&self, writer: &mut ByteWriter<'_>) -> Result<(), EncoderError>
fn encode_into(&self, writer: &mut ByteWriter<'_>) -> Result<(), EncoderError>
Source§fn decode_from(
&mut self,
reader: &mut ByteReader<'_>,
) -> Result<(), DecoderError>
fn decode_from( &mut self, reader: &mut ByteReader<'_>, ) -> Result<(), DecoderError>
Source§fn clone_element(&self) -> Box<DynElement>
fn clone_element(&self) -> Box<DynElement>
Source§fn is_same_type_as(&self, other: &DynElement) -> bool
fn is_same_type_as(&self, other: &DynElement) -> bool
other has the same datatype: the same Rust type and, for dynamic containers, the same
structure.Source§fn encoded_length(&self) -> Result<usize, EncoderError>
fn encoded_length(&self) -> Result<usize, EncoderError>
Source§fn to_bytes(&self) -> Result<Vec<u8>, EncoderError>
fn to_bytes(&self) -> Result<Vec<u8>, EncoderError>
Source§fn append_to(&self, buffer: &mut Vec<u8>) -> Result<(), EncoderError>
fn append_to(&self, buffer: &mut Vec<u8>) -> Result<(), EncoderError>
buffer as a new outermost value: padding is computed from the first
appended octet. On error buffer is left unchanged.Source§fn decode_slice(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
fn decode_slice(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
bytes; octets after the value are ignored.Source§fn decode_slice_strict(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
fn decode_slice_strict(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
bytes, which must hold exactly one value.