diff --git a/src/lib.rs b/src/lib.rs index cadc958..7a55cb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -274,7 +274,7 @@ fn parse_to_table(input: &str) -> std::string::String { }; table.add_row(row![ - format!("({}{:}", record.data, value_information), + format!("({}{}", record.data, value_information), format!("{}", data_information) ]); } diff --git a/src/user_data/data_information.rs b/src/user_data/data_information.rs index a8a3878..e041b69 100644 --- a/src/user_data/data_information.rs +++ b/src/user_data/data_information.rs @@ -252,6 +252,16 @@ impl PartialEq for TextUnit<'_> { self.0.iter().eq(other.as_bytes().iter().rev()) } } + +#[cfg(feature = "std")] +impl std::fmt::Display for TextUnit<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let value: Vec = self.0.iter().copied().rev().collect(); + let value = String::from_utf8(value).unwrap_or_default(); + write!(f, "{}", value) + } +} + #[cfg(any(feature = "serde", feature = "std"))] impl From> for String { fn from(value: TextUnit<'_>) -> Self { @@ -366,10 +376,6 @@ impl std::fmt::Display for Data<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.value { Some(value) => match value { - &DataType::Text(text) => { - let text: String = text.into(); - write!(f, "{}", text) - } DataType::Number(value) => write!(f, "{}", value), DataType::Date(day, month, year) => write!(f, "{}/{}/{}", day, month, year), DataType::DateTime(day, month, year, hour, minute) => { @@ -385,7 +391,10 @@ impl std::fmt::Display for Data<'_> { DataType::Time(seconds, minutes, hours) => { write!(f, "{}:{}:{}", hours, minutes, seconds) } - DataType::Text(text_unit) => todo!(), + DataType::Text(text_unit) => { + let text: String = (*text_unit).into(); + write!(f, "{}", text) + } DataType::ManufacturerSpecific(data) => { write!(f, "Manufacturer Specific: {:?}", data) }