-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c4b2b7
commit ad4fc90
Showing
7 changed files
with
142 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
pub mod get_node_by_path; | ||
#[cfg(feature = "storage")] | ||
pub mod storage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![cfg(feature = "storage")] | ||
|
||
use crate::Node; | ||
use std::path::Path; | ||
|
||
pub enum StorageError { | ||
Io(std::io::Error), | ||
Json(serde_json::Error), | ||
} | ||
|
||
pub fn get_node_by_path(path: impl AsRef<Path>) -> Result<Node, StorageError> { | ||
let json_file_path = path.as_ref().join("info.json"); | ||
let json_file_content = std::fs::read_to_string(json_file_path).map_err(StorageError::Io)?; | ||
serde_json::from_str::<Node>(json_file_content.as_str()).map_err(StorageError::Json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#[cfg(feature = "const")] | ||
mod _auto_generated; | ||
mod api; | ||
mod node; | ||
|
||
pub use api::get_node_by_path::get_node_by_path; | ||
#[cfg(feature = "storage")] | ||
pub use api::storage::StorageError; | ||
pub use node::model::{Node, NodeName, NodeTerms, NodeType}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters