show bytes as description, implement format bytes trait

This commit is contained in:
yggverse 2025-07-07 15:48:36 +03:00
parent d05b15c7a3
commit f49ed0e11b
5 changed files with 66 additions and 13 deletions

View file

@ -6,16 +6,18 @@ const NAME_MAX_LEN: usize = 125; // + 3 bytes for `...` offset @TODO optional
pub struct Value {
pub time: DateTime<Utc>,
pub node: u64,
/// Isolate by applying internal filter on value set
// Isolate by applying internal filter on value set
length: Option<u64>,
name: Option<String>,
}
impl Value {
/// Create new `Self` with current timestamp
pub fn new(node: u64, name: Option<String>) -> Self {
pub fn new(node: u64, name: Option<String>, length: Option<u64>) -> Self {
Self {
time: Utc::now(),
node,
length,
name: filter_name(name),
}
}
@ -23,6 +25,10 @@ impl Value {
pub fn name(&self) -> Option<&String> {
self.name.as_ref()
}
/// Get reference to the safely constructed `length` member
pub fn length(&self) -> Option<u64> {
self.length
}
}
/// Prevent unexpected memory usage on store values from unknown source