1#![cfg_attr(not(feature = "std"), no_std)]
2#![doc = include_str!("../docs/rustdoc_include/borsh_crate_top_level.md")]
3
4#[cfg(not(feature = "std"))]
5extern crate alloc;
6
7#[doc = include_str!("../docs/rustdoc_include/borsh_schema.md")]
8#[cfg(feature = "unstable__schema")]
9pub use borsh_derive::BorshSchema;
10
11#[doc = include_str!("../docs/rustdoc_include/borsh_deserialize.md")]
12#[cfg(feature = "derive")]
13pub use borsh_derive::BorshDeserialize;
14
15#[doc = include_str!("../docs/rustdoc_include/borsh_serialize.md")]
16#[cfg(feature = "derive")]
17pub use borsh_derive::BorshSerialize;
18
19pub mod de;
20
21#[cfg(feature = "unstable__schema")]
24pub mod schema;
25#[cfg(feature = "unstable__schema")]
26pub(crate) mod schema_helpers;
27pub mod ser;
28
29pub use de::BorshDeserialize;
30pub use de::{from_reader, from_slice};
31#[cfg(feature = "unstable__schema")]
32pub use schema::BorshSchema;
33#[cfg(feature = "unstable__schema")]
34pub use schema_helpers::{
35 max_serialized_size, schema_container_of, try_from_slice_with_schema, try_to_vec_with_schema,
36};
37pub use ser::helpers::{object_length, to_vec, to_writer};
38pub use ser::BorshSerialize;
39pub mod error;
40
41#[cfg(all(feature = "std", feature = "hashbrown"))]
42compile_error!("feature \"std\" and feature \"hashbrown\" don't make sense at the same time");
43
44#[cfg(feature = "std")]
45use std::io as io_impl;
46#[cfg(not(feature = "std"))]
47mod nostd_io;
48#[cfg(not(feature = "std"))]
49use nostd_io as io_impl;
50
51pub mod io {
57 pub use super::io_impl::{Error, ErrorKind, Read, Result, Write};
58}
59
60#[doc(hidden)]
61pub mod __private {
62
63 #[cfg(feature = "std")]
67 pub mod maybestd {
68 pub use std::{borrow, boxed, collections, format, string, vec};
69
70 #[cfg(feature = "rc")]
71 pub use std::{rc, sync};
72 }
73 #[cfg(not(feature = "std"))]
74 pub mod maybestd {
75 pub use alloc::{borrow, boxed, format, string, vec};
76
77 #[cfg(feature = "rc")]
78 pub use alloc::{rc, sync};
79
80 pub mod collections {
81 pub use alloc::collections::{btree_map, BTreeMap, BTreeSet, LinkedList, VecDeque};
82 #[cfg(feature = "hashbrown")]
83 pub use hashbrown::*;
84 }
85 }
86}