Expand description
§Crate features
§Ecosystem features
-
std - When enabled,
borshuses the standard library. Disabling this feature will result in building the crate inno_stdenvironment.To carter such builds, Borsh offers
iomodule which includes a items which are used inBorshSerializeandBorshDeserializetraits. Most notablyio::Read,io::Writeandio::Result.When std feature is enabled, those items are re-exports of corresponding
std::ioitems. Otherwise they are borsh-specific types which mimic behaviour of corresponding standard types.
§Default features
- std - enabled by default.
§Other features
-
derive - Gates derive macros of BorshSerialize and BorshDeserialize traits.
-
unstable__schema - Gates [BorshSchema] trait and its derive macro. Gates [schema] module. This feature requires derive to be enabled too.
-
rc - Gates implementation of BorshSerialize and BorshDeserialize for
Rc<T>/Arc<T>respectively. Inno_stdsettingRc/Arcare pulled fromalloccrate. Serializing and deserializing these types does not preserve identity and may result in multiple copies of the same data. Be sure that this is what you want before enabling this feature. -
hashbrown - Pulls in HashMap/HashSet when no
stdis 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.
-
indexmap - Gates implementation of BorshSerialize and BorshDeserialize for indexmap::IndexMap and IndexSet
-
ascii - Gates implementation of BorshSerialize, BorshDeserialize, [BorshSchema] for types from ascii crate.
-
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.
If this feature is not enabled, it is possible that two different byte slices could deserialize into the same
HashMap/HashSetobject.
§Config aliases
- hash_collections -
This is a feature alias, set up in
build.rsto be equivalent to (std OR hashbrown). Gates implementation of BorshSerialize, BorshDeserialize and [BorshSchema] for HashMap/HashSet.
§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 ser::BorshSerialize;
Modules§
Functions§
- object_
length - Serializes an object without allocation to compute and return its length
- to_vec
- Serialize an object into a vector of bytes.
- to_
writer - Serializes an object directly into a
Writer.
Derive Macros§
- Borsh
Deserialize - Derive macro available if borsh is built with
features = ["derive"]. - Borsh
Serialize - Derive macro available if borsh is built with
features = ["derive"].