rust_codegen
v0.2.0
Published
This Rust library provides a WebAssembly interface for generating mapping code, YAML files, and schema files from given contract configurations for generation of subgraph code. This library contains a module named `codegen` which is responsible for implem
Downloads
2
Readme
This Rust library provides a WebAssembly interface for generating mapping code, YAML files, and schema files from given contract configurations for generation of subgraph code. This library contains a module named codegen
which is responsible for implementing the functionality. The exposed functions are wrapped using the wasm_bindgen
attribute to be callable from JavaScript.
Functions
generate_mapping(val: JsValue) -> Result<String, String>
This function takes a JavaScript value representing a contract configuration and generates the mapping code. If successful, it returns the generated mapping code as a string. If there's an error, it returns a string describing the error.
Parameters:
val
: (JsValue) A JavaScript value containing the contract configuration.
Returns:
- Result: A result containing the generated mapping code as a string or an error message as a string.
generate_yaml(val: JsValue) -> Result<String, String>
This function takes a JavaScript value representing an array of contract configurations and generates the YAML files. If successful, it returns the generated YAML files as a string. If there's an error, it returns a string describing the error.
Parameters:
val
: (JsValue) A JavaScript value containing the array of contract configurations.
Returns:
- Result: A result containing the generated YAML files as a string or an error message as a string.
generate_schema(val: JsValue) -> Result<String, String>
This function takes a JavaScript value representing an array of contract configurations and generates the schema files. If successful, it returns the generated schema files as a string. If there's an error, it returns a string describing the error.
Parameters:
val
: (JsValue) A JavaScript value containing the array of contract configurations.
Returns:
- Result: A result containing the generated schema files as a string or an error message as a string.
generate_helpers() -> String
This function generates some of the helper functions that we use in the generated code