Skip to main content

borsh/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3#[cfg(not(feature = "std"))]
4extern crate alloc;
5
6pub use borsh_derive::{BorshDeserialize, BorshSchema, BorshSerialize};
7
8pub mod de;
9mod pubkey;
10pub mod schema;
11pub mod schema_helpers;
12pub mod ser;
13
14pub use de::BorshDeserialize;
15pub use schema::BorshSchema;
16pub use schema_helpers::{try_from_slice_with_schema, try_to_vec_with_schema};
17pub use ser::BorshSerialize;
18
19/// A facade around all the types we need from the `std`, `core`, and `alloc`
20/// crates. This avoids elaborate import wrangling having to happen in every
21/// module.
22#[cfg(feature = "std")]
23pub mod maybestd {
24    pub use std::{borrow, boxed, collections, format, io, rc, string, sync, vec};
25}
26
27#[cfg(not(feature = "std"))]
28mod nostd_io;
29
30#[cfg(not(feature = "std"))]
31pub mod maybestd {
32    pub use alloc::{borrow, boxed, format, rc, string, sync, vec};
33
34    pub mod collections {
35        pub use alloc::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque};
36        pub use hashbrown::*;
37    }
38
39    pub mod io {
40        pub use super::super::nostd_io::*;
41    }
42
43    pub use hashbrown::{HashMap, HashSet};
44
45    pub mod hash_map {
46        pub use hashbrown::hash_map::Entry;
47    }
48}