From 6aa2735a25ccc3ea3eec1554d727b1da69d3c0f0 Mon Sep 17 00:00:00 2001 From: MecryTv Date: Wed, 26 Nov 2025 15:25:04 +0100 Subject: [PATCH 1/2] [ref] Update Readme --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ed438e1..6ec336c 100644 --- a/README.md +++ b/README.md @@ -98,26 +98,69 @@ Crate: [code0-definition-reader](https://crates.io/crates/code0-definition-reade cargo add code0-definition-reader ``` -### Usage +### Basic Usage ```rs use code0_definition_reader::Reader; -let reader = Reader::configure( - String::new(), // Path required for configure - false, // should_break - Vec::new(), // accepted_features - None // accepted_versions -); +fn main() { + // Create a reader with default configuration + let reader = Reader::configure( + "./path/to/definitions".to_string(), // Path to definitions directory + false, // should_break: continue on errors + Vec::new(), // accepted_features: empty = all features + None // accepted_version: None = all versions + ); + + // Read all features + match reader.read_features() { + Ok(features) => { + for feature in features { + println!("Loaded feature: {}", feature.name); + println!(" - Data Types: {}", feature.data_types.len()); + println!(" - Flow Types: {}", feature.flow_types.len()); + println!(" - Functions: {}", feature.functions.len()); + } + } + Err(err) => { + eprintln!("Failed to read features: {:?}", err); + } + } +} +``` + +### Advanced Usage - Filter Specific Features + +```rs +use code0_definition_reader::Reader; -let features = reader.read_features("./path/to/definitions"); +fn main() { + let reader = Reader::configure( + "./definitions".to_string(), + false, + vec!["http".to_string(), "database".to_string()], // Only load http and database features + None + ); -for feature in features { - 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 + let features = reader.read_features().expect("Failed to read features"); - println!("Loaded feature: {}", name); + for feature in features { + println!("Feature: {}", feature.name); + + // Access data types + for data_type in &feature.data_types { + println!(" DataType: {}", data_type.identifier); + } + + // Access flow types + for flow_type in &feature.flow_types { + println!(" FlowType: {}", flow_type.identifier); + } + + // Access runtime functions + for function in &feature.functions { + println!(" Function: {}", function.runtime_name); + } + } } ``` From a4a2612bb9129145cd73ddd05750f0e0091be949 Mon Sep 17 00:00:00 2001 From: MecryTv Date: Wed, 26 Nov 2025 15:26:28 +0100 Subject: [PATCH 2/2] [ref] Update Readme --- README.md | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6ec336c..0b3d48d 100644 --- a/README.md +++ b/README.md @@ -142,24 +142,29 @@ fn main() { None ); - let features = reader.read_features().expect("Failed to read features"); - - for feature in features { - println!("Feature: {}", feature.name); - - // Access data types - for data_type in &feature.data_types { - println!(" DataType: {}", data_type.identifier); - } - - // Access flow types - for flow_type in &feature.flow_types { - println!(" FlowType: {}", flow_type.identifier); + match reader.read_features() { + Ok(features) => { + for feature in features { + println!("Feature: {}", feature.name); + + // Access data types + for data_type in &feature.data_types { + println!(" DataType: {}", data_type.identifier); + } + + // Access flow types + for flow_type in &feature.flow_types { + println!(" FlowType: {}", flow_type.identifier); + } + + // Access runtime functions + for function in &feature.functions { + println!(" Function: {}", function.runtime_name); + } + } } - - // Access runtime functions - for function in &feature.functions { - println!(" Function: {}", function.runtime_name); + Err(err) => { + eprintln!("Failed to read features: {:?}", err); } } }