1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11bitflags! {
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13 pub struct WriteOptions: u8 {
14 const OVERWRITE = 1;
15 const CONCAT = 2;
16 }
17}
18
19impl WriteOptions {
20 #[inline(always)]
21 pub fn from_bits_allow_unknown(bits: u8) -> Self {
22 Self::from_bits_retain(bits)
23 }
24
25 #[inline(always)]
26 pub fn has_unknown_bits(&self) -> bool {
27 self.get_unknown_bits() != 0
28 }
29
30 #[inline(always)]
31 pub fn get_unknown_bits(&self) -> u8 {
32 self.bits() & !Self::all().bits()
33 }
34}
35
36#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub enum WriteError {
39 Unknown,
40 InvalidKey,
41 InvalidValue,
42 AlreadyExists,
43 #[doc(hidden)]
44 __SourceBreaking {
45 unknown_ordinal: u32,
46 },
47}
48
49#[macro_export]
51macro_rules! WriteErrorUnknown {
52 () => {
53 _
54 };
55}
56
57impl WriteError {
58 #[inline]
59 pub fn from_primitive(prim: u32) -> Option<Self> {
60 match prim {
61 0 => Some(Self::Unknown),
62 1 => Some(Self::InvalidKey),
63 2 => Some(Self::InvalidValue),
64 3 => Some(Self::AlreadyExists),
65 _ => None,
66 }
67 }
68
69 #[inline]
70 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
71 match prim {
72 0 => Self::Unknown,
73 1 => Self::InvalidKey,
74 2 => Self::InvalidValue,
75 3 => Self::AlreadyExists,
76 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
77 }
78 }
79
80 #[inline]
81 pub fn unknown() -> Self {
82 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
83 }
84
85 #[inline]
86 pub const fn into_primitive(self) -> u32 {
87 match self {
88 Self::Unknown => 0,
89 Self::InvalidKey => 1,
90 Self::InvalidValue => 2,
91 Self::AlreadyExists => 3,
92 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
93 }
94 }
95
96 #[inline]
97 pub fn is_unknown(&self) -> bool {
98 match self {
99 Self::__SourceBreaking { unknown_ordinal: _ } => true,
100 _ => false,
101 }
102 }
103}
104
105#[derive(Clone, Debug, PartialEq)]
109pub struct Item {
110 pub key: String,
111 pub value: Value,
112}
113
114impl fidl::Persistable for Item {}
115
116#[derive(Clone, Debug, Default, PartialEq)]
117pub struct StoreWriteItemRequest {
118 pub attempt: Option<Item>,
119 pub options: Option<WriteOptions>,
120 #[doc(hidden)]
121 pub __source_breaking: fidl::marker::SourceBreaking,
122}
123
124impl fidl::Persistable for StoreWriteItemRequest {}
125
126#[derive(Clone, Debug)]
127pub enum Value {
128 Bytes(Vec<u8>),
129 String(String),
130 Bool(bool),
131 Uint8(u8),
132 Int8(i8),
133 Uint16(u16),
134 Int16(i16),
135 Uint32(u32),
136 Int32(i32),
137 Float32(f32),
138 Uint64(u64),
139 Int64(i64),
140 Float64(f64),
141 Uint128([u64; 2]),
142 #[doc(hidden)]
143 __SourceBreaking {
144 unknown_ordinal: u64,
145 },
146}
147
148#[macro_export]
150macro_rules! ValueUnknown {
151 () => {
152 _
153 };
154}
155
156impl PartialEq for Value {
158 fn eq(&self, other: &Self) -> bool {
159 match (self, other) {
160 (Self::Bytes(x), Self::Bytes(y)) => *x == *y,
161 (Self::String(x), Self::String(y)) => *x == *y,
162 (Self::Bool(x), Self::Bool(y)) => *x == *y,
163 (Self::Uint8(x), Self::Uint8(y)) => *x == *y,
164 (Self::Int8(x), Self::Int8(y)) => *x == *y,
165 (Self::Uint16(x), Self::Uint16(y)) => *x == *y,
166 (Self::Int16(x), Self::Int16(y)) => *x == *y,
167 (Self::Uint32(x), Self::Uint32(y)) => *x == *y,
168 (Self::Int32(x), Self::Int32(y)) => *x == *y,
169 (Self::Float32(x), Self::Float32(y)) => *x == *y,
170 (Self::Uint64(x), Self::Uint64(y)) => *x == *y,
171 (Self::Int64(x), Self::Int64(y)) => *x == *y,
172 (Self::Float64(x), Self::Float64(y)) => *x == *y,
173 (Self::Uint128(x), Self::Uint128(y)) => *x == *y,
174 _ => false,
175 }
176 }
177}
178
179impl Value {
180 #[inline]
181 pub fn ordinal(&self) -> u64 {
182 match *self {
183 Self::Bytes(_) => 1,
184 Self::String(_) => 2,
185 Self::Bool(_) => 3,
186 Self::Uint8(_) => 4,
187 Self::Int8(_) => 5,
188 Self::Uint16(_) => 6,
189 Self::Int16(_) => 7,
190 Self::Uint32(_) => 8,
191 Self::Int32(_) => 9,
192 Self::Float32(_) => 10,
193 Self::Uint64(_) => 11,
194 Self::Int64(_) => 12,
195 Self::Float64(_) => 13,
196 Self::Uint128(_) => 14,
197 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
198 }
199 }
200
201 #[inline]
202 pub fn unknown_variant_for_testing() -> Self {
203 Self::__SourceBreaking { unknown_ordinal: 0 }
204 }
205
206 #[inline]
207 pub fn is_unknown(&self) -> bool {
208 match self {
209 Self::__SourceBreaking { .. } => true,
210 _ => false,
211 }
212 }
213}
214
215impl fidl::Persistable for Value {}
216
217mod internal {
218 use super::*;
219 unsafe impl fidl::encoding::TypeMarker for WriteOptions {
220 type Owned = Self;
221
222 #[inline(always)]
223 fn inline_align(_context: fidl::encoding::Context) -> usize {
224 1
225 }
226
227 #[inline(always)]
228 fn inline_size(_context: fidl::encoding::Context) -> usize {
229 1
230 }
231 }
232
233 impl fidl::encoding::ValueTypeMarker for WriteOptions {
234 type Borrowed<'a> = Self;
235 #[inline(always)]
236 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
237 *value
238 }
239 }
240
241 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WriteOptions {
242 #[inline]
243 unsafe fn encode(
244 self,
245 encoder: &mut fidl::encoding::Encoder<'_, D>,
246 offset: usize,
247 _depth: fidl::encoding::Depth,
248 ) -> fidl::Result<()> {
249 encoder.debug_check_bounds::<Self>(offset);
250 encoder.write_num(self.bits(), offset);
251 Ok(())
252 }
253 }
254
255 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WriteOptions {
256 #[inline(always)]
257 fn new_empty() -> Self {
258 Self::empty()
259 }
260
261 #[inline]
262 unsafe fn decode(
263 &mut self,
264 decoder: &mut fidl::encoding::Decoder<'_, D>,
265 offset: usize,
266 _depth: fidl::encoding::Depth,
267 ) -> fidl::Result<()> {
268 decoder.debug_check_bounds::<Self>(offset);
269 let prim = decoder.read_num::<u8>(offset);
270 *self = Self::from_bits_allow_unknown(prim);
271 Ok(())
272 }
273 }
274 unsafe impl fidl::encoding::TypeMarker for WriteError {
275 type Owned = Self;
276
277 #[inline(always)]
278 fn inline_align(_context: fidl::encoding::Context) -> usize {
279 std::mem::align_of::<u32>()
280 }
281
282 #[inline(always)]
283 fn inline_size(_context: fidl::encoding::Context) -> usize {
284 std::mem::size_of::<u32>()
285 }
286
287 #[inline(always)]
288 fn encode_is_copy() -> bool {
289 false
290 }
291
292 #[inline(always)]
293 fn decode_is_copy() -> bool {
294 false
295 }
296 }
297
298 impl fidl::encoding::ValueTypeMarker for WriteError {
299 type Borrowed<'a> = Self;
300 #[inline(always)]
301 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
302 *value
303 }
304 }
305
306 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WriteError {
307 #[inline]
308 unsafe fn encode(
309 self,
310 encoder: &mut fidl::encoding::Encoder<'_, D>,
311 offset: usize,
312 _depth: fidl::encoding::Depth,
313 ) -> fidl::Result<()> {
314 encoder.debug_check_bounds::<Self>(offset);
315 encoder.write_num(self.into_primitive(), offset);
316 Ok(())
317 }
318 }
319
320 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WriteError {
321 #[inline(always)]
322 fn new_empty() -> Self {
323 Self::unknown()
324 }
325
326 #[inline]
327 unsafe fn decode(
328 &mut self,
329 decoder: &mut fidl::encoding::Decoder<'_, D>,
330 offset: usize,
331 _depth: fidl::encoding::Depth,
332 ) -> fidl::Result<()> {
333 decoder.debug_check_bounds::<Self>(offset);
334 let prim = decoder.read_num::<u32>(offset);
335
336 *self = Self::from_primitive_allow_unknown(prim);
337 Ok(())
338 }
339 }
340
341 impl fidl::encoding::ValueTypeMarker for Item {
342 type Borrowed<'a> = &'a Self;
343 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
344 value
345 }
346 }
347
348 unsafe impl fidl::encoding::TypeMarker for Item {
349 type Owned = Self;
350
351 #[inline(always)]
352 fn inline_align(_context: fidl::encoding::Context) -> usize {
353 8
354 }
355
356 #[inline(always)]
357 fn inline_size(_context: fidl::encoding::Context) -> usize {
358 32
359 }
360 }
361
362 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Item, D> for &Item {
363 #[inline]
364 unsafe fn encode(
365 self,
366 encoder: &mut fidl::encoding::Encoder<'_, D>,
367 offset: usize,
368 _depth: fidl::encoding::Depth,
369 ) -> fidl::Result<()> {
370 encoder.debug_check_bounds::<Item>(offset);
371 fidl::encoding::Encode::<Item, D>::encode(
373 (
374 <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
375 &self.key,
376 ),
377 <Value as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
378 ),
379 encoder,
380 offset,
381 _depth,
382 )
383 }
384 }
385 unsafe impl<
386 D: fidl::encoding::ResourceDialect,
387 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
388 T1: fidl::encoding::Encode<Value, D>,
389 > fidl::encoding::Encode<Item, D> for (T0, T1)
390 {
391 #[inline]
392 unsafe fn encode(
393 self,
394 encoder: &mut fidl::encoding::Encoder<'_, D>,
395 offset: usize,
396 depth: fidl::encoding::Depth,
397 ) -> fidl::Result<()> {
398 encoder.debug_check_bounds::<Item>(offset);
399 self.0.encode(encoder, offset + 0, depth)?;
403 self.1.encode(encoder, offset + 16, depth)?;
404 Ok(())
405 }
406 }
407
408 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Item {
409 #[inline(always)]
410 fn new_empty() -> Self {
411 Self {
412 key: fidl::new_empty!(fidl::encoding::BoundedString<128>, D),
413 value: fidl::new_empty!(Value, D),
414 }
415 }
416
417 #[inline]
418 unsafe fn decode(
419 &mut self,
420 decoder: &mut fidl::encoding::Decoder<'_, D>,
421 offset: usize,
422 _depth: fidl::encoding::Depth,
423 ) -> fidl::Result<()> {
424 decoder.debug_check_bounds::<Self>(offset);
425 fidl::decode!(
427 fidl::encoding::BoundedString<128>,
428 D,
429 &mut self.key,
430 decoder,
431 offset + 0,
432 _depth
433 )?;
434 fidl::decode!(Value, D, &mut self.value, decoder, offset + 16, _depth)?;
435 Ok(())
436 }
437 }
438
439 impl StoreWriteItemRequest {
440 #[inline(always)]
441 fn max_ordinal_present(&self) -> u64 {
442 if let Some(_) = self.options {
443 return 2;
444 }
445 if let Some(_) = self.attempt {
446 return 1;
447 }
448 0
449 }
450 }
451
452 impl fidl::encoding::ValueTypeMarker for StoreWriteItemRequest {
453 type Borrowed<'a> = &'a Self;
454 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
455 value
456 }
457 }
458
459 unsafe impl fidl::encoding::TypeMarker for StoreWriteItemRequest {
460 type Owned = Self;
461
462 #[inline(always)]
463 fn inline_align(_context: fidl::encoding::Context) -> usize {
464 8
465 }
466
467 #[inline(always)]
468 fn inline_size(_context: fidl::encoding::Context) -> usize {
469 16
470 }
471 }
472
473 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StoreWriteItemRequest, D>
474 for &StoreWriteItemRequest
475 {
476 unsafe fn encode(
477 self,
478 encoder: &mut fidl::encoding::Encoder<'_, D>,
479 offset: usize,
480 mut depth: fidl::encoding::Depth,
481 ) -> fidl::Result<()> {
482 encoder.debug_check_bounds::<StoreWriteItemRequest>(offset);
483 let max_ordinal: u64 = self.max_ordinal_present();
485 encoder.write_num(max_ordinal, offset);
486 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
487 if max_ordinal == 0 {
489 return Ok(());
490 }
491 depth.increment()?;
492 let envelope_size = 8;
493 let bytes_len = max_ordinal as usize * envelope_size;
494 #[allow(unused_variables)]
495 let offset = encoder.out_of_line_offset(bytes_len);
496 let mut _prev_end_offset: usize = 0;
497 if 1 > max_ordinal {
498 return Ok(());
499 }
500
501 let cur_offset: usize = (1 - 1) * envelope_size;
504
505 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
507
508 fidl::encoding::encode_in_envelope_optional::<Item, D>(
513 self.attempt.as_ref().map(<Item as fidl::encoding::ValueTypeMarker>::borrow),
514 encoder,
515 offset + cur_offset,
516 depth,
517 )?;
518
519 _prev_end_offset = cur_offset + envelope_size;
520 if 2 > max_ordinal {
521 return Ok(());
522 }
523
524 let cur_offset: usize = (2 - 1) * envelope_size;
527
528 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
530
531 fidl::encoding::encode_in_envelope_optional::<WriteOptions, D>(
536 self.options
537 .as_ref()
538 .map(<WriteOptions as fidl::encoding::ValueTypeMarker>::borrow),
539 encoder,
540 offset + cur_offset,
541 depth,
542 )?;
543
544 _prev_end_offset = cur_offset + envelope_size;
545
546 Ok(())
547 }
548 }
549
550 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StoreWriteItemRequest {
551 #[inline(always)]
552 fn new_empty() -> Self {
553 Self::default()
554 }
555
556 unsafe fn decode(
557 &mut self,
558 decoder: &mut fidl::encoding::Decoder<'_, D>,
559 offset: usize,
560 mut depth: fidl::encoding::Depth,
561 ) -> fidl::Result<()> {
562 decoder.debug_check_bounds::<Self>(offset);
563 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
564 None => return Err(fidl::Error::NotNullable),
565 Some(len) => len,
566 };
567 if len == 0 {
569 return Ok(());
570 };
571 depth.increment()?;
572 let envelope_size = 8;
573 let bytes_len = len * envelope_size;
574 let offset = decoder.out_of_line_offset(bytes_len)?;
575 let mut _next_ordinal_to_read = 0;
577 let mut next_offset = offset;
578 let end_offset = offset + bytes_len;
579 _next_ordinal_to_read += 1;
580 if next_offset >= end_offset {
581 return Ok(());
582 }
583
584 while _next_ordinal_to_read < 1 {
586 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
587 _next_ordinal_to_read += 1;
588 next_offset += envelope_size;
589 }
590
591 let next_out_of_line = decoder.next_out_of_line();
592 let handles_before = decoder.remaining_handles();
593 if let Some((inlined, num_bytes, num_handles)) =
594 fidl::encoding::decode_envelope_header(decoder, next_offset)?
595 {
596 let member_inline_size =
597 <Item as fidl::encoding::TypeMarker>::inline_size(decoder.context);
598 if inlined != (member_inline_size <= 4) {
599 return Err(fidl::Error::InvalidInlineBitInEnvelope);
600 }
601 let inner_offset;
602 let mut inner_depth = depth.clone();
603 if inlined {
604 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
605 inner_offset = next_offset;
606 } else {
607 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
608 inner_depth.increment()?;
609 }
610 let val_ref = self.attempt.get_or_insert_with(|| fidl::new_empty!(Item, D));
611 fidl::decode!(Item, D, val_ref, decoder, inner_offset, inner_depth)?;
612 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
613 {
614 return Err(fidl::Error::InvalidNumBytesInEnvelope);
615 }
616 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
617 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
618 }
619 }
620
621 next_offset += envelope_size;
622 _next_ordinal_to_read += 1;
623 if next_offset >= end_offset {
624 return Ok(());
625 }
626
627 while _next_ordinal_to_read < 2 {
629 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
630 _next_ordinal_to_read += 1;
631 next_offset += envelope_size;
632 }
633
634 let next_out_of_line = decoder.next_out_of_line();
635 let handles_before = decoder.remaining_handles();
636 if let Some((inlined, num_bytes, num_handles)) =
637 fidl::encoding::decode_envelope_header(decoder, next_offset)?
638 {
639 let member_inline_size =
640 <WriteOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
641 if inlined != (member_inline_size <= 4) {
642 return Err(fidl::Error::InvalidInlineBitInEnvelope);
643 }
644 let inner_offset;
645 let mut inner_depth = depth.clone();
646 if inlined {
647 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
648 inner_offset = next_offset;
649 } else {
650 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
651 inner_depth.increment()?;
652 }
653 let val_ref = self.options.get_or_insert_with(|| fidl::new_empty!(WriteOptions, D));
654 fidl::decode!(WriteOptions, D, val_ref, decoder, inner_offset, inner_depth)?;
655 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
656 {
657 return Err(fidl::Error::InvalidNumBytesInEnvelope);
658 }
659 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
660 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
661 }
662 }
663
664 next_offset += envelope_size;
665
666 while next_offset < end_offset {
668 _next_ordinal_to_read += 1;
669 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
670 next_offset += envelope_size;
671 }
672
673 Ok(())
674 }
675 }
676
677 impl fidl::encoding::ValueTypeMarker for Value {
678 type Borrowed<'a> = &'a Self;
679 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
680 value
681 }
682 }
683
684 unsafe impl fidl::encoding::TypeMarker for Value {
685 type Owned = Self;
686
687 #[inline(always)]
688 fn inline_align(_context: fidl::encoding::Context) -> usize {
689 8
690 }
691
692 #[inline(always)]
693 fn inline_size(_context: fidl::encoding::Context) -> usize {
694 16
695 }
696 }
697
698 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Value, D> for &Value {
699 #[inline]
700 unsafe fn encode(
701 self,
702 encoder: &mut fidl::encoding::Encoder<'_, D>,
703 offset: usize,
704 _depth: fidl::encoding::Depth,
705 ) -> fidl::Result<()> {
706 encoder.debug_check_bounds::<Value>(offset);
707 encoder.write_num::<u64>(self.ordinal(), offset);
708 match self {
709 Value::Bytes(ref val) => {
710 fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<u8, 64000>, D>(
711 <fidl::encoding::Vector<u8, 64000> as fidl::encoding::ValueTypeMarker>::borrow(val),
712 encoder, offset + 8, _depth
713 )
714 }
715 Value::String(ref val) => {
716 fidl::encoding::encode_in_envelope::<fidl::encoding::BoundedString<64000>, D>(
717 <fidl::encoding::BoundedString<64000> as fidl::encoding::ValueTypeMarker>::borrow(val),
718 encoder, offset + 8, _depth
719 )
720 }
721 Value::Bool(ref val) => {
722 fidl::encoding::encode_in_envelope::<bool, D>(
723 <bool as fidl::encoding::ValueTypeMarker>::borrow(val),
724 encoder, offset + 8, _depth
725 )
726 }
727 Value::Uint8(ref val) => {
728 fidl::encoding::encode_in_envelope::<u8, D>(
729 <u8 as fidl::encoding::ValueTypeMarker>::borrow(val),
730 encoder, offset + 8, _depth
731 )
732 }
733 Value::Int8(ref val) => {
734 fidl::encoding::encode_in_envelope::<i8, D>(
735 <i8 as fidl::encoding::ValueTypeMarker>::borrow(val),
736 encoder, offset + 8, _depth
737 )
738 }
739 Value::Uint16(ref val) => {
740 fidl::encoding::encode_in_envelope::<u16, D>(
741 <u16 as fidl::encoding::ValueTypeMarker>::borrow(val),
742 encoder, offset + 8, _depth
743 )
744 }
745 Value::Int16(ref val) => {
746 fidl::encoding::encode_in_envelope::<i16, D>(
747 <i16 as fidl::encoding::ValueTypeMarker>::borrow(val),
748 encoder, offset + 8, _depth
749 )
750 }
751 Value::Uint32(ref val) => {
752 fidl::encoding::encode_in_envelope::<u32, D>(
753 <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
754 encoder, offset + 8, _depth
755 )
756 }
757 Value::Int32(ref val) => {
758 fidl::encoding::encode_in_envelope::<i32, D>(
759 <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
760 encoder, offset + 8, _depth
761 )
762 }
763 Value::Float32(ref val) => {
764 fidl::encoding::encode_in_envelope::<f32, D>(
765 <f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
766 encoder, offset + 8, _depth
767 )
768 }
769 Value::Uint64(ref val) => {
770 fidl::encoding::encode_in_envelope::<u64, D>(
771 <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
772 encoder, offset + 8, _depth
773 )
774 }
775 Value::Int64(ref val) => {
776 fidl::encoding::encode_in_envelope::<i64, D>(
777 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
778 encoder, offset + 8, _depth
779 )
780 }
781 Value::Float64(ref val) => {
782 fidl::encoding::encode_in_envelope::<f64, D>(
783 <f64 as fidl::encoding::ValueTypeMarker>::borrow(val),
784 encoder, offset + 8, _depth
785 )
786 }
787 Value::Uint128(ref val) => {
788 fidl::encoding::encode_in_envelope::<fidl::encoding::Array<u64, 2>, D>(
789 <fidl::encoding::Array<u64, 2> as fidl::encoding::ValueTypeMarker>::borrow(val),
790 encoder, offset + 8, _depth
791 )
792 }
793 Value::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
794 }
795 }
796 }
797
798 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Value {
799 #[inline(always)]
800 fn new_empty() -> Self {
801 Self::__SourceBreaking { unknown_ordinal: 0 }
802 }
803
804 #[inline]
805 unsafe fn decode(
806 &mut self,
807 decoder: &mut fidl::encoding::Decoder<'_, D>,
808 offset: usize,
809 mut depth: fidl::encoding::Depth,
810 ) -> fidl::Result<()> {
811 decoder.debug_check_bounds::<Self>(offset);
812 #[allow(unused_variables)]
813 let next_out_of_line = decoder.next_out_of_line();
814 let handles_before = decoder.remaining_handles();
815 let (ordinal, inlined, num_bytes, num_handles) =
816 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
817
818 let member_inline_size = match ordinal {
819 1 => <fidl::encoding::Vector<u8, 64000> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
820 2 => <fidl::encoding::BoundedString<64000> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
821 3 => <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context),
822 4 => <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
823 5 => <i8 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
824 6 => <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
825 7 => <i16 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
826 8 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
827 9 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
828 10 => <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
829 11 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
830 12 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
831 13 => <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
832 14 => <fidl::encoding::Array<u64, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
833 0 => return Err(fidl::Error::UnknownUnionTag),
834 _ => num_bytes as usize,
835 };
836
837 if inlined != (member_inline_size <= 4) {
838 return Err(fidl::Error::InvalidInlineBitInEnvelope);
839 }
840 let _inner_offset;
841 if inlined {
842 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
843 _inner_offset = offset + 8;
844 } else {
845 depth.increment()?;
846 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
847 }
848 match ordinal {
849 1 => {
850 #[allow(irrefutable_let_patterns)]
851 if let Value::Bytes(_) = self {
852 } else {
854 *self =
856 Value::Bytes(fidl::new_empty!(fidl::encoding::Vector<u8, 64000>, D));
857 }
858 #[allow(irrefutable_let_patterns)]
859 if let Value::Bytes(ref mut val) = self {
860 fidl::decode!(fidl::encoding::Vector<u8, 64000>, D, val, decoder, _inner_offset, depth)?;
861 } else {
862 unreachable!()
863 }
864 }
865 2 => {
866 #[allow(irrefutable_let_patterns)]
867 if let Value::String(_) = self {
868 } else {
870 *self = Value::String(fidl::new_empty!(
872 fidl::encoding::BoundedString<64000>,
873 D
874 ));
875 }
876 #[allow(irrefutable_let_patterns)]
877 if let Value::String(ref mut val) = self {
878 fidl::decode!(
879 fidl::encoding::BoundedString<64000>,
880 D,
881 val,
882 decoder,
883 _inner_offset,
884 depth
885 )?;
886 } else {
887 unreachable!()
888 }
889 }
890 3 => {
891 #[allow(irrefutable_let_patterns)]
892 if let Value::Bool(_) = self {
893 } else {
895 *self = Value::Bool(fidl::new_empty!(bool, D));
897 }
898 #[allow(irrefutable_let_patterns)]
899 if let Value::Bool(ref mut val) = self {
900 fidl::decode!(bool, D, val, decoder, _inner_offset, depth)?;
901 } else {
902 unreachable!()
903 }
904 }
905 4 => {
906 #[allow(irrefutable_let_patterns)]
907 if let Value::Uint8(_) = self {
908 } else {
910 *self = Value::Uint8(fidl::new_empty!(u8, D));
912 }
913 #[allow(irrefutable_let_patterns)]
914 if let Value::Uint8(ref mut val) = self {
915 fidl::decode!(u8, D, val, decoder, _inner_offset, depth)?;
916 } else {
917 unreachable!()
918 }
919 }
920 5 => {
921 #[allow(irrefutable_let_patterns)]
922 if let Value::Int8(_) = self {
923 } else {
925 *self = Value::Int8(fidl::new_empty!(i8, D));
927 }
928 #[allow(irrefutable_let_patterns)]
929 if let Value::Int8(ref mut val) = self {
930 fidl::decode!(i8, D, val, decoder, _inner_offset, depth)?;
931 } else {
932 unreachable!()
933 }
934 }
935 6 => {
936 #[allow(irrefutable_let_patterns)]
937 if let Value::Uint16(_) = self {
938 } else {
940 *self = Value::Uint16(fidl::new_empty!(u16, D));
942 }
943 #[allow(irrefutable_let_patterns)]
944 if let Value::Uint16(ref mut val) = self {
945 fidl::decode!(u16, D, val, decoder, _inner_offset, depth)?;
946 } else {
947 unreachable!()
948 }
949 }
950 7 => {
951 #[allow(irrefutable_let_patterns)]
952 if let Value::Int16(_) = self {
953 } else {
955 *self = Value::Int16(fidl::new_empty!(i16, D));
957 }
958 #[allow(irrefutable_let_patterns)]
959 if let Value::Int16(ref mut val) = self {
960 fidl::decode!(i16, D, val, decoder, _inner_offset, depth)?;
961 } else {
962 unreachable!()
963 }
964 }
965 8 => {
966 #[allow(irrefutable_let_patterns)]
967 if let Value::Uint32(_) = self {
968 } else {
970 *self = Value::Uint32(fidl::new_empty!(u32, D));
972 }
973 #[allow(irrefutable_let_patterns)]
974 if let Value::Uint32(ref mut val) = self {
975 fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
976 } else {
977 unreachable!()
978 }
979 }
980 9 => {
981 #[allow(irrefutable_let_patterns)]
982 if let Value::Int32(_) = self {
983 } else {
985 *self = Value::Int32(fidl::new_empty!(i32, D));
987 }
988 #[allow(irrefutable_let_patterns)]
989 if let Value::Int32(ref mut val) = self {
990 fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
991 } else {
992 unreachable!()
993 }
994 }
995 10 => {
996 #[allow(irrefutable_let_patterns)]
997 if let Value::Float32(_) = self {
998 } else {
1000 *self = Value::Float32(fidl::new_empty!(f32, D));
1002 }
1003 #[allow(irrefutable_let_patterns)]
1004 if let Value::Float32(ref mut val) = self {
1005 fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
1006 } else {
1007 unreachable!()
1008 }
1009 }
1010 11 => {
1011 #[allow(irrefutable_let_patterns)]
1012 if let Value::Uint64(_) = self {
1013 } else {
1015 *self = Value::Uint64(fidl::new_empty!(u64, D));
1017 }
1018 #[allow(irrefutable_let_patterns)]
1019 if let Value::Uint64(ref mut val) = self {
1020 fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
1021 } else {
1022 unreachable!()
1023 }
1024 }
1025 12 => {
1026 #[allow(irrefutable_let_patterns)]
1027 if let Value::Int64(_) = self {
1028 } else {
1030 *self = Value::Int64(fidl::new_empty!(i64, D));
1032 }
1033 #[allow(irrefutable_let_patterns)]
1034 if let Value::Int64(ref mut val) = self {
1035 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1036 } else {
1037 unreachable!()
1038 }
1039 }
1040 13 => {
1041 #[allow(irrefutable_let_patterns)]
1042 if let Value::Float64(_) = self {
1043 } else {
1045 *self = Value::Float64(fidl::new_empty!(f64, D));
1047 }
1048 #[allow(irrefutable_let_patterns)]
1049 if let Value::Float64(ref mut val) = self {
1050 fidl::decode!(f64, D, val, decoder, _inner_offset, depth)?;
1051 } else {
1052 unreachable!()
1053 }
1054 }
1055 14 => {
1056 #[allow(irrefutable_let_patterns)]
1057 if let Value::Uint128(_) = self {
1058 } else {
1060 *self = Value::Uint128(fidl::new_empty!(fidl::encoding::Array<u64, 2>, D));
1062 }
1063 #[allow(irrefutable_let_patterns)]
1064 if let Value::Uint128(ref mut val) = self {
1065 fidl::decode!(fidl::encoding::Array<u64, 2>, D, val, decoder, _inner_offset, depth)?;
1066 } else {
1067 unreachable!()
1068 }
1069 }
1070 #[allow(deprecated)]
1071 ordinal => {
1072 for _ in 0..num_handles {
1073 decoder.drop_next_handle()?;
1074 }
1075 *self = Value::__SourceBreaking { unknown_ordinal: ordinal };
1076 }
1077 }
1078 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1079 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1080 }
1081 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1082 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1083 }
1084 Ok(())
1085 }
1086 }
1087}