Skip to main content

VersionedModuleSchema

Enum VersionedModuleSchema 

Source
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

Source

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.

Source

pub fn from_base64_str(s: &str) -> Result<Self, VersionedSchemaError>

Get a versioned module schema from a base64 string.

Source

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

Source

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

Source

pub fn get_event_schema( &self, contract_name: &str, ) -> Result<Type, VersionedSchemaError>

Source

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

Source

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

Source

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

Source§

fn clone(&self) -> VersionedModuleSchema

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VersionedModuleSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserial for VersionedModuleSchema

Source§

fn deserial<R: Read>(source: &mut R) -> ParseResult<Self>

Attempt to read a structure from a given source, failing if an error occurs during deserialization or reading.
Source§

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));
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serial for VersionedModuleSchema

Source§

fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err>

Attempt to write the structure into the provided writer, failing if only part of the structure could be written. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<A> Serialize for A
where A: Deserial + Serial,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more