1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
use {
crate::{
PrimitiveTy,
wincode_extra::{LenMap, Map},
},
alloc::{borrow::Cow, vec::Vec},
core::{marker::PhantomData, mem::MaybeUninit},
wincode::{
ReadError, ReadResult, SchemaRead, SchemaReadContext,
config::{Config, ConfigCore, DefaultConfig},
context::Len,
io::Reader,
len::SeqLen,
},
};
/// An owned, dynamically typed primitive value.
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
pub enum PrimitiveValue {
/// An unsigned 8-bit integer.
U8(u8),
/// An unsigned 16-bit integer.
U16(u16),
/// An unsigned 32-bit integer.
U32(u32),
/// An unsigned 64-bit integer.
U64(u64),
/// A signed 8-bit integer.
I8(i8),
/// A signed 16-bit integer.
I16(i16),
/// A signed 32-bit integer.
I32(i32),
/// A signed 64-bit integer.
I64(i64),
/// A 32-bit floating-point number.
F32(f32),
/// A 64-bit floating-point number.
F64(f64),
/// A Boolean value.
Bool(bool),
}
impl PrimitiveValue {
/// Returns the complete encoded width of this primitive, in bytes.
///
/// Primitive encodings have no length prefix, so this is also the complete
/// serialized size under wincode's [`DefaultConfig`].
#[inline]
pub const fn size(self) -> usize {
match self {
PrimitiveValue::U8(_) => 1,
PrimitiveValue::U16(_) => 2,
PrimitiveValue::U32(_) => 4,
PrimitiveValue::U64(_) => 8,
PrimitiveValue::I8(_) => 1,
PrimitiveValue::I16(_) => 2,
PrimitiveValue::I32(_) => 4,
PrimitiveValue::I64(_) => 8,
PrimitiveValue::F32(_) => 4,
PrimitiveValue::F64(_) => 8,
PrimitiveValue::Bool(_) => 1,
}
}
}
/// A value decoded from a runtime [`Ty`](crate::Ty).
///
/// Scalar primitives are stored by value. Strings and byte payloads use
/// [`Cow`] so they can borrow from readers that support stable borrowing.
/// Non-byte primitive arrays and vectors are represented by [`LazyVec`] and
/// decoded as they are iterated.
#[derive(Debug, Clone, PartialEq)]
pub enum Value<'a> {
/// An unsigned 8-bit integer.
U8(u8),
/// An unsigned 16-bit integer.
U16(u16),
/// An unsigned 32-bit integer.
U32(u32),
/// An unsigned 64-bit integer.
U64(u64),
/// A signed 8-bit integer.
I8(i8),
/// A signed 16-bit integer.
I16(i16),
/// A signed 32-bit integer.
I32(i32),
/// A signed 64-bit integer.
I64(i64),
/// A 32-bit floating-point number.
F32(f32),
/// A 64-bit floating-point number.
F64(f64),
/// A Boolean value.
Bool(bool),
/// A UTF-8 string, borrowed from the input when possible.
String(Cow<'a, str>),
/// A byte array or byte vector, borrowed from the input when possible.
Bytes(Cow<'a, [u8]>),
/// A lazily decoded array or vector of non-byte primitives.
Vec(LazyVec<'a>),
}
impl Value<'_> {
/// Returns the number of encoded payload bytes held by this value.
///
/// For scalar primitives this is their complete encoded width. For
/// strings, bytes, and lazy vectors this is only the payload length and
/// excludes any length prefix from a dynamically sized string or vector.
/// Consequently, this is not necessarily the complete serialized size of
/// the original field.
#[inline]
pub fn size(&self) -> usize {
match self {
Value::U8(_) => 1,
Value::U16(_) => 2,
Value::U32(_) => 4,
Value::U64(_) => 8,
Value::I8(_) => 1,
Value::I16(_) => 2,
Value::I32(_) => 4,
Value::I64(_) => 8,
Value::F32(_) => 4,
Value::F64(_) => 8,
Value::Bool(_) => 1,
Value::String(str) => str.len(),
Value::Bytes(bytes) => bytes.len(),
Value::Vec(vec) => vec.payload.len(),
}
}
}
/// A lazily decoded vector of fixed-width primitive values.
///
/// The encoded payload remains borrowed when the input reader supports stable
/// borrowing. Use [`Self::try_iter_as`] to iterate by reference when the
/// concrete element type is known, [`Self::try_into_iter_as`] to create an
/// owning iterator, or [`Self::into_dyn_vec`] to decode dynamically typed
/// values.
#[derive(Debug, Clone, PartialEq)]
pub struct LazyVec<'a> {
ty: PrimitiveTy,
payload: Cow<'a, [u8]>,
/// The length of the vector, in _elements_ (not bytes).
///
/// Invariant: `payload.len() == len * ty.size()`.
len: usize,
}
/// Lazy-vector iterator types.
pub mod lazy_vec {
use {super::*, crate::DynPrimitiveTy};
/// A borrowing, lazy iterator over the elements of a [`LazyVec`].
///
/// Each item is decoded only when [`Iterator::next`] is called.
#[derive(Debug, Clone, Copy)]
pub struct Iter<'a, As> {
payload: &'a [u8],
len: usize,
index: usize,
_marker: PhantomData<As>,
}
/// An owning, lazy iterator over the elements of a [`LazyVec`].
///
/// Each item is decoded only when [`Iterator::next`] is called.
#[derive(Debug, Clone)]
pub struct IntoIter<'a, As> {
payload: Cow<'a, [u8]>,
len: usize,
index: usize,
_marker: PhantomData<As>,
}
impl<'a> LazyVec<'a> {
/// # Safety
///
/// `payload.len()` must equal `len * ty.size()`.
pub(crate) unsafe fn new_unchecked(
ty: PrimitiveTy,
len: usize,
payload: Cow<'a, [u8]>,
) -> Self {
Self { ty, len, payload }
}
/// Returns a borrowing, lazy iterator of `As` values.
///
/// The requested type must match the primitive element type recorded in
/// the schema. This prevents, for example, interpreting the payload of
/// a `Vec<u64>` as a sequence of `u8` values.
///
/// This method validates the element type and its width, but it does
/// not decode any elements. Decoding happens as the returned iterator
/// is advanced, and each item is returned as a [`ReadResult`].
/// Consequently, malformed element encodings are reported by
/// the iterator item that encounters them rather than by this
/// method.
///
/// The iterator borrows this lazy vector. Multiple iterators can be
/// created without cloning or decoding the payload.
///
/// To iterate, `As` must also implement
/// [`SchemaRead<DefaultConfig, Dst = As>`](SchemaRead).
///
/// # Errors
///
/// Returns an error if:
///
/// - `As` does not match the vector's recorded primitive element type;
/// or
/// - the size of `As` does not match the recorded element width.
///
/// # Examples
///
/// ```
/// use wincode::{ReadResult, SchemaRead, SchemaWrite};
/// use wincode_dynamic::{Decoder, SchemaDynamic, Value};
///
/// #[derive(SchemaDynamic, SchemaRead, SchemaWrite)]
/// struct Message {
/// values: Vec<u64>,
/// }
///
/// let encoded = wincode::serialize(&Message {
/// values: vec![10, 20, 30],
/// })
/// .expect("serialize message");
/// let schema = Message::schema();
/// let decoder = Decoder::new(&schema);
/// let mut fields = decoder.fields(encoded.as_slice())?;
///
/// let field = fields.next().expect("values field")?;
/// assert_eq!(field.name(), "values");
/// let Value::Vec(values) = field.value() else {
/// panic!("expected a vector");
/// };
/// let values = values
/// .try_iter_as::<u64>()?
/// .collect::<ReadResult<Vec<_>>>()?;
///
/// assert_eq!(values, [10, 20, 30]);
/// # Ok::<(), wincode::ReadError>(())
/// ```
#[inline]
pub fn try_iter_as<'iter, As>(&'iter self) -> ReadResult<Iter<'iter, As>>
where
As: DynPrimitiveTy,
{
validate_element_type::<As>(self.ty)?;
Ok(Iter {
len: self.len,
payload: self.payload.as_ref(),
index: 0,
_marker: PhantomData,
})
}
/// Converts this vector into an owning, lazy iterator of `As` values.
///
/// This performs the same type validation as [`Self::try_iter_as`], but
/// consumes the lazy vector and moves its payload into the iterator.
/// Borrowed payloads remain borrowed, and owned payloads are moved
/// without cloning or reallocating them.
///
/// # Errors
///
/// Returns an error if `As` does not match the vector's recorded
/// primitive element type or width.
#[inline]
pub fn try_into_iter_as<As>(self) -> ReadResult<IntoIter<'a, As>>
where
As: DynPrimitiveTy,
{
validate_element_type::<As>(self.ty)?;
Ok(IntoIter {
len: self.len,
payload: self.payload,
index: 0,
_marker: PhantomData,
})
}
/// Converts this lazy vector into a [`Vec<PrimitiveValue>`] by decoding
/// all elements using the vector's recorded primitive element type.
///
/// # Errors
///
/// Returns the first element decoding error encountered in the payload.
#[inline]
pub fn into_dyn_vec(self) -> ReadResult<Vec<PrimitiveValue>> {
<<DefaultConfig as Config>::LengthEncoding as SeqLen<DefaultConfig>>::prealloc_check::<
PrimitiveValue,
>(self.len)?;
<Array<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::get_with_context(
(Len(self.len), self.ty),
&self.payload[..],
)
}
/// Returns the number of elements in the vector.
#[inline]
pub const fn len(&self) -> usize {
self.len
}
/// Returns `true` if the vector contains no elements.
#[inline]
pub fn is_empty(&self) -> bool {
self.payload.is_empty()
}
#[cfg(all(test, feature = "std"))]
pub(crate) fn has_borrowed_payload(&self) -> bool {
matches!(self.payload, Cow::Borrowed(_))
}
/// Returns the vector's primitive element type.
#[inline]
pub const fn ty(&self) -> PrimitiveTy {
self.ty
}
}
#[inline]
fn validate_element_type<As: DynPrimitiveTy>(ty: PrimitiveTy) -> ReadResult<()> {
#[cold]
const fn ty_mismatch() -> ReadError {
ReadError::Custom("lazy vector element type mismatch")
}
if As::TYPE != ty || ty.size() != size_of::<As>() {
return Err(ty_mismatch());
}
Ok(())
}
macro_rules! impl_iterator {
($iter:ident) => {
impl<As> Iterator for $iter<'_, As>
where
As: for<'de> SchemaRead<'de, DefaultConfig, Dst = As>,
{
type Item = ReadResult<As>;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
if self.index >= self.len {
return None;
}
let start = self.index * size_of::<As>();
// SAFETY:
// - `payload.len()` is an exact multiple of `size_of::<As>()`.
// - `len` is `payload.len() / size_of::<As>()`.
// - `index < len`, so `start < payload.len()`.
let remaining = unsafe { self.payload.as_ref().get_unchecked(start..) };
let item = As::get(remaining);
self.index += 1;
Some(item)
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let remaining = self.len - self.index;
(remaining, Some(remaining))
}
}
impl<As> ExactSizeIterator for $iter<'_, As>
where
As: for<'de> SchemaRead<'de, DefaultConfig, Dst = As>,
{
#[inline]
fn len(&self) -> usize {
self.len - self.index
}
}
impl<As> core::iter::FusedIterator for $iter<'_, As> where
As: for<'de> SchemaRead<'de, DefaultConfig, Dst = As>
{
}
};
}
impl_iterator!(Iter);
impl_iterator!(IntoIter);
}
unsafe impl<'de, C: ConfigCore> SchemaReadContext<'de, C, PrimitiveTy> for PrimitiveValue {
type Dst = Self;
#[inline]
fn read_with_context(
ctx: PrimitiveTy,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()> {
let val = match ctx {
PrimitiveTy::U8 => <u8 as SchemaRead<C>>::get(reader).map(PrimitiveValue::U8)?,
PrimitiveTy::U16 => <u16 as SchemaRead<C>>::get(reader).map(PrimitiveValue::U16)?,
PrimitiveTy::U32 => <u32 as SchemaRead<C>>::get(reader).map(PrimitiveValue::U32)?,
PrimitiveTy::U64 => <u64 as SchemaRead<C>>::get(reader).map(PrimitiveValue::U64)?,
PrimitiveTy::I8 => <i8 as SchemaRead<C>>::get(reader).map(PrimitiveValue::I8)?,
PrimitiveTy::I16 => <i16 as SchemaRead<C>>::get(reader).map(PrimitiveValue::I16)?,
PrimitiveTy::I32 => <i32 as SchemaRead<C>>::get(reader).map(PrimitiveValue::I32)?,
PrimitiveTy::I64 => <i64 as SchemaRead<C>>::get(reader).map(PrimitiveValue::I64)?,
PrimitiveTy::F32 => <f32 as SchemaRead<C>>::get(reader).map(PrimitiveValue::F32)?,
PrimitiveTy::F64 => <f64 as SchemaRead<C>>::get(reader).map(PrimitiveValue::F64)?,
PrimitiveTy::Bool => <bool as SchemaRead<C>>::get(reader).map(PrimitiveValue::Bool)?,
};
dst.write(val);
Ok(())
}
}
unsafe impl<'de> SchemaReadContext<'de, DefaultConfig, PrimitiveTy> for usize {
type Dst = Self;
#[inline]
fn read_with_context(
ctx: PrimitiveTy,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()> {
#[inline]
fn try_cast_to_usize(val: impl TryInto<usize>) -> ReadResult<usize> {
#[cold]
fn err() -> ReadError {
ReadError::Custom("cannot cast to usize")
}
val.try_into().map_err(|_| err())
}
let val = match ctx {
PrimitiveTy::U8 => <u8 as SchemaRead<DefaultConfig>>::get(reader).map(usize::from)?,
PrimitiveTy::U16 => <u16 as SchemaRead<DefaultConfig>>::get(reader).map(usize::from)?,
PrimitiveTy::U32 => {
<u32 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
PrimitiveTy::U64 => {
<u64 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
PrimitiveTy::I8 => {
<i8 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
PrimitiveTy::I16 => {
<i16 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
PrimitiveTy::I32 => {
<i32 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
PrimitiveTy::I64 => {
<i64 as SchemaRead<DefaultConfig>>::get(reader).and_then(try_cast_to_usize)?
}
_ => return Err(ReadError::Custom("cannot cast to usize")),
};
dst.write(val);
Ok(())
}
}
unsafe impl<'de, C: ConfigCore> SchemaReadContext<'de, C, PrimitiveTy> for Value<'de> {
type Dst = Self;
#[inline]
fn read_with_context(
ctx: PrimitiveTy,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()> {
let val = match ctx {
PrimitiveTy::U8 => <u8 as SchemaRead<C>>::get(reader).map(Value::U8)?,
PrimitiveTy::U16 => <u16 as SchemaRead<C>>::get(reader).map(Value::U16)?,
PrimitiveTy::U32 => <u32 as SchemaRead<C>>::get(reader).map(Value::U32)?,
PrimitiveTy::U64 => <u64 as SchemaRead<C>>::get(reader).map(Value::U64)?,
PrimitiveTy::I8 => <i8 as SchemaRead<C>>::get(reader).map(Value::I8)?,
PrimitiveTy::I16 => <i16 as SchemaRead<C>>::get(reader).map(Value::I16)?,
PrimitiveTy::I32 => <i32 as SchemaRead<C>>::get(reader).map(Value::I32)?,
PrimitiveTy::I64 => <i64 as SchemaRead<C>>::get(reader).map(Value::I64)?,
PrimitiveTy::F32 => <f32 as SchemaRead<C>>::get(reader).map(Value::F32)?,
PrimitiveTy::F64 => <f64 as SchemaRead<C>>::get(reader).map(Value::F64)?,
PrimitiveTy::Bool => <bool as SchemaRead<C>>::get(reader).map(Value::Bool)?,
};
dst.write(val);
Ok(())
}
}
unsafe impl<'de> SchemaReadContext<'de, DefaultConfig, PrimitiveTy> for Vec<PrimitiveValue> {
type Dst = Self;
#[inline]
fn read_with_context(
ctx: PrimitiveTy,
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()> {
match ctx {
PrimitiveTy::U8 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::U8),
reader,
dst,
)
}
PrimitiveTy::U16 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::U16),
reader,
dst,
)
}
PrimitiveTy::U32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::U32),
reader,
dst,
)
}
PrimitiveTy::U64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::U64),
reader,
dst,
)
}
PrimitiveTy::I8 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::I8),
reader,
dst,
)
}
PrimitiveTy::I16 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::I16),
reader,
dst,
)
}
PrimitiveTy::I32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::I32),
reader,
dst,
)
}
PrimitiveTy::I64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::I64),
reader,
dst,
)
}
PrimitiveTy::F32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::F32),
reader,
dst,
)
}
PrimitiveTy::F64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::F64),
reader,
dst,
)
}
PrimitiveTy::Bool => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
Map::new(PrimitiveValue::Bool),
reader,
dst,
)
}
}
}
}
pub(crate) struct Array<T> {
_marker: core::marker::PhantomData<T>,
}
unsafe impl<'de, C: ConfigCore> SchemaReadContext<'de, C, (Len, PrimitiveTy)>
for Array<PrimitiveValue>
{
type Dst = Vec<PrimitiveValue>;
#[inline]
fn read_with_context(
ctx: (Len, PrimitiveTy),
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()> {
let (Len(len), ty) = ctx;
match ty {
PrimitiveTy::U8 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::U8),
reader,
dst,
)
}
PrimitiveTy::U16 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::U16),
reader,
dst,
)
}
PrimitiveTy::U32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::U32),
reader,
dst,
)
}
PrimitiveTy::U64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::U64),
reader,
dst,
)
}
PrimitiveTy::I8 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::I8),
reader,
dst,
)
}
PrimitiveTy::I16 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::I16),
reader,
dst,
)
}
PrimitiveTy::I32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::I32),
reader,
dst,
)
}
PrimitiveTy::I64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::I64),
reader,
dst,
)
}
PrimitiveTy::F32 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::F32),
reader,
dst,
)
}
PrimitiveTy::F64 => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::F64),
reader,
dst,
)
}
PrimitiveTy::Bool => {
<Vec<PrimitiveValue> as SchemaReadContext<DefaultConfig, _>>::read_with_context(
LenMap::new(len, PrimitiveValue::Bool),
reader,
dst,
)
}
}
}
}