pub struct DCSwitch {
name: Option<String>,
key: DCField,
cases: Vec<SwitchCase>,
default_case: Option<SwitchCase>,
cases_by_value: HashMap<Vec<u8>, usize>,
}Expand description
Represents a DC Switch statement, which can appear inside a dclass declaration and represents two or more alternative unpacking schemes based on the first field read.
Fields§
§name: Option<String>§key: DCField§cases: Vec<SwitchCase>§default_case: Option<SwitchCase>§cases_by_value: HashMap<Vec<u8>, usize>Implementations§
Source§impl DCSwitch
impl DCSwitch
Sourcepub fn get_key_parameter(&self) -> &DCField
pub fn get_key_parameter(&self) -> &DCField
Returns the key parameter on which the switch is based.
The value of this parameter in the record determines which one of the several cases within the switch will be used.
Sourcepub fn get_num_cases(&self) -> usize
pub fn get_num_cases(&self) -> usize
Returns the number of different cases within the switch.
The legal values for case_index range from 0 to n_cases - 1.
Sourcepub fn get_case(&self, index: usize) -> Option<&SwitchCase>
pub fn get_case(&self, index: usize) -> Option<&SwitchCase>
Returns case reference from given index wrapped in an Option.
Sourcepub fn get_default_case(&self) -> Option<&SwitchCase>
pub fn get_default_case(&self) -> Option<&SwitchCase>
Returns default case reference wrapped in an Option.
A default case is optional, so None can be returned.
Sourcepub fn get_case_index_by_value(&self, value: Vec<u8>) -> Option<usize>
pub fn get_case_index_by_value(&self, value: Vec<u8>) -> Option<usize>
Returns the index of the case with the given packed value.
None is returned if no case with that value is found.
pub fn apply_switch(&self, _value: Vec<u8>, _length: usize)
Trait Implementations§
Source§impl LegacyDCHash for DCSwitch
impl LegacyDCHash for DCSwitch
Source§fn generate_hash(&self, hashgen: &mut DCHashGenerator)
fn generate_hash(&self, hashgen: &mut DCHashGenerator)
Accumulates the properties of this DC element into the file hash.
Auto Trait Implementations§
impl Freeze for DCSwitch
impl RefUnwindSafe for DCSwitch
impl Send for DCSwitch
impl Sync for DCSwitch
impl Unpin for DCSwitch
impl UnwindSafe for DCSwitch
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