Module borsh::schema[][src]

Since Borsh is not a self-descriptive format we have a way to describe types serialized with Borsh so that we can deserialize serialized blobs without having Rust types available. Additionally, this can be used to serialize content provided in a different format, e.g. JSON object {"user": "alice", "message": "Message"} can be serialized by JS code into Borsh format such that it can be deserialized into struct UserMessage {user: String, message: String} on Rust side.

The important components are: BorshSchema trait, Definition and Declaration types, and BorshSchemaContainer struct.

Structs

BorshSchemaContainer

All schema information needed to deserialize a single type.

Enums

Definition

The type that we use to represent the definition of the Borsh type.

Fields

The collection representing the fields of a struct.

Traits

BorshSchema

The declaration and the definition of the type that can be used to (de)serialize Borsh without the Rust type that produced it.

Type Definitions

Declaration

The type that we use to represent the declaration of the Borsh type.

FieldName

The name of the field in the struct (can be used to convert JSON to Borsh using the schema).

VariantName

The type that we use for the name of the variant.