1// Used only by Serde doc tests. Not public API.
2
3use crate::lib::*;
4
5use crate::ser;
6
7#[doc(hidden)]
8#[derive(Debug)]
9pub struct Error;
10
11impl ser::Error for Error {
12 fn custom<T>(_: T) -> Self
13 where
14 T: Display,
15 {
16 unimplemented!()
17 }
18}
19
20#[cfg(feature = "std")]
21impl error::Error for Error {
22 fn description(&self) -> &str {
23 unimplemented!()
24 }
25}
26
27impl Display for Error {
28 fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
29 unimplemented!()
30 }
31}
32
33#[doc(hidden)]
34#[macro_export]
35macro_rules! __private_serialize {
36 () => {
37 trait Serialize {
38 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
39 where
40 S: $crate::Serializer;
41 }
42 };
43}
44
45#[doc(hidden)]
46#[macro_export(local_inner_macros)]
47macro_rules! __serialize_unimplemented {
48 ($($func:ident)*) => {
49 $(
50 __serialize_unimplemented_helper!($func);
51 )*
52 };
53}
54
55#[doc(hidden)]
56#[macro_export]
57macro_rules! __serialize_unimplemented_method {
58 ($func:ident $(<$t:ident>)* ($($arg:ty),*) -> $ret:ident) => {
59 fn $func $(<$t: ?Sized + $crate::Serialize>)* (self $(, _: $arg)*) -> $crate::__private::Result<Self::$ret, Self::Error> {
60 unimplemented!()
61 }
62 };
63}
64
65#[doc(hidden)]
66#[macro_export(local_inner_macros)]
67macro_rules! __serialize_unimplemented_helper {
68 (bool) => {
69 __serialize_unimplemented_method!(serialize_bool(bool) -> Ok);
70 };
71 (i8) => {
72 __serialize_unimplemented_method!(serialize_i8(i8) -> Ok);
73 };
74 (i16) => {
75 __serialize_unimplemented_method!(serialize_i16(i16) -> Ok);
76 };
77 (i32) => {
78 __serialize_unimplemented_method!(serialize_i32(i32) -> Ok);
79 };
80 (i64) => {
81 __serialize_unimplemented_method!(serialize_i64(i64) -> Ok);
82 };
83 (u8) => {
84 __serialize_unimplemented_method!(serialize_u8(u8) -> Ok);
85 };
86 (u16) => {
87 __serialize_unimplemented_method!(serialize_u16(u16) -> Ok);
88 };
89 (u32) => {
90 __serialize_unimplemented_method!(serialize_u32(u32) -> Ok);
91 };
92 (u64) => {
93 __serialize_unimplemented_method!(serialize_u64(u64) -> Ok);
94 };
95 (f32) => {
96 __serialize_unimplemented_method!(serialize_f32(f32) -> Ok);
97 };
98 (f64) => {
99 __serialize_unimplemented_method!(serialize_f64(f64) -> Ok);
100 };
101 (char) => {
102 __serialize_unimplemented_method!(serialize_char(char) -> Ok);
103 };
104 (str) => {
105 __serialize_unimplemented_method!(serialize_str(&str) -> Ok);
106 };
107 (bytes) => {
108 __serialize_unimplemented_method!(serialize_bytes(&[u8]) -> Ok);
109 };
110 (none) => {
111 __serialize_unimplemented_method!(serialize_none() -> Ok);
112 };
113 (some) => {
114 __serialize_unimplemented_method!(serialize_some<T>(&T) -> Ok);
115 };
116 (unit) => {
117 __serialize_unimplemented_method!(serialize_unit() -> Ok);
118 };
119 (unit_struct) => {
120 __serialize_unimplemented_method!(serialize_unit_struct(&str) -> Ok);
121 };
122 (unit_variant) => {
123 __serialize_unimplemented_method!(serialize_unit_variant(&str, u32, &str) -> Ok);
124 };
125 (newtype_struct) => {
126 __serialize_unimplemented_method!(serialize_newtype_struct<T>(&str, &T) -> Ok);
127 };
128 (newtype_variant) => {
129 __serialize_unimplemented_method!(serialize_newtype_variant<T>(&str, u32, &str, &T) -> Ok);
130 };
131 (seq) => {
132 type SerializeSeq = $crate::ser::Impossible<Self::Ok, Self::Error>;
133 __serialize_unimplemented_method!(serialize_seq(Option<usize>) -> SerializeSeq);
134 };
135 (tuple) => {
136 type SerializeTuple = $crate::ser::Impossible<Self::Ok, Self::Error>;
137 __serialize_unimplemented_method!(serialize_tuple(usize) -> SerializeTuple);
138 };
139 (tuple_struct) => {
140 type SerializeTupleStruct = $crate::ser::Impossible<Self::Ok, Self::Error>;
141 __serialize_unimplemented_method!(serialize_tuple_struct(&str, usize) -> SerializeTupleStruct);
142 };
143 (tuple_variant) => {
144 type SerializeTupleVariant = $crate::ser::Impossible<Self::Ok, Self::Error>;
145 __serialize_unimplemented_method!(serialize_tuple_variant(&str, u32, &str, usize) -> SerializeTupleVariant);
146 };
147 (map) => {
148 type SerializeMap = $crate::ser::Impossible<Self::Ok, Self::Error>;
149 __serialize_unimplemented_method!(serialize_map(Option<usize>) -> SerializeMap);
150 };
151 (struct) => {
152 type SerializeStruct = $crate::ser::Impossible<Self::Ok, Self::Error>;
153 __serialize_unimplemented_method!(serialize_struct(&str, usize) -> SerializeStruct);
154 };
155 (struct_variant) => {
156 type SerializeStructVariant = $crate::ser::Impossible<Self::Ok, Self::Error>;
157 __serialize_unimplemented_method!(serialize_struct_variant(&str, u32, &str, usize) -> SerializeStructVariant);
158 };
159}
160