pub struct Register {
pub unit: Unit,
pub scaler: i8,
pub value: i64,
}Expand description
One register of a TupelEntry: value × 10^scaler in unit, as on the wire
(Unsigned8, Integer8, Integer64).
Fields§
§unit: UnitThe unit.
scaler: i8The decimal exponent.
value: i64The raw value.
Implementations§
Source§impl Register
impl Register
Sourcepub const fn quantity(self) -> Quantity
pub const fn quantity(self) -> Quantity
The register as an exact Quantity.
Examples found in repository?
examples/decode.rs (line 301)
282fn tree(t: &sml_kit::Tree<'_>, depth: usize) {
283 let name = Obis::from_bytes(t.name).map_or_else(
284 |_| hex(t.name),
285 |o| format!("{o}{}", o.name().map(|n| format!(" ({n})")).unwrap_or_default()),
286 );
287 let value = match t.value {
288 None => String::new(),
289 Some(sml_kit::ProcParValue::Value(SmlValue::Bytes(b))) => format!("= {}", text(b)),
290 Some(sml_kit::ProcParValue::Value(v)) => format!("= {v:?}"),
291 Some(sml_kit::ProcParValue::Entry(e)) => format!(
292 "= {}{}",
293 e.quantity().map_or_else(|| format!("{:?}", e.value), |q| q.to_string()),
294 if e.value_signature.is_some() { " (signed, not verified)" } else { "" }
295 ),
296 Some(sml_kit::ProcParValue::Period(p)) => {
297 format!("= {}", p.quantity().map_or_else(|| format!("{:?}", p.value), |q| q.to_string()))
298 }
299 Some(sml_kit::ProcParValue::Time(t)) => format!("= {t}"),
300 Some(sml_kit::ProcParValue::Tupel(t)) => {
301 format!("= A+ {} A- {}", t.a_plus.quantity(), t.a_minus.quantity())
302 }
303 };
304 println!("{:indent$}{name} {value}", "", indent = 2 * depth + 1);
305 for child in t.children.into_iter().flatten() {
306 match child {
307 Ok(c) => tree(&c, depth + 1),
308 Err(e) => eprintln!("{:indent$}child error: {e}", "", indent = 2 * depth + 3),
309 }
310 }
311}Trait Implementations§
impl Copy for Register
impl Eq for Register
impl StructuralPartialEq for Register
Auto Trait Implementations§
impl Forget for Register
impl Freeze for Register
impl Move for Register
impl RefUnwindSafe for Register
impl Send for Register
impl Sync for Register
impl Unpin for Register
impl UnsafeUnpin for Register
impl UnwindSafe for Register
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