postcard_schema/impls/
builtins_std.rs1use crate::{
4 schema::{DataModelType, NamedType},
5 Schema,
6};
7
8#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
9impl<T: Schema> Schema for std::vec::Vec<T> {
10 const SCHEMA: &'static NamedType = &NamedType {
11 name: "Vec<T>",
12 ty: &DataModelType::Seq(T::SCHEMA),
13 };
14}
15
16#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
17impl Schema for std::string::String {
18 const SCHEMA: &'static NamedType = &NamedType {
19 name: "String",
20 ty: &DataModelType::String,
21 };
22}
23
24#[cfg_attr(docsrs, doc(cfg(feature = "use-std")))]
25impl Schema for std::path::PathBuf {
26 const SCHEMA: &'static NamedType = &NamedType {
27 name: "PathBuf",
28 ty: &DataModelType::String,
29 };
30}
31
32#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
33impl<K: Schema, V: Schema> Schema for std::collections::HashMap<K, V> {
34 const SCHEMA: &'static NamedType = &NamedType {
35 name: "HashMap<K, V>",
36 ty: &DataModelType::Map {
37 key: K::SCHEMA,
38 val: V::SCHEMA,
39 },
40 };
41}
42
43#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
44impl<K: Schema, V: Schema> Schema for std::collections::BTreeMap<K, V> {
45 const SCHEMA: &'static NamedType = &NamedType {
46 name: "BTreeMap<K, V>",
47 ty: &DataModelType::Map {
48 key: K::SCHEMA,
49 val: V::SCHEMA,
50 },
51 };
52}
53
54#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
55impl<K: Schema> Schema for std::collections::HashSet<K> {
56 const SCHEMA: &'static NamedType = &NamedType {
57 name: "HashSet<K>",
58 ty: &DataModelType::Seq(K::SCHEMA),
59 };
60}
61
62#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
63impl<K: Schema> Schema for std::collections::BTreeSet<K> {
64 const SCHEMA: &'static NamedType = &NamedType {
65 name: "BTreeSet<K>",
66 ty: &DataModelType::Seq(K::SCHEMA),
67 };
68}
69
70#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
71impl<T: Schema> Schema for std::boxed::Box<T> {
72 const SCHEMA: &'static NamedType = T::SCHEMA;
73}
74
75#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "use-std"))))]
76impl<T: ?Sized + Schema + std::borrow::ToOwned> Schema for std::borrow::Cow<'_, T> {
77 const SCHEMA: &'static NamedType = T::SCHEMA;
78}