pub enum VersionedModuleSchema {
V0(ModuleV0),
V1(ModuleV1),
V2(ModuleV2),
V3(ModuleV3),
}Expand description
Represents the different schema versions.
The serialization of this type includes the versioning information. The serialization of this is always prefixed with two 255u8 in order to distinguish this versioned schema from the unversioned.
When embedded into a smart contract module, name the custom section
concordium-schema.
Variants§
V0(ModuleV0)
Version 0 schema, only supported by V0 smart contracts.
V1(ModuleV1)
Version 1 schema, only supported by V1 smart contracts.
V2(ModuleV2)
Version 2 schema, only supported by V1 smart contracts.
V3(ModuleV3)
Version 3 schema, only supported by V1 smart contracts.
Implementations§
Source§impl VersionedModuleSchema
impl VersionedModuleSchema
Sourcepub fn new(
schema_bytes: &[u8],
schema_version: &Option<u8>,
) -> Result<Self, VersionedSchemaError>
pub fn new( schema_bytes: &[u8], schema_version: &Option<u8>, ) -> Result<Self, VersionedSchemaError>
Get a versioned module schema. First reads header to see if the version can be discerned, otherwise tries using provided schema_version.
Sourcepub fn from_base64_str(s: &str) -> Result<Self, VersionedSchemaError>
pub fn from_base64_str(s: &str) -> Result<Self, VersionedSchemaError>
Get a versioned module schema from a base64 string.
Sourcepub fn get_receive_param_schema(
&self,
contract_name: &str,
function_name: &str,
) -> Result<Type, VersionedSchemaError>
pub fn get_receive_param_schema( &self, contract_name: &str, function_name: &str, ) -> Result<Type, VersionedSchemaError>
Returns a receive function’s parameter schema from a versioned module schema
Sourcepub fn get_init_param_schema(
&self,
contract_name: &str,
) -> Result<Type, VersionedSchemaError>
pub fn get_init_param_schema( &self, contract_name: &str, ) -> Result<Type, VersionedSchemaError>
Returns an init function’s parameter schema from a versioned module schema
pub fn get_event_schema( &self, contract_name: &str, ) -> Result<Type, VersionedSchemaError>
Sourcepub fn get_receive_error_schema(
&self,
contract_name: &str,
function_name: &str,
) -> Result<Type, VersionedSchemaError>
pub fn get_receive_error_schema( &self, contract_name: &str, function_name: &str, ) -> Result<Type, VersionedSchemaError>
Returns a receive function’s error schema from a versioned module schema
Sourcepub fn get_init_error_schema(
&self,
contract_name: &str,
) -> Result<Type, VersionedSchemaError>
pub fn get_init_error_schema( &self, contract_name: &str, ) -> Result<Type, VersionedSchemaError>
Returns an init function’s error schema from a versioned module schema
Sourcepub fn get_receive_return_value_schema(
&self,
contract_name: &str,
function_name: &str,
) -> Result<Type, VersionedSchemaError>
pub fn get_receive_return_value_schema( &self, contract_name: &str, function_name: &str, ) -> Result<Type, VersionedSchemaError>
Returns the return value schema from a versioned module schema.
Trait Implementations§
Source§impl Clone for VersionedModuleSchema
impl Clone for VersionedModuleSchema
Source§fn clone(&self) -> VersionedModuleSchema
fn clone(&self) -> VersionedModuleSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VersionedModuleSchema
impl Debug for VersionedModuleSchema
Source§impl Deserial for VersionedModuleSchema
impl Deserial for VersionedModuleSchema
Source§impl Display for VersionedModuleSchema
Displays a pretty-printed template of the VersionedModuleSchema.
impl Display for VersionedModuleSchema
Displays a pretty-printed template of the VersionedModuleSchema.
§Examples
§Display a template of the VersionedModuleSchema
let mut receive_function_map = BTreeMap::new();
receive_function_map.insert(String::from("MyFunction"), FunctionV2 {
parameter: Some(Type::AccountAddress),
error: Some(Type::AccountAddress),
return_value: Some(Type::AccountAddress),
});
let mut map = BTreeMap::new();
map.insert(String::from("MyContract"), ContractV3 {
init: Some(FunctionV2 {
parameter: Some(Type::AccountAddress),
error: Some(Type::AccountAddress),
return_value: Some(Type::AccountAddress),
}),
receive: receive_function_map,
event: Some(Type::AccountAddress),
});
let schema = VersionedModuleSchema::V3(ModuleV3 {
contracts: map,
});
let display = "Contract: MyContract
Init:
Parameter:
\"<AccountAddress>\"
Error:
\"<AccountAddress>\"
Return value:
\"<AccountAddress>\"
Methods:
- \"MyFunction\"
Parameter:
\"<AccountAddress>\"
Error:
\"<AccountAddress>\"
Return value:
\"<AccountAddress>\"
Event:
\"<AccountAddress>\"\n";
assert_eq!(display, format!("{}", schema));