Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

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!

### Package Resources
Crate: [code0-definition-reader](https://crates.io/crates/code0-definition-reader) on crates.io
### Install Package
```bash
cargo add code0-definition-reader
Expand All @@ -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(
Copy link
Member

Choose a reason for hiding this comment

The 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");
Copy link
Member

Choose a reason for hiding this comment

The 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 self.path?


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);
}
```