config: workspace display order
This commit is contained in:
parent
40328d7c4a
commit
e570152dde
17 changed files with 237 additions and 11 deletions
32
toml-config/src/config/parsers/workspace_display_order.rs
Normal file
32
toml-config/src/config/parsers/workspace_display_order.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use {
|
||||
crate::{
|
||||
config::parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
toml::toml_span::{Span, SpannedExt},
|
||||
},
|
||||
jay_config::workspace::WorkspaceDisplayOrder,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WorkspaceDisplayOrderParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error("Unknown workspace display order {0}")]
|
||||
Unknown(String),
|
||||
}
|
||||
|
||||
pub struct WorkspaceDisplayOrderParser;
|
||||
|
||||
impl Parser for WorkspaceDisplayOrderParser {
|
||||
type Value = WorkspaceDisplayOrder;
|
||||
type Error = WorkspaceDisplayOrderParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::String];
|
||||
|
||||
fn parse_string(&mut self, span: Span, string: &str) -> ParseResult<Self> {
|
||||
match string {
|
||||
"manual" => Ok(WorkspaceDisplayOrder::Manual),
|
||||
"sorted" => Ok(WorkspaceDisplayOrder::Sorted),
|
||||
_ => Err(WorkspaceDisplayOrderParserError::Unknown(string.to_string()).spanned(span)),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue