pub enum Type {
Show 31 variants Unit, Bool, U8, U16, U32, U64, U128, I8, I16, I32, I64, I128, Amount, AccountAddress, ContractAddress, Timestamp, Duration, Pair(Box<Type, Global>, Box<Type, Global>), List(SizeLengthBox<Type, Global>), Set(SizeLengthBox<Type, Global>), Map(SizeLengthBox<Type, Global>, Box<Type, Global>), Array(u32Box<Type, Global>), Struct(Fields), Enum(Vec<(String, Fields), Global>), String(SizeLength), ContractName(SizeLength), ReceiveName(SizeLength), ULeb128(u32), ILeb128(u32), ByteList(SizeLength), ByteArray(u32),
}
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, Global>, Box<Type, Global>)

A pair.

List(SizeLengthBox<Type, Global>)

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

Set(SizeLengthBox<Type, Global>)

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

Map(SizeLengthBox<Type, Global>, Box<Type, Global>)

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

Array(u32Box<Type, Global>)

A fixed sized list.

Struct(Fields)

A structure type with fields.

Enum(Vec<(String, Fields), Global>)

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.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

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

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

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.