Add conversions
This commit is contained in:
11
src/ttl.rs
11
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<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),
|
||||
|
||||
Reference in New Issue
Block a user