/rust/registry/src/index.crates.io-1949cf8c6b5b557f/serde_json-1.0.96/src/ser.rs
Line | Count | Source |
1 | | //! Serialize a Rust data structure into JSON data. |
2 | | |
3 | | use crate::error::{Error, ErrorCode, Result}; |
4 | | use crate::io; |
5 | | use alloc::string::{String, ToString}; |
6 | | use alloc::vec::Vec; |
7 | | use core::fmt::{self, Display}; |
8 | | use core::num::FpCategory; |
9 | | use serde::ser::{self, Impossible, Serialize}; |
10 | | |
11 | | /// A structure for serializing Rust values into JSON. |
12 | | #[cfg_attr(docsrs, doc(cfg(feature = "std")))] |
13 | | pub struct Serializer<W, F = CompactFormatter> { |
14 | | writer: W, |
15 | | formatter: F, |
16 | | } |
17 | | |
18 | | impl<W> Serializer<W> |
19 | | where |
20 | | W: io::Write, |
21 | | { |
22 | | /// Creates a new JSON serializer. |
23 | | #[inline] |
24 | 0 | pub fn new(writer: W) -> Self { |
25 | 0 | Serializer::with_formatter(writer, CompactFormatter) |
26 | 0 | } Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::new Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::new Unexecuted instantiation: <serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter>>::new |
27 | | } |
28 | | |
29 | | impl<'a, W> Serializer<W, PrettyFormatter<'a>> |
30 | | where |
31 | | W: io::Write, |
32 | | { |
33 | | /// Creates a new JSON pretty print serializer. |
34 | | #[inline] |
35 | 0 | pub fn pretty(writer: W) -> Self { |
36 | 0 | Serializer::with_formatter(writer, PrettyFormatter::new()) |
37 | 0 | } Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter>>::pretty Unexecuted instantiation: <serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter>>::pretty |
38 | | } |
39 | | |
40 | | impl<W, F> Serializer<W, F> |
41 | | where |
42 | | W: io::Write, |
43 | | F: Formatter, |
44 | | { |
45 | | /// Creates a new JSON visitor whose output will be written to the writer |
46 | | /// specified. |
47 | | #[inline] |
48 | 0 | pub fn with_formatter(writer: W, formatter: F) -> Self { |
49 | 0 | Serializer { writer, formatter } |
50 | 0 | } Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::with_formatter Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::with_formatter Unexecuted instantiation: <serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter>>::with_formatter Unexecuted instantiation: <serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter>>::with_formatter Unexecuted instantiation: <serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter>>::with_formatter |
51 | | |
52 | | /// Unwrap the `Writer` from the `Serializer`. |
53 | | #[inline] |
54 | 0 | pub fn into_inner(self) -> W { |
55 | 0 | self.writer |
56 | 0 | } |
57 | | } |
58 | | |
59 | | impl<'a, W, F> ser::Serializer for &'a mut Serializer<W, F> |
60 | | where |
61 | | W: io::Write, |
62 | | F: Formatter, |
63 | | { |
64 | | type Ok = (); |
65 | | type Error = Error; |
66 | | |
67 | | type SerializeSeq = Compound<'a, W, F>; |
68 | | type SerializeTuple = Compound<'a, W, F>; |
69 | | type SerializeTupleStruct = Compound<'a, W, F>; |
70 | | type SerializeTupleVariant = Compound<'a, W, F>; |
71 | | type SerializeMap = Compound<'a, W, F>; |
72 | | type SerializeStruct = Compound<'a, W, F>; |
73 | | type SerializeStructVariant = Compound<'a, W, F>; |
74 | | |
75 | | #[inline] |
76 | 0 | fn serialize_bool(self, value: bool) -> Result<()> { |
77 | 0 | self.formatter |
78 | 0 | .write_bool(&mut self.writer, value) |
79 | 0 | .map_err(Error::io) |
80 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_bool Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_bool Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_bool Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_bool |
81 | | |
82 | | #[inline] |
83 | 0 | fn serialize_i8(self, value: i8) -> Result<()> { |
84 | 0 | self.formatter |
85 | 0 | .write_i8(&mut self.writer, value) |
86 | 0 | .map_err(Error::io) |
87 | 0 | } |
88 | | |
89 | | #[inline] |
90 | 0 | fn serialize_i16(self, value: i16) -> Result<()> { |
91 | 0 | self.formatter |
92 | 0 | .write_i16(&mut self.writer, value) |
93 | 0 | .map_err(Error::io) |
94 | 0 | } |
95 | | |
96 | | #[inline] |
97 | 0 | fn serialize_i32(self, value: i32) -> Result<()> { |
98 | 0 | self.formatter |
99 | 0 | .write_i32(&mut self.writer, value) |
100 | 0 | .map_err(Error::io) |
101 | 0 | } |
102 | | |
103 | | #[inline] |
104 | 0 | fn serialize_i64(self, value: i64) -> Result<()> { |
105 | 0 | self.formatter |
106 | 0 | .write_i64(&mut self.writer, value) |
107 | 0 | .map_err(Error::io) |
108 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_i64 Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_i64 |
109 | | |
110 | 0 | fn serialize_i128(self, value: i128) -> Result<()> { |
111 | 0 | self.formatter |
112 | 0 | .write_i128(&mut self.writer, value) |
113 | 0 | .map_err(Error::io) |
114 | 0 | } |
115 | | |
116 | | #[inline] |
117 | 0 | fn serialize_u8(self, value: u8) -> Result<()> { |
118 | 0 | self.formatter |
119 | 0 | .write_u8(&mut self.writer, value) |
120 | 0 | .map_err(Error::io) |
121 | 0 | } |
122 | | |
123 | | #[inline] |
124 | 0 | fn serialize_u16(self, value: u16) -> Result<()> { |
125 | 0 | self.formatter |
126 | 0 | .write_u16(&mut self.writer, value) |
127 | 0 | .map_err(Error::io) |
128 | 0 | } |
129 | | |
130 | | #[inline] |
131 | 0 | fn serialize_u32(self, value: u32) -> Result<()> { |
132 | 0 | self.formatter |
133 | 0 | .write_u32(&mut self.writer, value) |
134 | 0 | .map_err(Error::io) |
135 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_u32 Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_u32 |
136 | | |
137 | | #[inline] |
138 | 0 | fn serialize_u64(self, value: u64) -> Result<()> { |
139 | 0 | self.formatter |
140 | 0 | .write_u64(&mut self.writer, value) |
141 | 0 | .map_err(Error::io) |
142 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_u64 Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_u64 Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_u64 |
143 | | |
144 | 0 | fn serialize_u128(self, value: u128) -> Result<()> { |
145 | 0 | self.formatter |
146 | 0 | .write_u128(&mut self.writer, value) |
147 | 0 | .map_err(Error::io) |
148 | 0 | } |
149 | | |
150 | | #[inline] |
151 | 0 | fn serialize_f32(self, value: f32) -> Result<()> { |
152 | 0 | match value.classify() { |
153 | 0 | FpCategory::Nan | FpCategory::Infinite => self |
154 | 0 | .formatter |
155 | 0 | .write_null(&mut self.writer) |
156 | 0 | .map_err(Error::io), |
157 | 0 | _ => self |
158 | 0 | .formatter |
159 | 0 | .write_f32(&mut self.writer, value) |
160 | 0 | .map_err(Error::io), |
161 | | } |
162 | 0 | } |
163 | | |
164 | | #[inline] |
165 | 0 | fn serialize_f64(self, value: f64) -> Result<()> { |
166 | 0 | match value.classify() { |
167 | 0 | FpCategory::Nan | FpCategory::Infinite => self |
168 | 0 | .formatter |
169 | 0 | .write_null(&mut self.writer) |
170 | 0 | .map_err(Error::io), |
171 | 0 | _ => self |
172 | 0 | .formatter |
173 | 0 | .write_f64(&mut self.writer, value) |
174 | 0 | .map_err(Error::io), |
175 | | } |
176 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_f64 Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_f64 |
177 | | |
178 | | #[inline] |
179 | 0 | fn serialize_char(self, value: char) -> Result<()> { |
180 | | // A char encoded as UTF-8 takes 4 bytes at most. |
181 | 0 | let mut buf = [0; 4]; |
182 | 0 | self.serialize_str(value.encode_utf8(&mut buf)) |
183 | 0 | } |
184 | | |
185 | | #[inline] |
186 | 0 | fn serialize_str(self, value: &str) -> Result<()> { |
187 | 0 | format_escaped_str(&mut self.writer, &mut self.formatter, value).map_err(Error::io) |
188 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_str |
189 | | |
190 | | #[inline] |
191 | 0 | fn serialize_bytes(self, value: &[u8]) -> Result<()> { |
192 | | use serde::ser::SerializeSeq; |
193 | 0 | let mut seq = tri!(self.serialize_seq(Some(value.len()))); |
194 | 0 | for byte in value { |
195 | 0 | tri!(seq.serialize_element(byte)); |
196 | | } |
197 | 0 | seq.end() |
198 | 0 | } |
199 | | |
200 | | #[inline] |
201 | 0 | fn serialize_unit(self) -> Result<()> { |
202 | 0 | self.formatter |
203 | 0 | .write_null(&mut self.writer) |
204 | 0 | .map_err(Error::io) |
205 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_unit Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_unit Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_unit Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_unit |
206 | | |
207 | | #[inline] |
208 | 0 | fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { |
209 | 0 | self.serialize_unit() |
210 | 0 | } |
211 | | |
212 | | #[inline] |
213 | 0 | fn serialize_unit_variant( |
214 | 0 | self, |
215 | 0 | _name: &'static str, |
216 | 0 | _variant_index: u32, |
217 | 0 | variant: &'static str, |
218 | 0 | ) -> Result<()> { |
219 | 0 | self.serialize_str(variant) |
220 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_unit_variant Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_unit_variant |
221 | | |
222 | | /// Serialize newtypes without an object wrapper. |
223 | | #[inline] |
224 | 0 | fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<()> |
225 | 0 | where |
226 | 0 | T: ?Sized + Serialize, |
227 | | { |
228 | 0 | value.serialize(self) |
229 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_newtype_struct::<cras_common::types_internal::_::InternalBitFlags> Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_newtype_struct::<cras_common::types_internal::_::InternalBitFlags> Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_newtype_struct::<_> |
230 | | |
231 | | #[inline] |
232 | 0 | fn serialize_newtype_variant<T>( |
233 | 0 | self, |
234 | 0 | _name: &'static str, |
235 | 0 | _variant_index: u32, |
236 | 0 | variant: &'static str, |
237 | 0 | value: &T, |
238 | 0 | ) -> Result<()> |
239 | 0 | where |
240 | 0 | T: ?Sized + Serialize, |
241 | | { |
242 | 0 | tri!(self |
243 | 0 | .formatter |
244 | 0 | .begin_object(&mut self.writer) |
245 | 0 | .map_err(Error::io)); |
246 | 0 | tri!(self |
247 | 0 | .formatter |
248 | 0 | .begin_object_key(&mut self.writer, true) |
249 | 0 | .map_err(Error::io)); |
250 | 0 | tri!(self.serialize_str(variant)); |
251 | 0 | tri!(self |
252 | 0 | .formatter |
253 | 0 | .end_object_key(&mut self.writer) |
254 | 0 | .map_err(Error::io)); |
255 | 0 | tri!(self |
256 | 0 | .formatter |
257 | 0 | .begin_object_value(&mut self.writer) |
258 | 0 | .map_err(Error::io)); |
259 | 0 | tri!(value.serialize(&mut *self)); |
260 | 0 | tri!(self |
261 | 0 | .formatter |
262 | 0 | .end_object_value(&mut self.writer) |
263 | 0 | .map_err(Error::io)); |
264 | 0 | self.formatter |
265 | 0 | .end_object(&mut self.writer) |
266 | 0 | .map_err(Error::io) |
267 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_newtype_variant::<audio_processor::config::PreloadedProcessor> Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_newtype_variant::<cras_s2::processing::BeamformingProperties> Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_newtype_variant::<_> |
268 | | |
269 | | #[inline] |
270 | 0 | fn serialize_none(self) -> Result<()> { |
271 | 0 | self.serialize_unit() |
272 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_none Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_none Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_none |
273 | | |
274 | | #[inline] |
275 | 0 | fn serialize_some<T>(self, value: &T) -> Result<()> |
276 | 0 | where |
277 | 0 | T: ?Sized + Serialize, |
278 | | { |
279 | 0 | value.serialize(self) |
280 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_some::<usize> Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_some::<alloc::vec::Vec<alloc::string::String>> Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_some::<_> |
281 | | |
282 | | #[inline] |
283 | 0 | fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> { |
284 | 0 | tri!(self |
285 | 0 | .formatter |
286 | 0 | .begin_array(&mut self.writer) |
287 | 0 | .map_err(Error::io)); |
288 | 0 | if len == Some(0) { |
289 | 0 | tri!(self |
290 | 0 | .formatter |
291 | 0 | .end_array(&mut self.writer) |
292 | 0 | .map_err(Error::io)); |
293 | 0 | Ok(Compound::Map { |
294 | 0 | ser: self, |
295 | 0 | state: State::Empty, |
296 | 0 | }) |
297 | | } else { |
298 | 0 | Ok(Compound::Map { |
299 | 0 | ser: self, |
300 | 0 | state: State::First, |
301 | 0 | }) |
302 | | } |
303 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_seq Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_seq Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_seq Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_seq |
304 | | |
305 | | #[inline] |
306 | 0 | fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple> { |
307 | 0 | self.serialize_seq(Some(len)) |
308 | 0 | } |
309 | | |
310 | | #[inline] |
311 | 0 | fn serialize_tuple_struct( |
312 | 0 | self, |
313 | 0 | _name: &'static str, |
314 | 0 | len: usize, |
315 | 0 | ) -> Result<Self::SerializeTupleStruct> { |
316 | 0 | self.serialize_seq(Some(len)) |
317 | 0 | } |
318 | | |
319 | | #[inline] |
320 | 0 | fn serialize_tuple_variant( |
321 | 0 | self, |
322 | 0 | _name: &'static str, |
323 | 0 | _variant_index: u32, |
324 | 0 | variant: &'static str, |
325 | 0 | len: usize, |
326 | 0 | ) -> Result<Self::SerializeTupleVariant> { |
327 | 0 | tri!(self |
328 | 0 | .formatter |
329 | 0 | .begin_object(&mut self.writer) |
330 | 0 | .map_err(Error::io)); |
331 | 0 | tri!(self |
332 | 0 | .formatter |
333 | 0 | .begin_object_key(&mut self.writer, true) |
334 | 0 | .map_err(Error::io)); |
335 | 0 | tri!(self.serialize_str(variant)); |
336 | 0 | tri!(self |
337 | 0 | .formatter |
338 | 0 | .end_object_key(&mut self.writer) |
339 | 0 | .map_err(Error::io)); |
340 | 0 | tri!(self |
341 | 0 | .formatter |
342 | 0 | .begin_object_value(&mut self.writer) |
343 | 0 | .map_err(Error::io)); |
344 | 0 | self.serialize_seq(Some(len)) |
345 | 0 | } |
346 | | |
347 | | #[inline] |
348 | 0 | fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap> { |
349 | 0 | tri!(self |
350 | 0 | .formatter |
351 | 0 | .begin_object(&mut self.writer) |
352 | 0 | .map_err(Error::io)); |
353 | 0 | if len == Some(0) { |
354 | 0 | tri!(self |
355 | 0 | .formatter |
356 | 0 | .end_object(&mut self.writer) |
357 | 0 | .map_err(Error::io)); |
358 | 0 | Ok(Compound::Map { |
359 | 0 | ser: self, |
360 | 0 | state: State::Empty, |
361 | 0 | }) |
362 | | } else { |
363 | 0 | Ok(Compound::Map { |
364 | 0 | ser: self, |
365 | 0 | state: State::First, |
366 | 0 | }) |
367 | | } |
368 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_map Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_map Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_map Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> as serde::ser::Serializer>::serialize_map Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_map |
369 | | |
370 | | #[inline] |
371 | 0 | fn serialize_struct(self, name: &'static str, len: usize) -> Result<Self::SerializeStruct> { |
372 | 0 | match name { |
373 | | #[cfg(feature = "arbitrary_precision")] |
374 | | crate::number::TOKEN => Ok(Compound::Number { ser: self }), |
375 | | #[cfg(feature = "raw_value")] |
376 | | crate::raw::TOKEN => Ok(Compound::RawValue { ser: self }), |
377 | 0 | _ => self.serialize_map(Some(len)), |
378 | | } |
379 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_struct Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_struct Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_struct |
380 | | |
381 | | #[inline] |
382 | 0 | fn serialize_struct_variant( |
383 | 0 | self, |
384 | 0 | _name: &'static str, |
385 | 0 | _variant_index: u32, |
386 | 0 | variant: &'static str, |
387 | 0 | len: usize, |
388 | 0 | ) -> Result<Self::SerializeStructVariant> { |
389 | 0 | tri!(self |
390 | 0 | .formatter |
391 | 0 | .begin_object(&mut self.writer) |
392 | 0 | .map_err(Error::io)); |
393 | 0 | tri!(self |
394 | 0 | .formatter |
395 | 0 | .begin_object_key(&mut self.writer, true) |
396 | 0 | .map_err(Error::io)); |
397 | 0 | tri!(self.serialize_str(variant)); |
398 | 0 | tri!(self |
399 | 0 | .formatter |
400 | 0 | .end_object_key(&mut self.writer) |
401 | 0 | .map_err(Error::io)); |
402 | 0 | tri!(self |
403 | 0 | .formatter |
404 | 0 | .begin_object_value(&mut self.writer) |
405 | 0 | .map_err(Error::io)); |
406 | 0 | self.serialize_map(Some(len)) |
407 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>> as serde::ser::Serializer>::serialize_struct_variant Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_struct_variant Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::serialize_struct_variant |
408 | | |
409 | 0 | fn collect_str<T>(self, value: &T) -> Result<()> |
410 | 0 | where |
411 | 0 | T: ?Sized + Display, |
412 | | { |
413 | | use self::fmt::Write; |
414 | | |
415 | | struct Adapter<'ser, W: 'ser, F: 'ser> { |
416 | | writer: &'ser mut W, |
417 | | formatter: &'ser mut F, |
418 | | error: Option<io::Error>, |
419 | | } |
420 | | |
421 | | impl<'ser, W, F> Write for Adapter<'ser, W, F> |
422 | | where |
423 | | W: io::Write, |
424 | | F: Formatter, |
425 | | { |
426 | 0 | fn write_str(&mut self, s: &str) -> fmt::Result { |
427 | 0 | debug_assert!(self.error.is_none()); |
428 | 0 | match format_escaped_str_contents(self.writer, self.formatter, s) { |
429 | 0 | Ok(()) => Ok(()), |
430 | 0 | Err(err) => { |
431 | 0 | self.error = Some(err); |
432 | 0 | Err(fmt::Error) |
433 | | } |
434 | | } |
435 | 0 | } Unexecuted instantiation: <<&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::collect_str::Adapter<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as core::fmt::Write>::write_str Unexecuted instantiation: <<&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::collect_str::Adapter<_, _> as core::fmt::Write>::write_str |
436 | | } |
437 | | |
438 | 0 | tri!(self |
439 | 0 | .formatter |
440 | 0 | .begin_string(&mut self.writer) |
441 | 0 | .map_err(Error::io)); |
442 | | { |
443 | 0 | let mut adapter = Adapter { |
444 | 0 | writer: &mut self.writer, |
445 | 0 | formatter: &mut self.formatter, |
446 | 0 | error: None, |
447 | 0 | }; |
448 | 0 | match write!(adapter, "{}", value) { |
449 | 0 | Ok(()) => debug_assert!(adapter.error.is_none()), |
450 | | Err(fmt::Error) => { |
451 | 0 | return Err(Error::io(adapter.error.expect("there should be an error"))); |
452 | | } |
453 | | } |
454 | | } |
455 | 0 | self.formatter |
456 | 0 | .end_string(&mut self.writer) |
457 | 0 | .map_err(Error::io) |
458 | 0 | } Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::collect_str::<bitflags::parser::AsDisplay<cras_common::types_internal::EFFECT_TYPE>> Unexecuted instantiation: <&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::collect_str::<bitflags::parser::AsDisplay<cras_common::types_internal::CRAS_NC_PROVIDER>> Unexecuted instantiation: <&mut serde_json::ser::Serializer<_, _> as serde::ser::Serializer>::collect_str::<_> |
459 | | } |
460 | | |
461 | | // Not public API. Should be pub(crate). |
462 | | #[doc(hidden)] |
463 | | #[derive(Eq, PartialEq)] |
464 | | pub enum State { |
465 | | Empty, |
466 | | First, |
467 | | Rest, |
468 | | } |
469 | | |
470 | | // Not public API. Should be pub(crate). |
471 | | #[doc(hidden)] |
472 | | pub enum Compound<'a, W: 'a, F: 'a> { |
473 | | Map { |
474 | | ser: &'a mut Serializer<W, F>, |
475 | | state: State, |
476 | | }, |
477 | | #[cfg(feature = "arbitrary_precision")] |
478 | | Number { ser: &'a mut Serializer<W, F> }, |
479 | | #[cfg(feature = "raw_value")] |
480 | | RawValue { ser: &'a mut Serializer<W, F> }, |
481 | | } |
482 | | |
483 | | impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> |
484 | | where |
485 | | W: io::Write, |
486 | | F: Formatter, |
487 | | { |
488 | | type Ok = (); |
489 | | type Error = Error; |
490 | | |
491 | | #[inline] |
492 | 0 | fn serialize_element<T>(&mut self, value: &T) -> Result<()> |
493 | 0 | where |
494 | 0 | T: ?Sized + Serialize, |
495 | | { |
496 | 0 | match self { |
497 | 0 | Compound::Map { ser, state } => { |
498 | 0 | tri!(ser |
499 | 0 | .formatter |
500 | 0 | .begin_array_value(&mut ser.writer, *state == State::First) |
501 | 0 | .map_err(Error::io)); |
502 | 0 | *state = State::Rest; |
503 | 0 | tri!(value.serialize(&mut **ser)); |
504 | 0 | ser.formatter |
505 | 0 | .end_array_value(&mut ser.writer) |
506 | 0 | .map_err(Error::io) |
507 | | } |
508 | | #[cfg(feature = "arbitrary_precision")] |
509 | | Compound::Number { .. } => unreachable!(), |
510 | | #[cfg(feature = "raw_value")] |
511 | | Compound::RawValue { .. } => unreachable!(), |
512 | | } |
513 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeSeq>::serialize_element::<&audio_processor::config::Processor> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeSeq>::serialize_element::<&usize> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeSeq>::serialize_element::<&alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::SerializeSeq>::serialize_element::<&serde_json::value::Value> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::SerializeSeq>::serialize_element::<&serde_json::value::Value> |
514 | | |
515 | | #[inline] |
516 | 0 | fn end(self) -> Result<()> { |
517 | 0 | match self { |
518 | 0 | Compound::Map { ser, state } => match state { |
519 | 0 | State::Empty => Ok(()), |
520 | 0 | _ => ser.formatter.end_array(&mut ser.writer).map_err(Error::io), |
521 | | }, |
522 | | #[cfg(feature = "arbitrary_precision")] |
523 | | Compound::Number { .. } => unreachable!(), |
524 | | #[cfg(feature = "raw_value")] |
525 | | Compound::RawValue { .. } => unreachable!(), |
526 | | } |
527 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeSeq>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeSeq>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::SerializeSeq>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::SerializeSeq>::end |
528 | | } |
529 | | |
530 | | impl<'a, W, F> ser::SerializeTuple for Compound<'a, W, F> |
531 | | where |
532 | | W: io::Write, |
533 | | F: Formatter, |
534 | | { |
535 | | type Ok = (); |
536 | | type Error = Error; |
537 | | |
538 | | #[inline] |
539 | 0 | fn serialize_element<T>(&mut self, value: &T) -> Result<()> |
540 | 0 | where |
541 | 0 | T: ?Sized + Serialize, |
542 | | { |
543 | 0 | ser::SerializeSeq::serialize_element(self, value) |
544 | 0 | } |
545 | | |
546 | | #[inline] |
547 | 0 | fn end(self) -> Result<()> { |
548 | 0 | ser::SerializeSeq::end(self) |
549 | 0 | } |
550 | | } |
551 | | |
552 | | impl<'a, W, F> ser::SerializeTupleStruct for Compound<'a, W, F> |
553 | | where |
554 | | W: io::Write, |
555 | | F: Formatter, |
556 | | { |
557 | | type Ok = (); |
558 | | type Error = Error; |
559 | | |
560 | | #[inline] |
561 | 0 | fn serialize_field<T>(&mut self, value: &T) -> Result<()> |
562 | 0 | where |
563 | 0 | T: ?Sized + Serialize, |
564 | | { |
565 | 0 | ser::SerializeSeq::serialize_element(self, value) |
566 | 0 | } |
567 | | |
568 | | #[inline] |
569 | 0 | fn end(self) -> Result<()> { |
570 | 0 | ser::SerializeSeq::end(self) |
571 | 0 | } |
572 | | } |
573 | | |
574 | | impl<'a, W, F> ser::SerializeTupleVariant for Compound<'a, W, F> |
575 | | where |
576 | | W: io::Write, |
577 | | F: Formatter, |
578 | | { |
579 | | type Ok = (); |
580 | | type Error = Error; |
581 | | |
582 | | #[inline] |
583 | 0 | fn serialize_field<T>(&mut self, value: &T) -> Result<()> |
584 | 0 | where |
585 | 0 | T: ?Sized + Serialize, |
586 | | { |
587 | 0 | ser::SerializeSeq::serialize_element(self, value) |
588 | 0 | } |
589 | | |
590 | | #[inline] |
591 | 0 | fn end(self) -> Result<()> { |
592 | 0 | match self { |
593 | 0 | Compound::Map { ser, state } => { |
594 | 0 | match state { |
595 | 0 | State::Empty => {} |
596 | 0 | _ => tri!(ser.formatter.end_array(&mut ser.writer).map_err(Error::io)), |
597 | | } |
598 | 0 | tri!(ser |
599 | 0 | .formatter |
600 | 0 | .end_object_value(&mut ser.writer) |
601 | 0 | .map_err(Error::io)); |
602 | 0 | ser.formatter.end_object(&mut ser.writer).map_err(Error::io) |
603 | | } |
604 | | #[cfg(feature = "arbitrary_precision")] |
605 | | Compound::Number { .. } => unreachable!(), |
606 | | #[cfg(feature = "raw_value")] |
607 | | Compound::RawValue { .. } => unreachable!(), |
608 | | } |
609 | 0 | } |
610 | | } |
611 | | |
612 | | impl<'a, W, F> ser::SerializeMap for Compound<'a, W, F> |
613 | | where |
614 | | W: io::Write, |
615 | | F: Formatter, |
616 | | { |
617 | | type Ok = (); |
618 | | type Error = Error; |
619 | | |
620 | | #[inline] |
621 | 0 | fn serialize_key<T>(&mut self, key: &T) -> Result<()> |
622 | 0 | where |
623 | 0 | T: ?Sized + Serialize, |
624 | | { |
625 | 0 | match self { |
626 | 0 | Compound::Map { ser, state } => { |
627 | 0 | tri!(ser |
628 | 0 | .formatter |
629 | 0 | .begin_object_key(&mut ser.writer, *state == State::First) |
630 | 0 | .map_err(Error::io)); |
631 | 0 | *state = State::Rest; |
632 | | |
633 | 0 | tri!(key.serialize(MapKeySerializer { ser: *ser })); |
634 | | |
635 | 0 | ser.formatter |
636 | 0 | .end_object_key(&mut ser.writer) |
637 | 0 | .map_err(Error::io) |
638 | | } |
639 | | #[cfg(feature = "arbitrary_precision")] |
640 | | Compound::Number { .. } => unreachable!(), |
641 | | #[cfg(feature = "raw_value")] |
642 | | Compound::RawValue { .. } => unreachable!(), |
643 | | } |
644 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_key::<str> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_key::<&alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_key::<&alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_key::<&cras_common::types_internal::CRAS_NC_PROVIDER> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_key::<str> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_key::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_key::<alloc::string::String> |
645 | | |
646 | | #[inline] |
647 | 0 | fn serialize_value<T>(&mut self, value: &T) -> Result<()> |
648 | 0 | where |
649 | 0 | T: ?Sized + Serialize, |
650 | | { |
651 | 0 | match self { |
652 | 0 | Compound::Map { ser, .. } => { |
653 | 0 | tri!(ser |
654 | 0 | .formatter |
655 | 0 | .begin_object_value(&mut ser.writer) |
656 | 0 | .map_err(Error::io)); |
657 | 0 | tri!(value.serialize(&mut **ser)); |
658 | 0 | ser.formatter |
659 | 0 | .end_object_value(&mut ser.writer) |
660 | 0 | .map_err(Error::io) |
661 | | } |
662 | | #[cfg(feature = "arbitrary_precision")] |
663 | | Compound::Number { .. } => unreachable!(), |
664 | | #[cfg(feature = "raw_value")] |
665 | | Compound::RawValue { .. } => unreachable!(), |
666 | | } |
667 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<alloc::vec::Vec<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<alloc::vec::Vec<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<alloc::boxed::Box<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<core::option::Option<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<audio_processor::shape::Format> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<audio_processor::config::Processor> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<std::path::PathBuf> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<bool> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<usize> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<&alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<core::option::Option<alloc::vec::Vec<alloc::string::String>>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<std::collections::hash::map::HashMap<alloc::string::String, alloc::string::String>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<std::collections::hash::map::HashMap<cras_common::types_internal::CRAS_NC_PROVIDER, cras_s2::AudioEffectStatus>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<std::collections::hash::set::HashSet<alloc::string::String>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_feature_tier::CrasFeatureTier> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_s2::Input> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_s2::Output> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<std::path::PathBuf> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_common::types_internal::EFFECT_TYPE> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_common::types_internal::CRAS_NC_PROVIDER> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_common::types_internal::CrasEffectUIAppearance> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<cras_s2::processing::BeamformingConfig> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<&cras_s2::AudioEffectStatus> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<&alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<&str> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<bool> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::serialize_value::<serde_json::value::Value> Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::serialize_value::<serde_json::value::Value> |
668 | | |
669 | | #[inline] |
670 | 0 | fn end(self) -> Result<()> { |
671 | 0 | match self { |
672 | 0 | Compound::Map { ser, state } => match state { |
673 | 0 | State::Empty => Ok(()), |
674 | 0 | _ => ser.formatter.end_object(&mut ser.writer).map_err(Error::io), |
675 | | }, |
676 | | #[cfg(feature = "arbitrary_precision")] |
677 | | Compound::Number { .. } => unreachable!(), |
678 | | #[cfg(feature = "raw_value")] |
679 | | Compound::RawValue { .. } => unreachable!(), |
680 | | } |
681 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::SerializeMap>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::SerializeMap>::end |
682 | | } |
683 | | |
684 | | impl<'a, W, F> ser::SerializeStruct for Compound<'a, W, F> |
685 | | where |
686 | | W: io::Write, |
687 | | F: Formatter, |
688 | | { |
689 | | type Ok = (); |
690 | | type Error = Error; |
691 | | |
692 | | #[inline] |
693 | 0 | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()> |
694 | 0 | where |
695 | 0 | T: ?Sized + Serialize, |
696 | | { |
697 | 0 | match self { |
698 | 0 | Compound::Map { .. } => ser::SerializeMap::serialize_entry(self, key, value), |
699 | | #[cfg(feature = "arbitrary_precision")] |
700 | | Compound::Number { ser, .. } => { |
701 | | if key == crate::number::TOKEN { |
702 | | value.serialize(NumberStrEmitter(ser)) |
703 | | } else { |
704 | | Err(invalid_number()) |
705 | | } |
706 | | } |
707 | | #[cfg(feature = "raw_value")] |
708 | | Compound::RawValue { ser, .. } => { |
709 | | if key == crate::raw::TOKEN { |
710 | | value.serialize(RawValueStrEmitter(ser)) |
711 | | } else { |
712 | | Err(invalid_raw_value()) |
713 | | } |
714 | | } |
715 | | } |
716 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<alloc::vec::Vec<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<alloc::vec::Vec<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<alloc::boxed::Box<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<core::option::Option<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<std::path::PathBuf> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<bool> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<usize> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<audio_processor::shape::Format> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::serialize_field::<audio_processor::config::Processor> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<core::option::Option<alloc::vec::Vec<alloc::string::String>>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<std::collections::hash::map::HashMap<alloc::string::String, alloc::string::String>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<std::collections::hash::map::HashMap<cras_common::types_internal::CRAS_NC_PROVIDER, cras_s2::AudioEffectStatus>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_feature_tier::CrasFeatureTier> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_s2::Input> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_s2::Output> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_common::types_internal::CRAS_NC_PROVIDER> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_common::types_internal::CrasEffectUIAppearance> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_s2::processing::BeamformingConfig> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<&str> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<std::collections::hash::set::HashSet<alloc::string::String>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<std::path::PathBuf> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<cras_common::types_internal::EFFECT_TYPE> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::serialize_field::<bool> Unexecuted instantiation: <serde_json::ser::Compound<_, _> as serde::ser::SerializeStruct>::serialize_field::<_> |
717 | | |
718 | | #[inline] |
719 | 0 | fn end(self) -> Result<()> { |
720 | 0 | match self { |
721 | 0 | Compound::Map { .. } => ser::SerializeMap::end(self), |
722 | | #[cfg(feature = "arbitrary_precision")] |
723 | | Compound::Number { .. } => Ok(()), |
724 | | #[cfg(feature = "raw_value")] |
725 | | Compound::RawValue { .. } => Ok(()), |
726 | | } |
727 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStruct>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStruct>::end Unexecuted instantiation: <serde_json::ser::Compound<_, _> as serde::ser::SerializeStruct>::end |
728 | | } |
729 | | |
730 | | impl<'a, W, F> ser::SerializeStructVariant for Compound<'a, W, F> |
731 | | where |
732 | | W: io::Write, |
733 | | F: Formatter, |
734 | | { |
735 | | type Ok = (); |
736 | | type Error = Error; |
737 | | |
738 | | #[inline] |
739 | 0 | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()> |
740 | 0 | where |
741 | 0 | T: ?Sized + Serialize, |
742 | | { |
743 | 0 | match *self { |
744 | 0 | Compound::Map { .. } => ser::SerializeStruct::serialize_field(self, key, value), |
745 | | #[cfg(feature = "arbitrary_precision")] |
746 | | Compound::Number { .. } => unreachable!(), |
747 | | #[cfg(feature = "raw_value")] |
748 | | Compound::RawValue { .. } => unreachable!(), |
749 | | } |
750 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<alloc::vec::Vec<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<alloc::vec::Vec<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<alloc::boxed::Box<audio_processor::config::Processor>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<core::option::Option<usize>> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<std::path::PathBuf> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<bool> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<usize> Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStructVariant>::serialize_field::<alloc::string::String> Unexecuted instantiation: <serde_json::ser::Compound<_, _> as serde::ser::SerializeStructVariant>::serialize_field::<_> |
751 | | |
752 | | #[inline] |
753 | 0 | fn end(self) -> Result<()> { |
754 | 0 | match self { |
755 | 0 | Compound::Map { ser, state } => { |
756 | 0 | match state { |
757 | 0 | State::Empty => {} |
758 | 0 | _ => tri!(ser.formatter.end_object(&mut ser.writer).map_err(Error::io)), |
759 | | } |
760 | 0 | tri!(ser |
761 | 0 | .formatter |
762 | 0 | .end_object_value(&mut ser.writer) |
763 | 0 | .map_err(Error::io)); |
764 | 0 | ser.formatter.end_object(&mut ser.writer).map_err(Error::io) |
765 | | } |
766 | | #[cfg(feature = "arbitrary_precision")] |
767 | | Compound::Number { .. } => unreachable!(), |
768 | | #[cfg(feature = "raw_value")] |
769 | | Compound::RawValue { .. } => unreachable!(), |
770 | | } |
771 | 0 | } Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::SerializeStructVariant>::end Unexecuted instantiation: <serde_json::ser::Compound<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::SerializeStructVariant>::end Unexecuted instantiation: <serde_json::ser::Compound<_, _> as serde::ser::SerializeStructVariant>::end |
772 | | } |
773 | | |
774 | | struct MapKeySerializer<'a, W: 'a, F: 'a> { |
775 | | ser: &'a mut Serializer<W, F>, |
776 | | } |
777 | | |
778 | | #[cfg(feature = "arbitrary_precision")] |
779 | | fn invalid_number() -> Error { |
780 | | Error::syntax(ErrorCode::InvalidNumber, 0, 0) |
781 | | } |
782 | | |
783 | | #[cfg(feature = "raw_value")] |
784 | | fn invalid_raw_value() -> Error { |
785 | | Error::syntax(ErrorCode::ExpectedSomeValue, 0, 0) |
786 | | } |
787 | | |
788 | 0 | fn key_must_be_a_string() -> Error { |
789 | 0 | Error::syntax(ErrorCode::KeyMustBeAString, 0, 0) |
790 | 0 | } |
791 | | |
792 | | impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> |
793 | | where |
794 | | W: io::Write, |
795 | | F: Formatter, |
796 | | { |
797 | | type Ok = (); |
798 | | type Error = Error; |
799 | | |
800 | | #[inline] |
801 | 0 | fn serialize_str(self, value: &str) -> Result<()> { |
802 | 0 | self.ser.serialize_str(value) |
803 | 0 | } Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_str Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> as serde::ser::Serializer>::serialize_str |
804 | | |
805 | | #[inline] |
806 | 0 | fn serialize_unit_variant( |
807 | 0 | self, |
808 | 0 | _name: &'static str, |
809 | 0 | _variant_index: u32, |
810 | 0 | variant: &'static str, |
811 | 0 | ) -> Result<()> { |
812 | 0 | self.ser.serialize_str(variant) |
813 | 0 | } |
814 | | |
815 | | #[inline] |
816 | 0 | fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<()> |
817 | 0 | where |
818 | 0 | T: ?Sized + Serialize, |
819 | | { |
820 | 0 | value.serialize(self) |
821 | 0 | } Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_newtype_struct::<cras_common::types_internal::_::InternalBitFlags> Unexecuted instantiation: <serde_json::ser::MapKeySerializer<_, _> as serde::ser::Serializer>::serialize_newtype_struct::<_> |
822 | | |
823 | | type SerializeSeq = Impossible<(), Error>; |
824 | | type SerializeTuple = Impossible<(), Error>; |
825 | | type SerializeTupleStruct = Impossible<(), Error>; |
826 | | type SerializeTupleVariant = Impossible<(), Error>; |
827 | | type SerializeMap = Impossible<(), Error>; |
828 | | type SerializeStruct = Impossible<(), Error>; |
829 | | type SerializeStructVariant = Impossible<(), Error>; |
830 | | |
831 | 0 | fn serialize_bool(self, _value: bool) -> Result<()> { |
832 | 0 | Err(key_must_be_a_string()) |
833 | 0 | } |
834 | | |
835 | 0 | fn serialize_i8(self, value: i8) -> Result<()> { |
836 | 0 | tri!(self |
837 | 0 | .ser |
838 | 0 | .formatter |
839 | 0 | .begin_string(&mut self.ser.writer) |
840 | 0 | .map_err(Error::io)); |
841 | 0 | tri!(self |
842 | 0 | .ser |
843 | 0 | .formatter |
844 | 0 | .write_i8(&mut self.ser.writer, value) |
845 | 0 | .map_err(Error::io)); |
846 | 0 | self.ser |
847 | 0 | .formatter |
848 | 0 | .end_string(&mut self.ser.writer) |
849 | 0 | .map_err(Error::io) |
850 | 0 | } |
851 | | |
852 | 0 | fn serialize_i16(self, value: i16) -> Result<()> { |
853 | 0 | tri!(self |
854 | 0 | .ser |
855 | 0 | .formatter |
856 | 0 | .begin_string(&mut self.ser.writer) |
857 | 0 | .map_err(Error::io)); |
858 | 0 | tri!(self |
859 | 0 | .ser |
860 | 0 | .formatter |
861 | 0 | .write_i16(&mut self.ser.writer, value) |
862 | 0 | .map_err(Error::io)); |
863 | 0 | self.ser |
864 | 0 | .formatter |
865 | 0 | .end_string(&mut self.ser.writer) |
866 | 0 | .map_err(Error::io) |
867 | 0 | } |
868 | | |
869 | 0 | fn serialize_i32(self, value: i32) -> Result<()> { |
870 | 0 | tri!(self |
871 | 0 | .ser |
872 | 0 | .formatter |
873 | 0 | .begin_string(&mut self.ser.writer) |
874 | 0 | .map_err(Error::io)); |
875 | 0 | tri!(self |
876 | 0 | .ser |
877 | 0 | .formatter |
878 | 0 | .write_i32(&mut self.ser.writer, value) |
879 | 0 | .map_err(Error::io)); |
880 | 0 | self.ser |
881 | 0 | .formatter |
882 | 0 | .end_string(&mut self.ser.writer) |
883 | 0 | .map_err(Error::io) |
884 | 0 | } |
885 | | |
886 | 0 | fn serialize_i64(self, value: i64) -> Result<()> { |
887 | 0 | tri!(self |
888 | 0 | .ser |
889 | 0 | .formatter |
890 | 0 | .begin_string(&mut self.ser.writer) |
891 | 0 | .map_err(Error::io)); |
892 | 0 | tri!(self |
893 | 0 | .ser |
894 | 0 | .formatter |
895 | 0 | .write_i64(&mut self.ser.writer, value) |
896 | 0 | .map_err(Error::io)); |
897 | 0 | self.ser |
898 | 0 | .formatter |
899 | 0 | .end_string(&mut self.ser.writer) |
900 | 0 | .map_err(Error::io) |
901 | 0 | } |
902 | | |
903 | 0 | fn serialize_i128(self, value: i128) -> Result<()> { |
904 | 0 | tri!(self |
905 | 0 | .ser |
906 | 0 | .formatter |
907 | 0 | .begin_string(&mut self.ser.writer) |
908 | 0 | .map_err(Error::io)); |
909 | 0 | tri!(self |
910 | 0 | .ser |
911 | 0 | .formatter |
912 | 0 | .write_i128(&mut self.ser.writer, value) |
913 | 0 | .map_err(Error::io)); |
914 | 0 | self.ser |
915 | 0 | .formatter |
916 | 0 | .end_string(&mut self.ser.writer) |
917 | 0 | .map_err(Error::io) |
918 | 0 | } |
919 | | |
920 | 0 | fn serialize_u8(self, value: u8) -> Result<()> { |
921 | 0 | tri!(self |
922 | 0 | .ser |
923 | 0 | .formatter |
924 | 0 | .begin_string(&mut self.ser.writer) |
925 | 0 | .map_err(Error::io)); |
926 | 0 | tri!(self |
927 | 0 | .ser |
928 | 0 | .formatter |
929 | 0 | .write_u8(&mut self.ser.writer, value) |
930 | 0 | .map_err(Error::io)); |
931 | 0 | self.ser |
932 | 0 | .formatter |
933 | 0 | .end_string(&mut self.ser.writer) |
934 | 0 | .map_err(Error::io) |
935 | 0 | } |
936 | | |
937 | 0 | fn serialize_u16(self, value: u16) -> Result<()> { |
938 | 0 | tri!(self |
939 | 0 | .ser |
940 | 0 | .formatter |
941 | 0 | .begin_string(&mut self.ser.writer) |
942 | 0 | .map_err(Error::io)); |
943 | 0 | tri!(self |
944 | 0 | .ser |
945 | 0 | .formatter |
946 | 0 | .write_u16(&mut self.ser.writer, value) |
947 | 0 | .map_err(Error::io)); |
948 | 0 | self.ser |
949 | 0 | .formatter |
950 | 0 | .end_string(&mut self.ser.writer) |
951 | 0 | .map_err(Error::io) |
952 | 0 | } |
953 | | |
954 | 0 | fn serialize_u32(self, value: u32) -> Result<()> { |
955 | 0 | tri!(self |
956 | 0 | .ser |
957 | 0 | .formatter |
958 | 0 | .begin_string(&mut self.ser.writer) |
959 | 0 | .map_err(Error::io)); |
960 | 0 | tri!(self |
961 | 0 | .ser |
962 | 0 | .formatter |
963 | 0 | .write_u32(&mut self.ser.writer, value) |
964 | 0 | .map_err(Error::io)); |
965 | 0 | self.ser |
966 | 0 | .formatter |
967 | 0 | .end_string(&mut self.ser.writer) |
968 | 0 | .map_err(Error::io) |
969 | 0 | } Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::serialize_u32 Unexecuted instantiation: <serde_json::ser::MapKeySerializer<_, _> as serde::ser::Serializer>::serialize_u32 |
970 | | |
971 | 0 | fn serialize_u64(self, value: u64) -> Result<()> { |
972 | 0 | tri!(self |
973 | 0 | .ser |
974 | 0 | .formatter |
975 | 0 | .begin_string(&mut self.ser.writer) |
976 | 0 | .map_err(Error::io)); |
977 | 0 | tri!(self |
978 | 0 | .ser |
979 | 0 | .formatter |
980 | 0 | .write_u64(&mut self.ser.writer, value) |
981 | 0 | .map_err(Error::io)); |
982 | 0 | self.ser |
983 | 0 | .formatter |
984 | 0 | .end_string(&mut self.ser.writer) |
985 | 0 | .map_err(Error::io) |
986 | 0 | } |
987 | | |
988 | 0 | fn serialize_u128(self, value: u128) -> Result<()> { |
989 | 0 | tri!(self |
990 | 0 | .ser |
991 | 0 | .formatter |
992 | 0 | .begin_string(&mut self.ser.writer) |
993 | 0 | .map_err(Error::io)); |
994 | 0 | tri!(self |
995 | 0 | .ser |
996 | 0 | .formatter |
997 | 0 | .write_u128(&mut self.ser.writer, value) |
998 | 0 | .map_err(Error::io)); |
999 | 0 | self.ser |
1000 | 0 | .formatter |
1001 | 0 | .end_string(&mut self.ser.writer) |
1002 | 0 | .map_err(Error::io) |
1003 | 0 | } |
1004 | | |
1005 | 0 | fn serialize_f32(self, _value: f32) -> Result<()> { |
1006 | 0 | Err(key_must_be_a_string()) |
1007 | 0 | } |
1008 | | |
1009 | 0 | fn serialize_f64(self, _value: f64) -> Result<()> { |
1010 | 0 | Err(key_must_be_a_string()) |
1011 | 0 | } |
1012 | | |
1013 | 0 | fn serialize_char(self, value: char) -> Result<()> { |
1014 | 0 | self.ser.serialize_str(&value.to_string()) |
1015 | 0 | } |
1016 | | |
1017 | 0 | fn serialize_bytes(self, _value: &[u8]) -> Result<()> { |
1018 | 0 | Err(key_must_be_a_string()) |
1019 | 0 | } |
1020 | | |
1021 | 0 | fn serialize_unit(self) -> Result<()> { |
1022 | 0 | Err(key_must_be_a_string()) |
1023 | 0 | } |
1024 | | |
1025 | 0 | fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { |
1026 | 0 | Err(key_must_be_a_string()) |
1027 | 0 | } |
1028 | | |
1029 | 0 | fn serialize_newtype_variant<T>( |
1030 | 0 | self, |
1031 | 0 | _name: &'static str, |
1032 | 0 | _variant_index: u32, |
1033 | 0 | _variant: &'static str, |
1034 | 0 | _value: &T, |
1035 | 0 | ) -> Result<()> |
1036 | 0 | where |
1037 | 0 | T: ?Sized + Serialize, |
1038 | | { |
1039 | 0 | Err(key_must_be_a_string()) |
1040 | 0 | } |
1041 | | |
1042 | 0 | fn serialize_none(self) -> Result<()> { |
1043 | 0 | Err(key_must_be_a_string()) |
1044 | 0 | } |
1045 | | |
1046 | 0 | fn serialize_some<T>(self, _value: &T) -> Result<()> |
1047 | 0 | where |
1048 | 0 | T: ?Sized + Serialize, |
1049 | | { |
1050 | 0 | Err(key_must_be_a_string()) |
1051 | 0 | } |
1052 | | |
1053 | 0 | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> { |
1054 | 0 | Err(key_must_be_a_string()) |
1055 | 0 | } |
1056 | | |
1057 | 0 | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple> { |
1058 | 0 | Err(key_must_be_a_string()) |
1059 | 0 | } |
1060 | | |
1061 | 0 | fn serialize_tuple_struct( |
1062 | 0 | self, |
1063 | 0 | _name: &'static str, |
1064 | 0 | _len: usize, |
1065 | 0 | ) -> Result<Self::SerializeTupleStruct> { |
1066 | 0 | Err(key_must_be_a_string()) |
1067 | 0 | } |
1068 | | |
1069 | 0 | fn serialize_tuple_variant( |
1070 | 0 | self, |
1071 | 0 | _name: &'static str, |
1072 | 0 | _variant_index: u32, |
1073 | 0 | _variant: &'static str, |
1074 | 0 | _len: usize, |
1075 | 0 | ) -> Result<Self::SerializeTupleVariant> { |
1076 | 0 | Err(key_must_be_a_string()) |
1077 | 0 | } |
1078 | | |
1079 | 0 | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap> { |
1080 | 0 | Err(key_must_be_a_string()) |
1081 | 0 | } |
1082 | | |
1083 | 0 | fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct> { |
1084 | 0 | Err(key_must_be_a_string()) |
1085 | 0 | } |
1086 | | |
1087 | 0 | fn serialize_struct_variant( |
1088 | 0 | self, |
1089 | 0 | _name: &'static str, |
1090 | 0 | _variant_index: u32, |
1091 | 0 | _variant: &'static str, |
1092 | 0 | _len: usize, |
1093 | 0 | ) -> Result<Self::SerializeStructVariant> { |
1094 | 0 | Err(key_must_be_a_string()) |
1095 | 0 | } |
1096 | | |
1097 | 0 | fn collect_str<T>(self, value: &T) -> Result<()> |
1098 | 0 | where |
1099 | 0 | T: ?Sized + Display, |
1100 | | { |
1101 | 0 | self.ser.collect_str(value) |
1102 | 0 | } Unexecuted instantiation: <serde_json::ser::MapKeySerializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> as serde::ser::Serializer>::collect_str::<bitflags::parser::AsDisplay<cras_common::types_internal::CRAS_NC_PROVIDER>> Unexecuted instantiation: <serde_json::ser::MapKeySerializer<_, _> as serde::ser::Serializer>::collect_str::<_> |
1103 | | } |
1104 | | |
1105 | | #[cfg(feature = "arbitrary_precision")] |
1106 | | struct NumberStrEmitter<'a, W: 'a + io::Write, F: 'a + Formatter>(&'a mut Serializer<W, F>); |
1107 | | |
1108 | | #[cfg(feature = "arbitrary_precision")] |
1109 | | impl<'a, W: io::Write, F: Formatter> ser::Serializer for NumberStrEmitter<'a, W, F> { |
1110 | | type Ok = (); |
1111 | | type Error = Error; |
1112 | | |
1113 | | type SerializeSeq = Impossible<(), Error>; |
1114 | | type SerializeTuple = Impossible<(), Error>; |
1115 | | type SerializeTupleStruct = Impossible<(), Error>; |
1116 | | type SerializeTupleVariant = Impossible<(), Error>; |
1117 | | type SerializeMap = Impossible<(), Error>; |
1118 | | type SerializeStruct = Impossible<(), Error>; |
1119 | | type SerializeStructVariant = Impossible<(), Error>; |
1120 | | |
1121 | | fn serialize_bool(self, _v: bool) -> Result<()> { |
1122 | | Err(invalid_number()) |
1123 | | } |
1124 | | |
1125 | | fn serialize_i8(self, _v: i8) -> Result<()> { |
1126 | | Err(invalid_number()) |
1127 | | } |
1128 | | |
1129 | | fn serialize_i16(self, _v: i16) -> Result<()> { |
1130 | | Err(invalid_number()) |
1131 | | } |
1132 | | |
1133 | | fn serialize_i32(self, _v: i32) -> Result<()> { |
1134 | | Err(invalid_number()) |
1135 | | } |
1136 | | |
1137 | | fn serialize_i64(self, _v: i64) -> Result<()> { |
1138 | | Err(invalid_number()) |
1139 | | } |
1140 | | |
1141 | | fn serialize_i128(self, _v: i128) -> Result<()> { |
1142 | | Err(invalid_number()) |
1143 | | } |
1144 | | |
1145 | | fn serialize_u8(self, _v: u8) -> Result<()> { |
1146 | | Err(invalid_number()) |
1147 | | } |
1148 | | |
1149 | | fn serialize_u16(self, _v: u16) -> Result<()> { |
1150 | | Err(invalid_number()) |
1151 | | } |
1152 | | |
1153 | | fn serialize_u32(self, _v: u32) -> Result<()> { |
1154 | | Err(invalid_number()) |
1155 | | } |
1156 | | |
1157 | | fn serialize_u64(self, _v: u64) -> Result<()> { |
1158 | | Err(invalid_number()) |
1159 | | } |
1160 | | |
1161 | | fn serialize_u128(self, _v: u128) -> Result<()> { |
1162 | | Err(invalid_number()) |
1163 | | } |
1164 | | |
1165 | | fn serialize_f32(self, _v: f32) -> Result<()> { |
1166 | | Err(invalid_number()) |
1167 | | } |
1168 | | |
1169 | | fn serialize_f64(self, _v: f64) -> Result<()> { |
1170 | | Err(invalid_number()) |
1171 | | } |
1172 | | |
1173 | | fn serialize_char(self, _v: char) -> Result<()> { |
1174 | | Err(invalid_number()) |
1175 | | } |
1176 | | |
1177 | | fn serialize_str(self, value: &str) -> Result<()> { |
1178 | | let NumberStrEmitter(serializer) = self; |
1179 | | serializer |
1180 | | .formatter |
1181 | | .write_number_str(&mut serializer.writer, value) |
1182 | | .map_err(Error::io) |
1183 | | } |
1184 | | |
1185 | | fn serialize_bytes(self, _value: &[u8]) -> Result<()> { |
1186 | | Err(invalid_number()) |
1187 | | } |
1188 | | |
1189 | | fn serialize_none(self) -> Result<()> { |
1190 | | Err(invalid_number()) |
1191 | | } |
1192 | | |
1193 | | fn serialize_some<T>(self, _value: &T) -> Result<()> |
1194 | | where |
1195 | | T: ?Sized + Serialize, |
1196 | | { |
1197 | | Err(invalid_number()) |
1198 | | } |
1199 | | |
1200 | | fn serialize_unit(self) -> Result<()> { |
1201 | | Err(invalid_number()) |
1202 | | } |
1203 | | |
1204 | | fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { |
1205 | | Err(invalid_number()) |
1206 | | } |
1207 | | |
1208 | | fn serialize_unit_variant( |
1209 | | self, |
1210 | | _name: &'static str, |
1211 | | _variant_index: u32, |
1212 | | _variant: &'static str, |
1213 | | ) -> Result<()> { |
1214 | | Err(invalid_number()) |
1215 | | } |
1216 | | |
1217 | | fn serialize_newtype_struct<T>(self, _name: &'static str, _value: &T) -> Result<()> |
1218 | | where |
1219 | | T: ?Sized + Serialize, |
1220 | | { |
1221 | | Err(invalid_number()) |
1222 | | } |
1223 | | |
1224 | | fn serialize_newtype_variant<T>( |
1225 | | self, |
1226 | | _name: &'static str, |
1227 | | _variant_index: u32, |
1228 | | _variant: &'static str, |
1229 | | _value: &T, |
1230 | | ) -> Result<()> |
1231 | | where |
1232 | | T: ?Sized + Serialize, |
1233 | | { |
1234 | | Err(invalid_number()) |
1235 | | } |
1236 | | |
1237 | | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> { |
1238 | | Err(invalid_number()) |
1239 | | } |
1240 | | |
1241 | | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple> { |
1242 | | Err(invalid_number()) |
1243 | | } |
1244 | | |
1245 | | fn serialize_tuple_struct( |
1246 | | self, |
1247 | | _name: &'static str, |
1248 | | _len: usize, |
1249 | | ) -> Result<Self::SerializeTupleStruct> { |
1250 | | Err(invalid_number()) |
1251 | | } |
1252 | | |
1253 | | fn serialize_tuple_variant( |
1254 | | self, |
1255 | | _name: &'static str, |
1256 | | _variant_index: u32, |
1257 | | _variant: &'static str, |
1258 | | _len: usize, |
1259 | | ) -> Result<Self::SerializeTupleVariant> { |
1260 | | Err(invalid_number()) |
1261 | | } |
1262 | | |
1263 | | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap> { |
1264 | | Err(invalid_number()) |
1265 | | } |
1266 | | |
1267 | | fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct> { |
1268 | | Err(invalid_number()) |
1269 | | } |
1270 | | |
1271 | | fn serialize_struct_variant( |
1272 | | self, |
1273 | | _name: &'static str, |
1274 | | _variant_index: u32, |
1275 | | _variant: &'static str, |
1276 | | _len: usize, |
1277 | | ) -> Result<Self::SerializeStructVariant> { |
1278 | | Err(invalid_number()) |
1279 | | } |
1280 | | } |
1281 | | |
1282 | | #[cfg(feature = "raw_value")] |
1283 | | struct RawValueStrEmitter<'a, W: 'a + io::Write, F: 'a + Formatter>(&'a mut Serializer<W, F>); |
1284 | | |
1285 | | #[cfg(feature = "raw_value")] |
1286 | | impl<'a, W: io::Write, F: Formatter> ser::Serializer for RawValueStrEmitter<'a, W, F> { |
1287 | | type Ok = (); |
1288 | | type Error = Error; |
1289 | | |
1290 | | type SerializeSeq = Impossible<(), Error>; |
1291 | | type SerializeTuple = Impossible<(), Error>; |
1292 | | type SerializeTupleStruct = Impossible<(), Error>; |
1293 | | type SerializeTupleVariant = Impossible<(), Error>; |
1294 | | type SerializeMap = Impossible<(), Error>; |
1295 | | type SerializeStruct = Impossible<(), Error>; |
1296 | | type SerializeStructVariant = Impossible<(), Error>; |
1297 | | |
1298 | | fn serialize_bool(self, _v: bool) -> Result<()> { |
1299 | | Err(ser::Error::custom("expected RawValue")) |
1300 | | } |
1301 | | |
1302 | | fn serialize_i8(self, _v: i8) -> Result<()> { |
1303 | | Err(ser::Error::custom("expected RawValue")) |
1304 | | } |
1305 | | |
1306 | | fn serialize_i16(self, _v: i16) -> Result<()> { |
1307 | | Err(ser::Error::custom("expected RawValue")) |
1308 | | } |
1309 | | |
1310 | | fn serialize_i32(self, _v: i32) -> Result<()> { |
1311 | | Err(ser::Error::custom("expected RawValue")) |
1312 | | } |
1313 | | |
1314 | | fn serialize_i64(self, _v: i64) -> Result<()> { |
1315 | | Err(ser::Error::custom("expected RawValue")) |
1316 | | } |
1317 | | |
1318 | | fn serialize_i128(self, _v: i128) -> Result<()> { |
1319 | | Err(ser::Error::custom("expected RawValue")) |
1320 | | } |
1321 | | |
1322 | | fn serialize_u8(self, _v: u8) -> Result<()> { |
1323 | | Err(ser::Error::custom("expected RawValue")) |
1324 | | } |
1325 | | |
1326 | | fn serialize_u16(self, _v: u16) -> Result<()> { |
1327 | | Err(ser::Error::custom("expected RawValue")) |
1328 | | } |
1329 | | |
1330 | | fn serialize_u32(self, _v: u32) -> Result<()> { |
1331 | | Err(ser::Error::custom("expected RawValue")) |
1332 | | } |
1333 | | |
1334 | | fn serialize_u64(self, _v: u64) -> Result<()> { |
1335 | | Err(ser::Error::custom("expected RawValue")) |
1336 | | } |
1337 | | |
1338 | | fn serialize_u128(self, _v: u128) -> Result<()> { |
1339 | | Err(ser::Error::custom("expected RawValue")) |
1340 | | } |
1341 | | |
1342 | | fn serialize_f32(self, _v: f32) -> Result<()> { |
1343 | | Err(ser::Error::custom("expected RawValue")) |
1344 | | } |
1345 | | |
1346 | | fn serialize_f64(self, _v: f64) -> Result<()> { |
1347 | | Err(ser::Error::custom("expected RawValue")) |
1348 | | } |
1349 | | |
1350 | | fn serialize_char(self, _v: char) -> Result<()> { |
1351 | | Err(ser::Error::custom("expected RawValue")) |
1352 | | } |
1353 | | |
1354 | | fn serialize_str(self, value: &str) -> Result<()> { |
1355 | | let RawValueStrEmitter(serializer) = self; |
1356 | | serializer |
1357 | | .formatter |
1358 | | .write_raw_fragment(&mut serializer.writer, value) |
1359 | | .map_err(Error::io) |
1360 | | } |
1361 | | |
1362 | | fn serialize_bytes(self, _value: &[u8]) -> Result<()> { |
1363 | | Err(ser::Error::custom("expected RawValue")) |
1364 | | } |
1365 | | |
1366 | | fn serialize_none(self) -> Result<()> { |
1367 | | Err(ser::Error::custom("expected RawValue")) |
1368 | | } |
1369 | | |
1370 | | fn serialize_some<T>(self, _value: &T) -> Result<()> |
1371 | | where |
1372 | | T: ?Sized + Serialize, |
1373 | | { |
1374 | | Err(ser::Error::custom("expected RawValue")) |
1375 | | } |
1376 | | |
1377 | | fn serialize_unit(self) -> Result<()> { |
1378 | | Err(ser::Error::custom("expected RawValue")) |
1379 | | } |
1380 | | |
1381 | | fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { |
1382 | | Err(ser::Error::custom("expected RawValue")) |
1383 | | } |
1384 | | |
1385 | | fn serialize_unit_variant( |
1386 | | self, |
1387 | | _name: &'static str, |
1388 | | _variant_index: u32, |
1389 | | _variant: &'static str, |
1390 | | ) -> Result<()> { |
1391 | | Err(ser::Error::custom("expected RawValue")) |
1392 | | } |
1393 | | |
1394 | | fn serialize_newtype_struct<T>(self, _name: &'static str, _value: &T) -> Result<()> |
1395 | | where |
1396 | | T: ?Sized + Serialize, |
1397 | | { |
1398 | | Err(ser::Error::custom("expected RawValue")) |
1399 | | } |
1400 | | |
1401 | | fn serialize_newtype_variant<T>( |
1402 | | self, |
1403 | | _name: &'static str, |
1404 | | _variant_index: u32, |
1405 | | _variant: &'static str, |
1406 | | _value: &T, |
1407 | | ) -> Result<()> |
1408 | | where |
1409 | | T: ?Sized + Serialize, |
1410 | | { |
1411 | | Err(ser::Error::custom("expected RawValue")) |
1412 | | } |
1413 | | |
1414 | | fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq> { |
1415 | | Err(ser::Error::custom("expected RawValue")) |
1416 | | } |
1417 | | |
1418 | | fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple> { |
1419 | | Err(ser::Error::custom("expected RawValue")) |
1420 | | } |
1421 | | |
1422 | | fn serialize_tuple_struct( |
1423 | | self, |
1424 | | _name: &'static str, |
1425 | | _len: usize, |
1426 | | ) -> Result<Self::SerializeTupleStruct> { |
1427 | | Err(ser::Error::custom("expected RawValue")) |
1428 | | } |
1429 | | |
1430 | | fn serialize_tuple_variant( |
1431 | | self, |
1432 | | _name: &'static str, |
1433 | | _variant_index: u32, |
1434 | | _variant: &'static str, |
1435 | | _len: usize, |
1436 | | ) -> Result<Self::SerializeTupleVariant> { |
1437 | | Err(ser::Error::custom("expected RawValue")) |
1438 | | } |
1439 | | |
1440 | | fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap> { |
1441 | | Err(ser::Error::custom("expected RawValue")) |
1442 | | } |
1443 | | |
1444 | | fn serialize_struct(self, _name: &'static str, _len: usize) -> Result<Self::SerializeStruct> { |
1445 | | Err(ser::Error::custom("expected RawValue")) |
1446 | | } |
1447 | | |
1448 | | fn serialize_struct_variant( |
1449 | | self, |
1450 | | _name: &'static str, |
1451 | | _variant_index: u32, |
1452 | | _variant: &'static str, |
1453 | | _len: usize, |
1454 | | ) -> Result<Self::SerializeStructVariant> { |
1455 | | Err(ser::Error::custom("expected RawValue")) |
1456 | | } |
1457 | | |
1458 | | fn collect_str<T>(self, value: &T) -> Result<Self::Ok> |
1459 | | where |
1460 | | T: ?Sized + Display, |
1461 | | { |
1462 | | self.serialize_str(&value.to_string()) |
1463 | | } |
1464 | | } |
1465 | | |
1466 | | /// Represents a character escape code in a type-safe manner. |
1467 | | pub enum CharEscape { |
1468 | | /// An escaped quote `"` |
1469 | | Quote, |
1470 | | /// An escaped reverse solidus `\` |
1471 | | ReverseSolidus, |
1472 | | /// An escaped solidus `/` |
1473 | | Solidus, |
1474 | | /// An escaped backspace character (usually escaped as `\b`) |
1475 | | Backspace, |
1476 | | /// An escaped form feed character (usually escaped as `\f`) |
1477 | | FormFeed, |
1478 | | /// An escaped line feed character (usually escaped as `\n`) |
1479 | | LineFeed, |
1480 | | /// An escaped carriage return character (usually escaped as `\r`) |
1481 | | CarriageReturn, |
1482 | | /// An escaped tab character (usually escaped as `\t`) |
1483 | | Tab, |
1484 | | /// An escaped ASCII plane control character (usually escaped as |
1485 | | /// `\u00XX` where `XX` are two hex characters) |
1486 | | AsciiControl(u8), |
1487 | | } |
1488 | | |
1489 | | impl CharEscape { |
1490 | | #[inline] |
1491 | 0 | fn from_escape_table(escape: u8, byte: u8) -> CharEscape { |
1492 | 0 | match escape { |
1493 | 0 | self::BB => CharEscape::Backspace, |
1494 | 0 | self::TT => CharEscape::Tab, |
1495 | 0 | self::NN => CharEscape::LineFeed, |
1496 | 0 | self::FF => CharEscape::FormFeed, |
1497 | 0 | self::RR => CharEscape::CarriageReturn, |
1498 | 0 | self::QU => CharEscape::Quote, |
1499 | 0 | self::BS => CharEscape::ReverseSolidus, |
1500 | 0 | self::UU => CharEscape::AsciiControl(byte), |
1501 | 0 | _ => unreachable!(), |
1502 | | } |
1503 | 0 | } |
1504 | | } |
1505 | | |
1506 | | /// This trait abstracts away serializing the JSON control characters, which allows the user to |
1507 | | /// optionally pretty print the JSON output. |
1508 | | pub trait Formatter { |
1509 | | /// Writes a `null` value to the specified writer. |
1510 | | #[inline] |
1511 | 0 | fn write_null<W>(&mut self, writer: &mut W) -> io::Result<()> |
1512 | 0 | where |
1513 | 0 | W: ?Sized + io::Write, |
1514 | | { |
1515 | 0 | writer.write_all(b"null") |
1516 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_null::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_null::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_null::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_null::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1517 | | |
1518 | | /// Writes a `true` or `false` value to the specified writer. |
1519 | | #[inline] |
1520 | 0 | fn write_bool<W>(&mut self, writer: &mut W, value: bool) -> io::Result<()> |
1521 | 0 | where |
1522 | 0 | W: ?Sized + io::Write, |
1523 | | { |
1524 | 0 | let s = if value { |
1525 | 0 | b"true" as &[u8] |
1526 | | } else { |
1527 | 0 | b"false" as &[u8] |
1528 | | }; |
1529 | 0 | writer.write_all(s) |
1530 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_bool::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_bool::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_bool::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_bool::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1531 | | |
1532 | | /// Writes an integer value like `-123` to the specified writer. |
1533 | | #[inline] |
1534 | 0 | fn write_i8<W>(&mut self, writer: &mut W, value: i8) -> io::Result<()> |
1535 | 0 | where |
1536 | 0 | W: ?Sized + io::Write, |
1537 | | { |
1538 | 0 | let mut buffer = itoa::Buffer::new(); |
1539 | 0 | let s = buffer.format(value); |
1540 | 0 | writer.write_all(s.as_bytes()) |
1541 | 0 | } |
1542 | | |
1543 | | /// Writes an integer value like `-123` to the specified writer. |
1544 | | #[inline] |
1545 | 0 | fn write_i16<W>(&mut self, writer: &mut W, value: i16) -> io::Result<()> |
1546 | 0 | where |
1547 | 0 | W: ?Sized + io::Write, |
1548 | | { |
1549 | 0 | let mut buffer = itoa::Buffer::new(); |
1550 | 0 | let s = buffer.format(value); |
1551 | 0 | writer.write_all(s.as_bytes()) |
1552 | 0 | } |
1553 | | |
1554 | | /// Writes an integer value like `-123` to the specified writer. |
1555 | | #[inline] |
1556 | 0 | fn write_i32<W>(&mut self, writer: &mut W, value: i32) -> io::Result<()> |
1557 | 0 | where |
1558 | 0 | W: ?Sized + io::Write, |
1559 | | { |
1560 | 0 | let mut buffer = itoa::Buffer::new(); |
1561 | 0 | let s = buffer.format(value); |
1562 | 0 | writer.write_all(s.as_bytes()) |
1563 | 0 | } |
1564 | | |
1565 | | /// Writes an integer value like `-123` to the specified writer. |
1566 | | #[inline] |
1567 | 0 | fn write_i64<W>(&mut self, writer: &mut W, value: i64) -> io::Result<()> |
1568 | 0 | where |
1569 | 0 | W: ?Sized + io::Write, |
1570 | | { |
1571 | 0 | let mut buffer = itoa::Buffer::new(); |
1572 | 0 | let s = buffer.format(value); |
1573 | 0 | writer.write_all(s.as_bytes()) |
1574 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_i64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_i64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1575 | | |
1576 | | /// Writes an integer value like `-123` to the specified writer. |
1577 | | #[inline] |
1578 | 0 | fn write_i128<W>(&mut self, writer: &mut W, value: i128) -> io::Result<()> |
1579 | 0 | where |
1580 | 0 | W: ?Sized + io::Write, |
1581 | | { |
1582 | 0 | let mut buffer = itoa::Buffer::new(); |
1583 | 0 | let s = buffer.format(value); |
1584 | 0 | writer.write_all(s.as_bytes()) |
1585 | 0 | } |
1586 | | |
1587 | | /// Writes an integer value like `123` to the specified writer. |
1588 | | #[inline] |
1589 | 0 | fn write_u8<W>(&mut self, writer: &mut W, value: u8) -> io::Result<()> |
1590 | 0 | where |
1591 | 0 | W: ?Sized + io::Write, |
1592 | | { |
1593 | 0 | let mut buffer = itoa::Buffer::new(); |
1594 | 0 | let s = buffer.format(value); |
1595 | 0 | writer.write_all(s.as_bytes()) |
1596 | 0 | } |
1597 | | |
1598 | | /// Writes an integer value like `123` to the specified writer. |
1599 | | #[inline] |
1600 | 0 | fn write_u16<W>(&mut self, writer: &mut W, value: u16) -> io::Result<()> |
1601 | 0 | where |
1602 | 0 | W: ?Sized + io::Write, |
1603 | | { |
1604 | 0 | let mut buffer = itoa::Buffer::new(); |
1605 | 0 | let s = buffer.format(value); |
1606 | 0 | writer.write_all(s.as_bytes()) |
1607 | 0 | } |
1608 | | |
1609 | | /// Writes an integer value like `123` to the specified writer. |
1610 | | #[inline] |
1611 | 0 | fn write_u32<W>(&mut self, writer: &mut W, value: u32) -> io::Result<()> |
1612 | 0 | where |
1613 | 0 | W: ?Sized + io::Write, |
1614 | | { |
1615 | 0 | let mut buffer = itoa::Buffer::new(); |
1616 | 0 | let s = buffer.format(value); |
1617 | 0 | writer.write_all(s.as_bytes()) |
1618 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_u32::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <_ as serde_json::ser::Formatter>::write_u32::<_> |
1619 | | |
1620 | | /// Writes an integer value like `123` to the specified writer. |
1621 | | #[inline] |
1622 | 0 | fn write_u64<W>(&mut self, writer: &mut W, value: u64) -> io::Result<()> |
1623 | 0 | where |
1624 | 0 | W: ?Sized + io::Write, |
1625 | | { |
1626 | 0 | let mut buffer = itoa::Buffer::new(); |
1627 | 0 | let s = buffer.format(value); |
1628 | 0 | writer.write_all(s.as_bytes()) |
1629 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_u64::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_u64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_u64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1630 | | |
1631 | | /// Writes an integer value like `123` to the specified writer. |
1632 | | #[inline] |
1633 | 0 | fn write_u128<W>(&mut self, writer: &mut W, value: u128) -> io::Result<()> |
1634 | 0 | where |
1635 | 0 | W: ?Sized + io::Write, |
1636 | | { |
1637 | 0 | let mut buffer = itoa::Buffer::new(); |
1638 | 0 | let s = buffer.format(value); |
1639 | 0 | writer.write_all(s.as_bytes()) |
1640 | 0 | } |
1641 | | |
1642 | | /// Writes a floating point value like `-31.26e+12` to the specified writer. |
1643 | | #[inline] |
1644 | 0 | fn write_f32<W>(&mut self, writer: &mut W, value: f32) -> io::Result<()> |
1645 | 0 | where |
1646 | 0 | W: ?Sized + io::Write, |
1647 | | { |
1648 | 0 | let mut buffer = ryu::Buffer::new(); |
1649 | 0 | let s = buffer.format_finite(value); |
1650 | 0 | writer.write_all(s.as_bytes()) |
1651 | 0 | } |
1652 | | |
1653 | | /// Writes a floating point value like `-31.26e+12` to the specified writer. |
1654 | | #[inline] |
1655 | 0 | fn write_f64<W>(&mut self, writer: &mut W, value: f64) -> io::Result<()> |
1656 | 0 | where |
1657 | 0 | W: ?Sized + io::Write, |
1658 | | { |
1659 | 0 | let mut buffer = ryu::Buffer::new(); |
1660 | 0 | let s = buffer.format_finite(value); |
1661 | 0 | writer.write_all(s.as_bytes()) |
1662 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_f64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_f64::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1663 | | |
1664 | | /// Writes a number that has already been rendered to a string. |
1665 | | #[inline] |
1666 | 0 | fn write_number_str<W>(&mut self, writer: &mut W, value: &str) -> io::Result<()> |
1667 | 0 | where |
1668 | 0 | W: ?Sized + io::Write, |
1669 | | { |
1670 | 0 | writer.write_all(value.as_bytes()) |
1671 | 0 | } |
1672 | | |
1673 | | /// Called before each series of `write_string_fragment` and |
1674 | | /// `write_char_escape`. Writes a `"` to the specified writer. |
1675 | | #[inline] |
1676 | 0 | fn begin_string<W>(&mut self, writer: &mut W) -> io::Result<()> |
1677 | 0 | where |
1678 | 0 | W: ?Sized + io::Write, |
1679 | | { |
1680 | 0 | writer.write_all(b"\"") |
1681 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_string::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_string::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1682 | | |
1683 | | /// Called after each series of `write_string_fragment` and |
1684 | | /// `write_char_escape`. Writes a `"` to the specified writer. |
1685 | | #[inline] |
1686 | 0 | fn end_string<W>(&mut self, writer: &mut W) -> io::Result<()> |
1687 | 0 | where |
1688 | 0 | W: ?Sized + io::Write, |
1689 | | { |
1690 | 0 | writer.write_all(b"\"") |
1691 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_string::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_string::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_string::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1692 | | |
1693 | | /// Writes a string fragment that doesn't need any escaping to the |
1694 | | /// specified writer. |
1695 | | #[inline] |
1696 | 0 | fn write_string_fragment<W>(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> |
1697 | 0 | where |
1698 | 0 | W: ?Sized + io::Write, |
1699 | | { |
1700 | 0 | writer.write_all(fragment.as_bytes()) |
1701 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_string_fragment::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_string_fragment::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_string_fragment::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_string_fragment::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_string_fragment::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1702 | | |
1703 | | /// Writes a character escape code to the specified writer. |
1704 | | #[inline] |
1705 | 0 | fn write_char_escape<W>(&mut self, writer: &mut W, char_escape: CharEscape) -> io::Result<()> |
1706 | 0 | where |
1707 | 0 | W: ?Sized + io::Write, |
1708 | | { |
1709 | | use self::CharEscape::*; |
1710 | | |
1711 | 0 | let s = match char_escape { |
1712 | 0 | Quote => b"\\\"", |
1713 | 0 | ReverseSolidus => b"\\\\", |
1714 | 0 | Solidus => b"\\/", |
1715 | 0 | Backspace => b"\\b", |
1716 | 0 | FormFeed => b"\\f", |
1717 | 0 | LineFeed => b"\\n", |
1718 | 0 | CarriageReturn => b"\\r", |
1719 | 0 | Tab => b"\\t", |
1720 | 0 | AsciiControl(byte) => { |
1721 | | static HEX_DIGITS: [u8; 16] = *b"0123456789abcdef"; |
1722 | 0 | let bytes = &[ |
1723 | 0 | b'\\', |
1724 | 0 | b'u', |
1725 | 0 | b'0', |
1726 | 0 | b'0', |
1727 | 0 | HEX_DIGITS[(byte >> 4) as usize], |
1728 | 0 | HEX_DIGITS[(byte & 0xF) as usize], |
1729 | 0 | ]; |
1730 | 0 | return writer.write_all(bytes); |
1731 | | } |
1732 | | }; |
1733 | | |
1734 | 0 | writer.write_all(s) |
1735 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_char_escape::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_char_escape::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_char_escape::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::write_char_escape::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::write_char_escape::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1736 | | |
1737 | | /// Called before every array. Writes a `[` to the specified |
1738 | | /// writer. |
1739 | | #[inline] |
1740 | 0 | fn begin_array<W>(&mut self, writer: &mut W) -> io::Result<()> |
1741 | 0 | where |
1742 | 0 | W: ?Sized + io::Write, |
1743 | | { |
1744 | 0 | writer.write_all(b"[") |
1745 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_array::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_array::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1746 | | |
1747 | | /// Called after every array. Writes a `]` to the specified |
1748 | | /// writer. |
1749 | | #[inline] |
1750 | 0 | fn end_array<W>(&mut self, writer: &mut W) -> io::Result<()> |
1751 | 0 | where |
1752 | 0 | W: ?Sized + io::Write, |
1753 | | { |
1754 | 0 | writer.write_all(b"]") |
1755 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_array::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_array::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1756 | | |
1757 | | /// Called before every array value. Writes a `,` if needed to |
1758 | | /// the specified writer. |
1759 | | #[inline] |
1760 | 0 | fn begin_array_value<W>(&mut self, writer: &mut W, first: bool) -> io::Result<()> |
1761 | 0 | where |
1762 | 0 | W: ?Sized + io::Write, |
1763 | | { |
1764 | 0 | if first { |
1765 | 0 | Ok(()) |
1766 | | } else { |
1767 | 0 | writer.write_all(b",") |
1768 | | } |
1769 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_array_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_array_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1770 | | |
1771 | | /// Called after every array value. |
1772 | | #[inline] |
1773 | 0 | fn end_array_value<W>(&mut self, _writer: &mut W) -> io::Result<()> |
1774 | 0 | where |
1775 | 0 | W: ?Sized + io::Write, |
1776 | | { |
1777 | 0 | Ok(()) |
1778 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_array_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_array_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1779 | | |
1780 | | /// Called before every object. Writes a `{` to the specified |
1781 | | /// writer. |
1782 | | #[inline] |
1783 | 0 | fn begin_object<W>(&mut self, writer: &mut W) -> io::Result<()> |
1784 | 0 | where |
1785 | 0 | W: ?Sized + io::Write, |
1786 | | { |
1787 | 0 | writer.write_all(b"{") |
1788 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1789 | | |
1790 | | /// Called after every object. Writes a `}` to the specified |
1791 | | /// writer. |
1792 | | #[inline] |
1793 | 0 | fn end_object<W>(&mut self, writer: &mut W) -> io::Result<()> |
1794 | 0 | where |
1795 | 0 | W: ?Sized + io::Write, |
1796 | | { |
1797 | 0 | writer.write_all(b"}") |
1798 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1799 | | |
1800 | | /// Called before every object key. |
1801 | | #[inline] |
1802 | 0 | fn begin_object_key<W>(&mut self, writer: &mut W, first: bool) -> io::Result<()> |
1803 | 0 | where |
1804 | 0 | W: ?Sized + io::Write, |
1805 | | { |
1806 | 0 | if first { |
1807 | 0 | Ok(()) |
1808 | | } else { |
1809 | 0 | writer.write_all(b",") |
1810 | | } |
1811 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_key::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1812 | | |
1813 | | /// Called after every object key. A `:` should be written to the |
1814 | | /// specified writer by either this method or |
1815 | | /// `begin_object_value`. |
1816 | | #[inline] |
1817 | 0 | fn end_object_key<W>(&mut self, _writer: &mut W) -> io::Result<()> |
1818 | 0 | where |
1819 | 0 | W: ?Sized + io::Write, |
1820 | | { |
1821 | 0 | Ok(()) |
1822 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object_key::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_key::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1823 | | |
1824 | | /// Called before every object value. A `:` should be written to |
1825 | | /// the specified writer by either this method or |
1826 | | /// `end_object_key`. |
1827 | | #[inline] |
1828 | 0 | fn begin_object_value<W>(&mut self, writer: &mut W) -> io::Result<()> |
1829 | 0 | where |
1830 | 0 | W: ?Sized + io::Write, |
1831 | | { |
1832 | 0 | writer.write_all(b":") |
1833 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::begin_object_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1834 | | |
1835 | | /// Called after every object value. |
1836 | | #[inline] |
1837 | 0 | fn end_object_value<W>(&mut self, _writer: &mut W) -> io::Result<()> |
1838 | 0 | where |
1839 | 0 | W: ?Sized + io::Write, |
1840 | | { |
1841 | 0 | Ok(()) |
1842 | 0 | } Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::CompactFormatter as serde_json::ser::Formatter>::end_object_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1843 | | |
1844 | | /// Writes a raw JSON fragment that doesn't need any escaping to the |
1845 | | /// specified writer. |
1846 | | #[inline] |
1847 | 0 | fn write_raw_fragment<W>(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> |
1848 | 0 | where |
1849 | 0 | W: ?Sized + io::Write, |
1850 | | { |
1851 | 0 | writer.write_all(fragment.as_bytes()) |
1852 | 0 | } |
1853 | | } |
1854 | | |
1855 | | /// This structure compacts a JSON value with no extra whitespace. |
1856 | | #[derive(Clone, Debug)] |
1857 | | pub struct CompactFormatter; |
1858 | | |
1859 | | impl Formatter for CompactFormatter {} |
1860 | | |
1861 | | /// This structure pretty prints a JSON value to make it human readable. |
1862 | | #[derive(Clone, Debug)] |
1863 | | pub struct PrettyFormatter<'a> { |
1864 | | current_indent: usize, |
1865 | | has_value: bool, |
1866 | | indent: &'a [u8], |
1867 | | } |
1868 | | |
1869 | | impl<'a> PrettyFormatter<'a> { |
1870 | | /// Construct a pretty printer formatter that defaults to using two spaces for indentation. |
1871 | 0 | pub fn new() -> Self { |
1872 | 0 | PrettyFormatter::with_indent(b" ") |
1873 | 0 | } |
1874 | | |
1875 | | /// Construct a pretty printer formatter that uses the `indent` string for indentation. |
1876 | 0 | pub fn with_indent(indent: &'a [u8]) -> Self { |
1877 | 0 | PrettyFormatter { |
1878 | 0 | current_indent: 0, |
1879 | 0 | has_value: false, |
1880 | 0 | indent, |
1881 | 0 | } |
1882 | 0 | } |
1883 | | } |
1884 | | |
1885 | | impl<'a> Default for PrettyFormatter<'a> { |
1886 | 0 | fn default() -> Self { |
1887 | 0 | PrettyFormatter::new() |
1888 | 0 | } |
1889 | | } |
1890 | | |
1891 | | impl<'a> Formatter for PrettyFormatter<'a> { |
1892 | | #[inline] |
1893 | 0 | fn begin_array<W>(&mut self, writer: &mut W) -> io::Result<()> |
1894 | 0 | where |
1895 | 0 | W: ?Sized + io::Write, |
1896 | | { |
1897 | 0 | self.current_indent += 1; |
1898 | 0 | self.has_value = false; |
1899 | 0 | writer.write_all(b"[") |
1900 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_array::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_array::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1901 | | |
1902 | | #[inline] |
1903 | 0 | fn end_array<W>(&mut self, writer: &mut W) -> io::Result<()> |
1904 | 0 | where |
1905 | 0 | W: ?Sized + io::Write, |
1906 | | { |
1907 | 0 | self.current_indent -= 1; |
1908 | | |
1909 | 0 | if self.has_value { |
1910 | 0 | tri!(writer.write_all(b"\n")); |
1911 | 0 | tri!(indent(writer, self.current_indent, self.indent)); |
1912 | 0 | } |
1913 | | |
1914 | 0 | writer.write_all(b"]") |
1915 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_array::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_array::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1916 | | |
1917 | | #[inline] |
1918 | 0 | fn begin_array_value<W>(&mut self, writer: &mut W, first: bool) -> io::Result<()> |
1919 | 0 | where |
1920 | 0 | W: ?Sized + io::Write, |
1921 | | { |
1922 | 0 | tri!(writer.write_all(if first { b"\n" } else { b",\n" })); |
1923 | 0 | indent(writer, self.current_indent, self.indent) |
1924 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_array_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_array_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1925 | | |
1926 | | #[inline] |
1927 | 0 | fn end_array_value<W>(&mut self, _writer: &mut W) -> io::Result<()> |
1928 | 0 | where |
1929 | 0 | W: ?Sized + io::Write, |
1930 | | { |
1931 | 0 | self.has_value = true; |
1932 | 0 | Ok(()) |
1933 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_array_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_array_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1934 | | |
1935 | | #[inline] |
1936 | 0 | fn begin_object<W>(&mut self, writer: &mut W) -> io::Result<()> |
1937 | 0 | where |
1938 | 0 | W: ?Sized + io::Write, |
1939 | | { |
1940 | 0 | self.current_indent += 1; |
1941 | 0 | self.has_value = false; |
1942 | 0 | writer.write_all(b"{") |
1943 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1944 | | |
1945 | | #[inline] |
1946 | 0 | fn end_object<W>(&mut self, writer: &mut W) -> io::Result<()> |
1947 | 0 | where |
1948 | 0 | W: ?Sized + io::Write, |
1949 | | { |
1950 | 0 | self.current_indent -= 1; |
1951 | | |
1952 | 0 | if self.has_value { |
1953 | 0 | tri!(writer.write_all(b"\n")); |
1954 | 0 | tri!(indent(writer, self.current_indent, self.indent)); |
1955 | 0 | } |
1956 | | |
1957 | 0 | writer.write_all(b"}") |
1958 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1959 | | |
1960 | | #[inline] |
1961 | 0 | fn begin_object_key<W>(&mut self, writer: &mut W, first: bool) -> io::Result<()> |
1962 | 0 | where |
1963 | 0 | W: ?Sized + io::Write, |
1964 | | { |
1965 | 0 | tri!(writer.write_all(if first { b"\n" } else { b",\n" })); |
1966 | 0 | indent(writer, self.current_indent, self.indent) |
1967 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object_key::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object_key::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1968 | | |
1969 | | #[inline] |
1970 | 0 | fn begin_object_value<W>(&mut self, writer: &mut W) -> io::Result<()> |
1971 | 0 | where |
1972 | 0 | W: ?Sized + io::Write, |
1973 | | { |
1974 | 0 | writer.write_all(b": ") |
1975 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::begin_object_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1976 | | |
1977 | | #[inline] |
1978 | 0 | fn end_object_value<W>(&mut self, _writer: &mut W) -> io::Result<()> |
1979 | 0 | where |
1980 | 0 | W: ?Sized + io::Write, |
1981 | | { |
1982 | 0 | self.has_value = true; |
1983 | 0 | Ok(()) |
1984 | 0 | } Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object_value::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: <serde_json::ser::PrettyFormatter as serde_json::ser::Formatter>::end_object_value::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |
1985 | | } |
1986 | | |
1987 | 0 | fn format_escaped_str<W, F>(writer: &mut W, formatter: &mut F, value: &str) -> io::Result<()> |
1988 | 0 | where |
1989 | 0 | W: ?Sized + io::Write, |
1990 | 0 | F: ?Sized + Formatter, |
1991 | | { |
1992 | 0 | tri!(formatter.begin_string(writer)); |
1993 | 0 | tri!(format_escaped_str_contents(writer, formatter, value)); |
1994 | 0 | formatter.end_string(writer) |
1995 | 0 | } Unexecuted instantiation: serde_json::ser::format_escaped_str::<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str::<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str::<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> |
1996 | | |
1997 | 0 | fn format_escaped_str_contents<W, F>( |
1998 | 0 | writer: &mut W, |
1999 | 0 | formatter: &mut F, |
2000 | 0 | value: &str, |
2001 | 0 | ) -> io::Result<()> |
2002 | 0 | where |
2003 | 0 | W: ?Sized + io::Write, |
2004 | 0 | F: ?Sized + Formatter, |
2005 | | { |
2006 | 0 | let bytes = value.as_bytes(); |
2007 | | |
2008 | 0 | let mut start = 0; |
2009 | | |
2010 | 0 | for (i, &byte) in bytes.iter().enumerate() { |
2011 | 0 | let escape = ESCAPE[byte as usize]; |
2012 | 0 | if escape == 0 { |
2013 | 0 | continue; |
2014 | 0 | } |
2015 | | |
2016 | 0 | if start < i { |
2017 | 0 | tri!(formatter.write_string_fragment(writer, &value[start..i])); |
2018 | 0 | } |
2019 | | |
2020 | 0 | let char_escape = CharEscape::from_escape_table(escape, byte); |
2021 | 0 | tri!(formatter.write_char_escape(writer, char_escape)); |
2022 | | |
2023 | 0 | start = i + 1; |
2024 | | } |
2025 | | |
2026 | 0 | if start == bytes.len() { |
2027 | 0 | return Ok(()); |
2028 | 0 | } |
2029 | | |
2030 | 0 | formatter.write_string_fragment(writer, &value[start..]) |
2031 | 0 | } Unexecuted instantiation: serde_json::ser::format_escaped_str_contents::<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str_contents::<&mut alloc::vec::Vec<u8>, serde_json::ser::CompactFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str_contents::<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str_contents::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::PrettyFormatter> Unexecuted instantiation: serde_json::ser::format_escaped_str_contents::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::ser::CompactFormatter> |
2032 | | |
2033 | | const BB: u8 = b'b'; // \x08 |
2034 | | const TT: u8 = b't'; // \x09 |
2035 | | const NN: u8 = b'n'; // \x0A |
2036 | | const FF: u8 = b'f'; // \x0C |
2037 | | const RR: u8 = b'r'; // \x0D |
2038 | | const QU: u8 = b'"'; // \x22 |
2039 | | const BS: u8 = b'\\'; // \x5C |
2040 | | const UU: u8 = b'u'; // \x00...\x1F except the ones above |
2041 | | const __: u8 = 0; |
2042 | | |
2043 | | // Lookup table of escape sequences. A value of b'x' at index i means that byte |
2044 | | // i is escaped as "\x" in JSON. A value of 0 means that byte i is not escaped. |
2045 | | static ESCAPE: [u8; 256] = [ |
2046 | | // 1 2 3 4 5 6 7 8 9 A B C D E F |
2047 | | UU, UU, UU, UU, UU, UU, UU, UU, BB, TT, NN, UU, FF, RR, UU, UU, // 0 |
2048 | | UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, // 1 |
2049 | | __, __, QU, __, __, __, __, __, __, __, __, __, __, __, __, __, // 2 |
2050 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 3 |
2051 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 4 |
2052 | | __, __, __, __, __, __, __, __, __, __, __, __, BS, __, __, __, // 5 |
2053 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 6 |
2054 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 7 |
2055 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 8 |
2056 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 9 |
2057 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // A |
2058 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // B |
2059 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // C |
2060 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // D |
2061 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // E |
2062 | | __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // F |
2063 | | ]; |
2064 | | |
2065 | | /// Serialize the given data structure as JSON into the IO stream. |
2066 | | /// |
2067 | | /// Serialization guarantees it only feeds valid UTF-8 sequences to the writer. |
2068 | | /// |
2069 | | /// # Errors |
2070 | | /// |
2071 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2072 | | /// fail, or if `T` contains a map with non-string keys. |
2073 | | #[inline] |
2074 | | #[cfg_attr(docsrs, doc(cfg(feature = "std")))] |
2075 | 0 | pub fn to_writer<W, T>(writer: W, value: &T) -> Result<()> |
2076 | 0 | where |
2077 | 0 | W: io::Write, |
2078 | 0 | T: ?Sized + Serialize, |
2079 | | { |
2080 | 0 | let mut ser = Serializer::new(writer); |
2081 | 0 | value.serialize(&mut ser) |
2082 | 0 | } Unexecuted instantiation: serde_json::ser::to_writer::<&mut alloc::vec::Vec<u8>, audio_processor::shape::Format> Unexecuted instantiation: serde_json::ser::to_writer::<&mut alloc::vec::Vec<u8>, audio_processor::processors::peer::messages::Init> Unexecuted instantiation: serde_json::ser::to_writer::<&mut alloc::vec::Vec<u8>, std::collections::hash::map::HashMap<alloc::string::String, alloc::string::String>> Unexecuted instantiation: serde_json::ser::to_writer::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::value::Value> |
2083 | | |
2084 | | /// Serialize the given data structure as pretty-printed JSON into the IO |
2085 | | /// stream. |
2086 | | /// |
2087 | | /// Serialization guarantees it only feeds valid UTF-8 sequences to the writer. |
2088 | | /// |
2089 | | /// # Errors |
2090 | | /// |
2091 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2092 | | /// fail, or if `T` contains a map with non-string keys. |
2093 | | #[inline] |
2094 | | #[cfg_attr(docsrs, doc(cfg(feature = "std")))] |
2095 | 0 | pub fn to_writer_pretty<W, T>(writer: W, value: &T) -> Result<()> |
2096 | 0 | where |
2097 | 0 | W: io::Write, |
2098 | 0 | T: ?Sized + Serialize, |
2099 | | { |
2100 | 0 | let mut ser = Serializer::pretty(writer); |
2101 | 0 | value.serialize(&mut ser) |
2102 | 0 | } Unexecuted instantiation: serde_json::ser::to_writer_pretty::<&mut alloc::vec::Vec<u8>, cras_s2::S2> Unexecuted instantiation: serde_json::ser::to_writer_pretty::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter, serde_json::value::Value> |
2103 | | |
2104 | | /// Serialize the given data structure as a JSON byte vector. |
2105 | | /// |
2106 | | /// # Errors |
2107 | | /// |
2108 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2109 | | /// fail, or if `T` contains a map with non-string keys. |
2110 | | #[inline] |
2111 | 0 | pub fn to_vec<T>(value: &T) -> Result<Vec<u8>> |
2112 | 0 | where |
2113 | 0 | T: ?Sized + Serialize, |
2114 | | { |
2115 | 0 | let mut writer = Vec::with_capacity(128); |
2116 | 0 | tri!(to_writer(&mut writer, value)); |
2117 | 0 | Ok(writer) |
2118 | 0 | } Unexecuted instantiation: serde_json::ser::to_vec::<audio_processor::shape::Format> Unexecuted instantiation: serde_json::ser::to_vec::<audio_processor::processors::peer::messages::Init> Unexecuted instantiation: serde_json::ser::to_vec::<std::collections::hash::map::HashMap<alloc::string::String, alloc::string::String>> Unexecuted instantiation: serde_json::ser::to_vec::<_> |
2119 | | |
2120 | | /// Serialize the given data structure as a pretty-printed JSON byte vector. |
2121 | | /// |
2122 | | /// # Errors |
2123 | | /// |
2124 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2125 | | /// fail, or if `T` contains a map with non-string keys. |
2126 | | #[inline] |
2127 | 0 | pub fn to_vec_pretty<T>(value: &T) -> Result<Vec<u8>> |
2128 | 0 | where |
2129 | 0 | T: ?Sized + Serialize, |
2130 | | { |
2131 | 0 | let mut writer = Vec::with_capacity(128); |
2132 | 0 | tri!(to_writer_pretty(&mut writer, value)); |
2133 | 0 | Ok(writer) |
2134 | 0 | } Unexecuted instantiation: serde_json::ser::to_vec_pretty::<cras_s2::S2> Unexecuted instantiation: serde_json::ser::to_vec_pretty::<_> |
2135 | | |
2136 | | /// Serialize the given data structure as a String of JSON. |
2137 | | /// |
2138 | | /// # Errors |
2139 | | /// |
2140 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2141 | | /// fail, or if `T` contains a map with non-string keys. |
2142 | | #[inline] |
2143 | 0 | pub fn to_string<T>(value: &T) -> Result<String> |
2144 | 0 | where |
2145 | 0 | T: ?Sized + Serialize, |
2146 | | { |
2147 | 0 | let vec = tri!(to_vec(value)); |
2148 | 0 | let string = unsafe { |
2149 | | // We do not emit invalid UTF-8. |
2150 | 0 | String::from_utf8_unchecked(vec) |
2151 | | }; |
2152 | 0 | Ok(string) |
2153 | 0 | } Unexecuted instantiation: serde_json::ser::to_string::<audio_processor::shape::Format> Unexecuted instantiation: serde_json::ser::to_string::<audio_processor::processors::peer::messages::Init> Unexecuted instantiation: serde_json::ser::to_string::<std::collections::hash::map::HashMap<alloc::string::String, alloc::string::String>> Unexecuted instantiation: serde_json::ser::to_string::<_> |
2154 | | |
2155 | | /// Serialize the given data structure as a pretty-printed String of JSON. |
2156 | | /// |
2157 | | /// # Errors |
2158 | | /// |
2159 | | /// Serialization can fail if `T`'s implementation of `Serialize` decides to |
2160 | | /// fail, or if `T` contains a map with non-string keys. |
2161 | | #[inline] |
2162 | 0 | pub fn to_string_pretty<T>(value: &T) -> Result<String> |
2163 | 0 | where |
2164 | 0 | T: ?Sized + Serialize, |
2165 | | { |
2166 | 0 | let vec = tri!(to_vec_pretty(value)); |
2167 | 0 | let string = unsafe { |
2168 | | // We do not emit invalid UTF-8. |
2169 | 0 | String::from_utf8_unchecked(vec) |
2170 | | }; |
2171 | 0 | Ok(string) |
2172 | 0 | } Unexecuted instantiation: serde_json::ser::to_string_pretty::<cras_s2::S2> Unexecuted instantiation: serde_json::ser::to_string_pretty::<_> |
2173 | | |
2174 | 0 | fn indent<W>(wr: &mut W, n: usize, s: &[u8]) -> io::Result<()> |
2175 | 0 | where |
2176 | 0 | W: ?Sized + io::Write, |
2177 | | { |
2178 | 0 | for _ in 0..n { |
2179 | 0 | tri!(wr.write_all(s)); |
2180 | | } |
2181 | | |
2182 | 0 | Ok(()) |
2183 | 0 | } Unexecuted instantiation: serde_json::ser::indent::<&mut alloc::vec::Vec<u8>> Unexecuted instantiation: serde_json::ser::indent::<&mut <serde_json::value::Value as core::fmt::Display>::fmt::WriterFormatter> |