pub enum Type {
Show 32 variants Unit, Bool, U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, Amount, AccountAddress, ContractAddress, Timestamp, Duration, Pair(Box<Type>, Box<Type>), List(SizeLength, Box<Type>), Set(SizeLength, Box<Type>), Map(SizeLength, Box<Type>, Box<Type>), Array(u32, Box<Type>), Struct(Fields), Enum(Vec<(String, Fields)>), String(SizeLength), ContractName(SizeLength), ReceiveName(SizeLength), ULeb128(u32), ILeb128(u32), ByteList(SizeLength), ByteArray(u32), TaggedEnum(BTreeMap<u8, (String, Fields)>),
}
Expand description

Schema type used to describe the different types in a smart contract, their serialization and how to represent the types in JSON.

Variants§

§

Unit

A type with no serialization.

§

Bool

Boolean. Serialized as a byte, where the value 0 is false and 1 is true.

§

U8

Unsigned 8-bit integer.

§

U16

Unsigned 16-bit integer. Serialized as little endian.

§

U32

Unsigned 32-bit integer. Serialized as little endian.

§

U64

Unsigned 64-bit integer. Serialized as little endian.

§

U128

Unsigned 128-bit integer. Serialized as little endian.

§

I8

Signed 8-bit integer. Serialized as little endian.

§

I16

Signed 16-bit integer. Serialized as little endian.

§

I32

Signed 32-bit integer. Serialized as little endian.

§

I64

Signed 64-bit integer. Serialized as little endian.

§

I128

Signed 128-bit integer. Serialized as little endian.

§

Amount

An amount of CCD. Serialized as 64-bit unsigned integer little endian.

§

AccountAddress

An account address.

§

ContractAddress

A contract address.

§

Timestamp

A timestamp. Represented as milliseconds since Unix epoch. Serialized as a 64-bit unsigned integer little endian.

§

Duration

A duration of milliseconds, cannot be negative. Serialized as a 64-bit unsigned integer little endian.

§

Pair(Box<Type>, Box<Type>)

A pair.

§

List(SizeLength, Box<Type>)

A list. It is serialized with the length first followed by the list items.

§

Set(SizeLength, Box<Type>)

A Set. It is serialized with the length first followed by the list items.

§

Map(SizeLength, Box<Type>, Box<Type>)

A Map. It is serialized with the length first followed by key-value pairs of the entries.

§

Array(u32, Box<Type>)

A fixed sized list.

§

Struct(Fields)

A structure type with fields.

§

Enum(Vec<(String, Fields)>)

A sum type.

§

String(SizeLength)

A UTF8 String. It is serialized with the length first followed by the encoding of the string.

§

ContractName(SizeLength)

A smart contract name. It is serialized with the length first followed by the ASCII encoding of the name.

§

ReceiveName(SizeLength)

A smart contract receive function name. It is serialized with the length first followed by the ASCII encoding of the name.

§

ULeb128(u32)

An unsigned integer encoded using LEB128 with the addition of a constraint on the maximum number of bytes to use for an encoding.

§

ILeb128(u32)

A signed integer encoded using LEB128 with the addition of a constraint on the maximum number of bytes to use for an encoding.

§

ByteList(SizeLength)

A list of bytes. It is serialized with the length first followed by the bytes.

§

ByteArray(u32)

A fixed sized list of bytes.

§

TaggedEnum(BTreeMap<u8, (String, Fields)>)

An enum with a tag.

Trait Implementations§

source§

impl Clone for Type

source§

fn clone(&self) -> Type

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Type

source§

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

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

impl Deserial for Type

source§

fn deserial<R>(source: &mut R) -> Result<Type, ParseError>
where R: Read,

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

impl PartialEq for Type

source§

fn eq(&self, other: &Type) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serial for Type

source§

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

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

impl Eq for Type

source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

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> Deletable for T
where T: Serialize,

source§

fn delete(self)

Delete all items that this type owns in the state.
source§

impl<D, S> DeserialWithState<S> for D
where D: Deserial, S: HasStateApi,

source§

fn deserial_with_state<R>(_state: &S, source: &mut R) -> Result<D, ParseError>
where R: Read,

Attempt to read a structure from a given source and state, failing if an error occurs during deserialization or reading.
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> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<A> Serialize for A
where A: Deserial + Serial,