Crate rain_metadata
source ·Expand description
§Rain Metadata Tooling
A library that provides all the toolings and utilities in order to work with RainLanguage metadata. Dotrain LSP/compiler, Rain Orderbook, etc are a few examples to mention that use this library under the hood.
Also provides CLI app (executable binary) to generate desireable Rain cbor encoded metadata based on Metadata Specs which for example is used in Rain deployment CI.
§Features
cli and json-schema features are default however, in most cases non of the features are needed for using the lib
crate, so they can be disabled by using default-features = false, just be aware that cli feature is required for
building the binary.
cli: A clap based CLI app module for functionalities of this library, this feature has tokio dependency with features enabled that are compatible forwasmfamily target builds, Enabling this feature will also enablejson-schemafeature. This feature is required for building the binary crate.json-schema: Enables implementation of Json Schema for different types of Rain meta.tokio-full: Installs tokio with full features which is a dependency ofclifeature, this allows for multi-threading of the CLI app (binary), however it results in erroneous builds forwasmtarget family as explained in tokio docs.this feature is only effective for binary crate and using it for lib crate just installs a tokio with full feature as a dependency as the entire lib crate doesn’t depend on tokio. This is because tokio is only used as a runtime for binray crate.
§Example
ⓘ
use rain_meta::{*, types::authoring::v1::AuthoringMeta};
let authoring_meta_content = r#"[
{
"word": "stack",
"description": "Copies an existing value from the stack.",
"operandParserOffset": 16
},
{
"word": "constant",
"description": "Copies a constant value onto the stack.",
"operandParserOffset": 16
}
]"#;
let authoring_meta: AuthoringMeta = serde_json::from_str(authoring_meta_content).unwrap();
// abi encode the authoring meta with performing validation
let authoring_meta_abi_encoded = authoring_meta.abi_encode_validate().unwrap();
// Constructing a RainMeta item (cbor map)
let meta_map = RainMetaDocumentV1Item {
payload: serde_bytes::ByteBuf::from(authoring_meta_abi_encoded),
magic: KnownMagic::AuthoringMetaV1,
content_type: ContentType::Cbor,
content_encoding: ContentEncoding::None,
content_language: ContentLanguage::None,
};
// cbor encode the meta item
let cbor_encoded = meta_map.cbor_encode().unwrap();
// decode the data back
let cbor_decoded_vec = RainMetaDocumentV1Item::cbor_decode(&cbor_encoded).unwrap();
// unpack the payload into AuthoringMeta
let unpacked_payload: AuthoringMeta = cbor_decoded_vec[0].clone().unpack_into().unwrap();Modules§
- Represents a clap based CLI app module
- All the known different Rain meta types and implementations
Structs§
- An iterator over the variants of Self
- An iterator over the variants of Self
- An iterator over the variants of Self
- response data struct for an ExpressionDeployer
- An iterator over the variants of Self
- An iterator over the variants of Self
- All known subgraph endpoints
- response data struct for a meta
- All required NPE2 ExpressionDeployer data for reproducing it on a local evm
- Rain Meta Document v1 Item (meta map)
- Meta Storage(CAS)
Enums§
- Represent section of a solidity artifact to extract
- Content encoding of a cbor meta map
- Content language of a cbor meta map
- Content type of a cbor meta map
- Covers all errors variants of Rain Metadat lib functionalities
- All known Rain magic numbers
- All known meta identifiers
Functions§
- converts bytes32 to string
- extracts the given section of a solidity artifact as Value
- searches for a meta matching the given hash in given subgraphs urls
- searches for an ExpressionDeployer matching the given hash in given subgraphs urls
- converts string to bytes32