1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! # Postcard Schema
/// Derive [`Schema`] for a struct or enum
///
/// # Examples
///
/// ```
/// use postcard_schema::Schema;
///
/// #[derive(Schema)]
/// struct Point {
/// x: i32,
/// y: i32,
/// }
/// ```
///
/// # Attributes
///
/// ## `#[serde(rename = "name")]`
///
/// The names of fields, containers, and variants in derived schemas respect `#[serde(rename = "name")]`
/// attributes. Note that this does not include variants like `#[serde(rename(serialize = "ser_name"))]`
/// or `#[serde(rename_all = "...")]`.
///
/// ## `#[postcard(crate = ...)]`
///
/// The `#[postcard(crate = ...)]` attribute can be used to specify a path to the `postcard_schema`
/// crate instance to use when referring to [`Schema`] and [schema types](schema) from generated
/// code. This is normally only applicable when invoking re-exported derives from a different crate.
///
/// ```
/// # use postcard_schema::Schema;
/// use postcard_schema as reexported_postcard_schema;
///
/// #[derive(Schema)]
/// #[postcard(crate = reexported_postcard_schema)]
/// struct Point {
/// x: i32,
/// y: i32,
/// }
/// ```
///
/// ## `#[postcard(bound = ...)]`
///
/// The `#[postcard(bound = ...)]` attribute can be used to overwrite the default bounds when
/// deriving [`Schema`]. The default bounds are `T: Schema` for each type parameter `T`.
///
/// ```
/// # use postcard_schema::Schema;
/// #[derive(Schema)]
/// #[postcard(bound = "")]
/// struct Foo<F: Bar, T: Schema>(F::Wrap<T>);
///
/// trait Bar {
/// type Wrap<T: Schema>: Schema;
/// }
///
/// struct NoSchema;
/// impl Bar for NoSchema {
/// type Wrap<T: Schema> = Option<T>;
/// }
///
/// Foo::<NoSchema, u8>::SCHEMA;
/// ```
pub use Schema;
/// A trait that represents a compile time calculated schema