Skip to main content

BasicTranslator

Trait BasicTranslator 

Source
pub trait BasicTranslator<VarId, ScopeId>: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn basic_translate(
        &self,
        num_bits: u32,
        value: &VariableValue,
    ) -> (String, ValueKind);

    // Provided methods
    fn basic_translate_numeric(
        &self,
        num_bits: u32,
        value: &VariableValue,
    ) -> Option<f64> { ... }
    fn translates(
        &self,
        variable: &VariableMeta<VarId, ScopeId>,
    ) -> Result<TranslationPreference> { ... }
    fn variable_info(
        &self,
        _variable: &VariableMeta<VarId, ScopeId>,
    ) -> Result<VariableInfo> { ... }
}
Expand description

A translator that only produces non-hierarchical values

Required Methods§

Source

fn name(&self) -> String

Name of the translator to be shown in the UI

Source

fn basic_translate( &self, num_bits: u32, value: &VariableValue, ) -> (String, ValueKind)

Translate the specified variable value into a human-readable form.

If the translator require VariableMeta information to perform the translation, use the more general Translator instead.

Provided Methods§

Source

fn basic_translate_numeric( &self, num_bits: u32, value: &VariableValue, ) -> Option<f64>

Translate a variable value to a numeric f64 for analog rendering.

Returns NAN_UNDEF for undefined values and NAN_HIGHIMP for high-impedance. The default implementation calls Self::basic_translate and parses the result. Translators that produce numeric output should override this for efficient analog signal rendering without string round-trip.

Source

fn translates( &self, variable: &VariableMeta<VarId, ScopeId>, ) -> Result<TranslationPreference>

Return TranslationPreference based on if the translator can handle this variable.

If this is not implemented, it will default to accepting all bit-vector types.

Source

fn variable_info( &self, _variable: &VariableMeta<VarId, ScopeId>, ) -> Result<VariableInfo>

Return information about the structure of a variable, see VariableInfo.

If this is not implemented, it will default to VariableInfo::Bits.

Implementors§