Crate borsh

Source

Modules§

de
maybestd
A facade around all the types we need from the std, core, and alloc crates. This avoids elaborate import wrangling having to happen in every module.
schema
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.
schema_helpers
ser

Traits§

BorshDeserialize
A data-structure that can be de-serialized from binary format by NBOR.
BorshSchema
The declaration and the definition of the type that can be used to (de)serialize Borsh without the Rust type that produced it.
BorshSerialize
A data-structure that can be serialized into binary format by NBOR.

Functions§

to_vec
Serialize an object into a vector of bytes.
to_writer
Serializes an object directly into a Writer.
try_from_slice_with_schema
Deserialize this instance from a slice of bytes, but assume that at the beginning we have bytes describing the schema of the type. We deserialize this schema and verify that it is correct.
try_to_vec_with_schema
Serialize object into a vector of bytes and prefix with the schema serialized as vector of bytes in Borsh format.

Derive Macros§

BorshDeserialize
BorshSchema
BorshSerialize