Enum borsh::schema::Definition
source · pub enum Definition {
Array {
length: u32,
elements: Declaration,
},
Sequence {
elements: Declaration,
},
Tuple {
elements: Vec<Declaration>,
},
Enum {
variants: Vec<(VariantName, Declaration)>,
},
Struct {
fields: Fields,
},
}
Expand description
The type that we use to represent the definition of the Borsh type.
Variants§
Array
A fixed-size array with the length known at the compile time and the same-type elements.
Sequence
Fields
§
elements: Declaration
A sequence of elements of length known at the run time and the same-type elements.
Tuple
Fields
§
elements: Vec<Declaration>
A fixed-size tuple with the length known at the compile time and the elements of different types.
Enum
Fields
§
variants: Vec<(VariantName, Declaration)>
A tagged union, a.k.a enum. Tagged-unions have variants with associated structures.
Struct
A structure, structurally similar to a tuple.
Trait Implementations§
source§impl BorshDeserialize for Definitionwhere
u32: BorshDeserialize,
Declaration: BorshDeserialize,
Vec<Declaration>: BorshDeserialize,
Vec<(VariantName, Declaration)>: BorshDeserialize,
Fields: BorshDeserialize,
impl BorshDeserialize for Definitionwhere u32: BorshDeserialize, Declaration: BorshDeserialize, Vec<Declaration>: BorshDeserialize, Vec<(VariantName, Declaration)>: BorshDeserialize, Fields: BorshDeserialize,
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self>
fn deserialize(buf: &mut &[u8]) -> Result<Self>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
source§fn try_from_slice(v: &[u8]) -> Result<Self>
fn try_from_slice(v: &[u8]) -> Result<Self>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R: Read>(reader: &mut R) -> Result<Self>
source§impl BorshSchema for Definition
impl BorshSchema for Definition
source§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
source§fn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
fn add_definitions_recursively( definitions: &mut HashMap<Declaration, Definition> )
Recursively, using DFS, add type definitions required for this type. For primitive types
this is an empty map. Type definition explains how to serialize/deserialize a type.
source§fn add_definition(
declaration: Declaration,
definition: Definition,
definitions: &mut HashMap<Declaration, Definition>
)
fn add_definition( declaration: Declaration, definition: Definition, definitions: &mut HashMap<Declaration, Definition> )
Helper method to add a single type definition to the map.
fn schema_container() -> BorshSchemaContainer
source§impl BorshSerialize for Definitionwhere
u32: BorshSerialize,
Declaration: BorshSerialize,
Vec<Declaration>: BorshSerialize,
Vec<(VariantName, Declaration)>: BorshSerialize,
Fields: BorshSerialize,
impl BorshSerialize for Definitionwhere u32: BorshSerialize, Declaration: BorshSerialize, Vec<Declaration>: BorshSerialize, Vec<(VariantName, Declaration)>: BorshSerialize, Fields: BorshSerialize,
source§impl Clone for Definition
impl Clone for Definition
source§fn clone(&self) -> Definition
fn clone(&self) -> Definition
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Definition
impl Debug for Definition
source§impl EnumExt for Definitionwhere
u32: BorshDeserialize,
Declaration: BorshDeserialize,
Vec<Declaration>: BorshDeserialize,
Vec<(VariantName, Declaration)>: BorshDeserialize,
Fields: BorshDeserialize,
impl EnumExt for Definitionwhere u32: BorshDeserialize, Declaration: BorshDeserialize, Vec<Declaration>: BorshDeserialize, Vec<(VariantName, Declaration)>: BorshDeserialize, Fields: BorshDeserialize,
source§impl PartialEq<Definition> for Definition
impl PartialEq<Definition> for Definition
source§fn eq(&self, other: &Definition) -> bool
fn eq(&self, other: &Definition) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.