-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] update README.md Rust Definition Package #141
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,7 +90,9 @@ for (const feature in features) { | |
| ``` | ||
|
|
||
| ## Rust Definition Package | ||
|
|
||
| This package is a Rust crate designed to read and parse CodeZero definition files (JSON) from a directory structure. It loads all features, including data-types, flow-types, and runtime-functions, providing them as idiomatic Rust structs. | ||
| ### Package Resources | ||
| Crate: [code0-definition-reader](https://crates.io/crates/code0-definition-reader) on crates.io | ||
| ### Install Package | ||
| ```bash | ||
| cargo add code0-definition-reader | ||
|
|
@@ -99,14 +101,23 @@ cargo add code0-definition-reader | |
| ### Usage | ||
|
|
||
| ```rs | ||
| use code0_definition_reader::Definition; | ||
| use code0_definition_reader::Reader; | ||
|
|
||
| let reader = Reader::configure( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Give examples and describe further what each parameter does! |
||
| String::new(), // Path required for configure | ||
| false, // should_break | ||
| Vec::new(), // accepted_features | ||
| None // accepted_versions | ||
| ); | ||
|
|
||
| let features = Definition::new("./path/to/definitions"); | ||
| let features = reader.read_features("./path/to/definitions"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might overlooked this in the implementation of the reader but you have already given the reader the path with the constructor. Why then providing the path again if you have already access to the path with |
||
|
|
||
| for feature in features { | ||
| let name = feature.name(); //name of the feature (e.g. rest) | ||
| let data_types = feature.data_types(); //dataTypes of this feature | ||
| let flow_types = feature.flow_types(); //flowTypes of this feature | ||
| let functions = feature.runtime_functions(); //runtimeFunctions of this feature | ||
| let name = &feature.name; // name of the feature (e.g., http) | ||
| let data_types = &feature.data_types; // dataTypes of this feature | ||
| let flow_types = &feature.flow_types; // flowTypes of this feature | ||
| let functions = &feature.functions; // runtimeFunctions of this feature | ||
|
|
||
| println!("Loaded feature: {}", name); | ||
| } | ||
| ``` | ||
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.
Please describe the expected project structure!