using unified system
This commit is contained in:
36
komp-app/src/navigation.rs
Normal file
36
komp-app/src/navigation.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use common::proto::komp_ac::tables_data::RowNavigationMode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum UnfilteredNavigationMode {
|
||||
Position,
|
||||
#[default]
|
||||
Id,
|
||||
}
|
||||
|
||||
impl UnfilteredNavigationMode {
|
||||
pub fn parse(value: &str) -> Option<Self> {
|
||||
match value {
|
||||
"id" => Some(Self::Id),
|
||||
"position" => Some(Self::Position),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Id => "id",
|
||||
Self::Position => "position",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UnfilteredNavigationMode> for RowNavigationMode {
|
||||
fn from(value: UnfilteredNavigationMode) -> Self {
|
||||
match value {
|
||||
UnfilteredNavigationMode::Id => Self::Id,
|
||||
UnfilteredNavigationMode::Position => Self::Position,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user