diff --git a/src/ttl.rs b/src/ttl.rs index a564e19..cba260f 100644 --- a/src/ttl.rs +++ b/src/ttl.rs @@ -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 { + match x { + 2 => Ok(Self::Short), + 4 => Ok(Self::Medium), + 12 => Ok(Self::Long), + _ => Err(Error::Parse), + } + } + pub fn from_str(x: &str) -> Result { match x { "short" => Ok(Self::Short),