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§
Sourcefn basic_translate(
&self,
num_bits: u32,
value: &VariableValue,
) -> (String, ValueKind)
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§
Sourcefn basic_translate_numeric(
&self,
num_bits: u32,
value: &VariableValue,
) -> Option<f64>
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.
Sourcefn translates(
&self,
variable: &VariableMeta<VarId, ScopeId>,
) -> Result<TranslationPreference>
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.
Sourcefn variable_info(
&self,
_variable: &VariableMeta<VarId, ScopeId>,
) -> Result<VariableInfo>
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.