-
Notifications
You must be signed in to change notification settings - Fork 0
Definition Reader #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1e80d2
8f6bdd9
cae5b07
f31cb1b
330f066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use std::io; | ||
| use std::path::PathBuf; | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum ReaderError { | ||
| JsonError { | ||
| path: PathBuf, | ||
| error: serde_json::Error, | ||
| }, | ||
| ReadFeatureError { | ||
| path: String, | ||
| source: Box<ReaderError>, | ||
| }, | ||
| ReadDirectoryError { | ||
| path: PathBuf, | ||
| error: io::Error, | ||
| }, | ||
| ReadFileError { | ||
| path: PathBuf, | ||
| error: io::Error, | ||
| }, | ||
| DirectoryEntryError(io::Error), | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||||
| pub mod version; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| use serde::Deserialize; | ||||||||||||||||||||||||||||||||||||||||||
| use tucana::shared::{DefinitionDataType, FlowType, RuntimeFunctionDefinition}; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| #[derive(Deserialize, Debug, Clone)] | ||||||||||||||||||||||||||||||||||||||||||
| pub struct Feature { | ||||||||||||||||||||||||||||||||||||||||||
| pub name: String, | ||||||||||||||||||||||||||||||||||||||||||
| pub data_types: Vec<DefinitionDataType>, | ||||||||||||||||||||||||||||||||||||||||||
| pub flow_types: Vec<FlowType>, | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+10
|
||||||||||||||||||||||||||||||||||||||||||
| #[derive(Deserialize, Debug, Clone)] | |
| pub struct Feature { | |
| pub name: String, | |
| pub data_types: Vec<DefinitionDataType>, | |
| pub flow_types: Vec<FlowType>, | |
| /// Represents a feature containing related flow definitions. | |
| /// | |
| /// A feature groups together data types, flow types, and runtime function | |
| /// definitions that belong to the same logical feature or module. | |
| #[derive(Deserialize, Debug, Clone)] | |
| pub struct Feature { | |
| /// The name of the feature. | |
| pub name: String, | |
| /// Data type definitions associated with this feature. | |
| pub data_types: Vec<DefinitionDataType>, | |
| /// Flow type definitions associated with this feature. | |
| pub flow_types: Vec<FlowType>, | |
| /// Runtime function definitions associated with this feature. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| use tucana::shared::{DefinitionDataType, FlowType, RuntimeFunctionDefinition, Version}; | ||
|
|
||
| pub trait HasVersion { | ||
| fn version(&self) -> &Option<Version>; | ||
| fn version_mut(&mut self) -> &mut Option<Version>; | ||
|
|
||
| fn normalize_version(&mut self) { | ||
| self.version_mut().get_or_insert(Version { | ||
| major: 0, | ||
| minor: 0, | ||
| patch: 0, | ||
| }); | ||
| } | ||
|
|
||
| fn is_accepted(&self, filter: &Option<Version>) -> bool { | ||
| filter | ||
| .as_ref() | ||
| .is_none_or(|v| self.version().as_ref() == Some(v)) | ||
raphael-goetz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
Comment on lines
+3
to
+20
|
||
|
|
||
| impl HasVersion for DefinitionDataType { | ||
| fn version(&self) -> &Option<Version> { | ||
| &self.version | ||
| } | ||
|
|
||
| fn version_mut(&mut self) -> &mut Option<Version> { | ||
| &mut self.version | ||
| } | ||
| } | ||
|
|
||
| impl HasVersion for FlowType { | ||
| fn version(&self) -> &Option<Version> { | ||
| &self.version | ||
| } | ||
|
|
||
| fn version_mut(&mut self) -> &mut Option<Version> { | ||
| &mut self.version | ||
| } | ||
| } | ||
|
|
||
| impl HasVersion for RuntimeFunctionDefinition { | ||
| fn version(&self) -> &Option<Version> { | ||
| &self.version | ||
| } | ||
|
|
||
| fn version_mut(&mut self) -> &mut Option<Version> { | ||
| &mut self.version | ||
| } | ||
| } | ||
|
Comment on lines
+3
to
+50
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ReaderErrorenum lacks documentation. Error types should be documented to help users understand when each error occurs: