Expand description
Crate features
Ecosystem features
- std -
When enabled, this will cause
borsh
to use the standard library. Currently, disabling this feature will result in building the crate inno_std
environment.
Default features
- std - enabled by default.
Other features
- derive - Gates derive macros of BorshSerialize and BorshDeserialize traits.
- schema - Gates BorshSchema trait and its derive macro. Gates schema and schema_helpers modules. This feature requires derive to be enabled too.
- rc -
Gates implementation of BorshSerialize and BorshDeserialize
for
Rc<T>
/Arc<T>
respectively. Inno_std
settingRc
/Arc
are pulled fromalloc
crate. - hashbrown -
Pulls in HashMap/HashSet when no
std
is available. This feature is set to be mutually exclusive with std feature. - bytes - Gates implementation of BorshSerialize and BorshDeserialize for Bytes and BytesMut.
- bson - Gates implementation of BorshSerialize and BorshDeserialize for ObjectId.
- de_strict_order - Enables check that keys, parsed during deserialization of HashMap/HashSet and BTreeSet/BTreeMap are encountered in ascending order with respect to PartialOrd for hash collections, and Ord for btree ones. Deserialization emits error otherwise.
Config aliases
- hash_collections -
This is a feature alias, set up in
build.rs
to be equivalent to (std OR hashbrown). Gates implementation of BorshSerialize, BorshDeserialize and BorshSchema for HashMap/HashSet. - derive_schema -
This is a feature alias, set up in
build.rs
to be equivalent to (derive AND schema).
Re-exports
pub use de::BorshDeserialize;
pub use de::from_reader;
pub use de::from_slice;
pub use schema::BorshSchema;
pub use schema_helpers::try_from_slice_with_schema;
pub use schema_helpers::try_to_vec_with_schema;
pub use ser::BorshSerialize;
Modules
- Module is available if borsh is built with
features = ["derive", "schema"]
. - Module is available if borsh is built with
features = ["derive", "schema"]
.
Functions
- Serialize an object into a vector of bytes.
- Serializes an object directly into a
Writer
.
Derive Macros
- Derive macro available if borsh is built with
features = ["derive"]
. - Derive macro available if borsh is built with
features = ["derive", "schema"]
. - Derive macro available if borsh is built with
features = ["derive"]
.