Crate borsh

Source
Expand description

§Crate features

§Ecosystem features

  • std - When enabled, borsh uses the standard library. Disabling this feature will result in building the crate in no_std environment.

    To carter such builds, Borsh offers io module which includes a items which are used in BorshSerialize and BorshDeserialize traits. Most notably io::Read, io::Write and io::Result.

    When std feature is enabled, those items are re-exports of corresponding std::io items. Otherwise they are borsh-specific types which mimic behaviour of corresponding standard types.

§Default features

  • std - enabled by default.

§Other features

§Config aliases

§Shortcuts

Following pages are highlighted here just to give reader a chance at learning that they exist.

Re-exports§

pub use de::BorshDeserialize;
pub use de::from_reader;
pub use de::from_slice;
pub use schema::BorshSchema;
pub use ser::BorshSerialize;

Modules§

de
error
io
Subset of std::io which is used as part of borsh public API.
schema
Module is available if borsh is built with features = ["unstable__schema"].
ser

Functions§

max_serialized_size
Returns the largest possible size of a serialised object based solely on its type T.
object_length
Serializes an object without allocation to compute and return its length
schema_container_of
generate BorshSchemaContainer for type T
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
Derive macro available if borsh is built with features = ["derive"].
BorshSchema
Derive macro available if borsh is built with features = ["unstable__schema"].
BorshSerialize
Derive macro available if borsh is built with features = ["derive"].