@@ -98,26 +98,74 @@ Crate: [code0-definition-reader](https://crates.io/crates/code0-definition-reade
9898cargo add code0-definition-reader
9999```
100100
101- ### Usage
101+ ### Basic Usage
102+
103+ ``` rs
104+ use code0_definition_reader :: Reader ;
105+
106+ fn main () {
107+ // Create a reader with default configuration
108+ let reader = Reader :: configure (
109+ " ./path/to/definitions" . to_string (), // Path to definitions directory
110+ false , // should_break: continue on errors
111+ Vec :: new (), // accepted_features: empty = all features
112+ None // accepted_version: None = all versions
113+ );
114+
115+ // Read all features
116+ match reader . read_features () {
117+ Ok (features ) => {
118+ for feature in features {
119+ println! (" Loaded feature: {}" , feature . name);
120+ println! (" - Data Types: {}" , feature . data_types. len ());
121+ println! (" - Flow Types: {}" , feature . flow_types. len ());
122+ println! (" - Functions: {}" , feature . functions. len ());
123+ }
124+ }
125+ Err (err ) => {
126+ eprintln! (" Failed to read features: {:?}" , err );
127+ }
128+ }
129+ }
130+ ```
131+
132+ ### Advanced Usage - Filter Specific Features
102133
103134``` rs
104135use code0_definition_reader :: Reader ;
105136
106- let reader = Reader :: configure (
107- String :: new (), // Path required for configure
108- false , // should_break
109- Vec :: new (), // accepted_features
110- None // accepted_versions
111- );
112-
113- let features = reader . read_features (" ./path/to/definitions" );
114-
115- for feature in features {
116- let name = & feature . name; // name of the feature (e.g., http)
117- let data_types = & feature . data_types; // dataTypes of this feature
118- let flow_types = & feature . flow_types; // flowTypes of this feature
119- let functions = & feature . functions; // runtimeFunctions of this feature
120-
121- println! (" Loaded feature: {}" , name );
137+ fn main () {
138+ let reader = Reader :: configure (
139+ " ./definitions" . to_string (),
140+ false ,
141+ vec! [" http" . to_string (), " database" . to_string ()], // Only load http and database features
142+ None
143+ );
144+
145+ match reader . read_features () {
146+ Ok (features ) => {
147+ for feature in features {
148+ println! (" Feature: {}" , feature . name);
149+
150+ // Access data types
151+ for data_type in & feature . data_types {
152+ println! (" DataType: {}" , data_type . identifier);
153+ }
154+
155+ // Access flow types
156+ for flow_type in & feature . flow_types {
157+ println! (" FlowType: {}" , flow_type . identifier);
158+ }
159+
160+ // Access runtime functions
161+ for function in & feature . functions {
162+ println! (" Function: {}" , function . runtime_name);
163+ }
164+ }
165+ }
166+ Err (err ) => {
167+ eprintln! (" Failed to read features: {:?}" , err );
168+ }
169+ }
122170}
123171```
0 commit comments