Add conversions

This commit is contained in:
Dominik Werder
2025-03-18 14:51:51 +01:00
parent 360faea1ae
commit be2f99a96f

View File

@@ -67,7 +67,7 @@ impl RetentionTime {
self.ttl_events_d0()
}
pub fn index_db_i32(&self) -> i32 {
pub fn to_index_db_i32(&self) -> i32 {
match self {
RetentionTime::Short => 2,
RetentionTime::Medium => 4,
@@ -75,6 +75,15 @@ impl RetentionTime {
}
}
pub fn from_index_db_u16(x: u16) -> Result<Self, Error> {
match x {
2 => Ok(Self::Short),
4 => Ok(Self::Medium),
12 => Ok(Self::Long),
_ => Err(Error::Parse),
}
}
pub fn from_str(x: &str) -> Result<Self, Error> {
match x {
"short" => Ok(Self::Short),