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
11pub const MAX_DATA_LENGTH: u32 = 8192;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub enum RouterError {
16 NotFound,
18 InvalidArgs,
20 NotSupported,
22 Internal,
24 Unknown,
26 #[doc(hidden)]
27 __SourceBreaking { unknown_ordinal: u32 },
28}
29
30#[macro_export]
32macro_rules! RouterErrorUnknown {
33 () => {
34 _
35 };
36}
37
38impl RouterError {
39 #[inline]
40 pub fn from_primitive(prim: u32) -> Option<Self> {
41 match prim {
42 1 => Some(Self::NotFound),
43 2 => Some(Self::InvalidArgs),
44 3 => Some(Self::NotSupported),
45 4 => Some(Self::Internal),
46 5 => Some(Self::Unknown),
47 _ => None,
48 }
49 }
50
51 #[inline]
52 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
53 match prim {
54 1 => Self::NotFound,
55 2 => Self::InvalidArgs,
56 3 => Self::NotSupported,
57 4 => Self::Internal,
58 5 => Self::Unknown,
59 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
60 }
61 }
62
63 #[inline]
64 pub fn unknown() -> Self {
65 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
66 }
67
68 #[inline]
69 pub const fn into_primitive(self) -> u32 {
70 match self {
71 Self::NotFound => 1,
72 Self::InvalidArgs => 2,
73 Self::NotSupported => 3,
74 Self::Internal => 4,
75 Self::Unknown => 5,
76 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
77 }
78 }
79
80 #[inline]
81 pub fn is_unknown(&self) -> bool {
82 match self {
83 Self::__SourceBreaking { unknown_ordinal: _ } => true,
84 _ => false,
85 }
86 }
87}
88
89#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
91pub enum RouterResponse {
92 Success,
94 Unavailable,
96 #[doc(hidden)]
97 __SourceBreaking { unknown_ordinal: u32 },
98}
99
100#[macro_export]
102macro_rules! RouterResponseUnknown {
103 () => {
104 _
105 };
106}
107
108impl RouterResponse {
109 #[inline]
110 pub fn from_primitive(prim: u32) -> Option<Self> {
111 match prim {
112 1 => Some(Self::Success),
113 2 => Some(Self::Unavailable),
114 _ => None,
115 }
116 }
117
118 #[inline]
119 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
120 match prim {
121 1 => Self::Success,
122 2 => Self::Unavailable,
123 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
124 }
125 }
126
127 #[inline]
128 pub fn unknown() -> Self {
129 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
130 }
131
132 #[inline]
133 pub const fn into_primitive(self) -> u32 {
134 match self {
135 Self::Success => 1,
136 Self::Unavailable => 2,
137 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
138 }
139 }
140
141 #[inline]
142 pub fn is_unknown(&self) -> bool {
143 match self {
144 Self::__SourceBreaking { unknown_ordinal: _ } => true,
145 _ => false,
146 }
147 }
148}
149
150#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
151pub struct DictionaryKeyIteratorGetNextResponse {
152 pub keys: Vec<String>,
153}
154
155impl fidl::Persistable for DictionaryKeyIteratorGetNextResponse {}
156
157#[derive(Clone, Debug)]
160pub enum Data {
161 Bytes(Vec<u8>),
162 String(String),
163 Int64(i64),
164 Uint64(u64),
165 #[doc(hidden)]
166 __SourceBreaking {
167 unknown_ordinal: u64,
168 },
169}
170
171#[macro_export]
173macro_rules! DataUnknown {
174 () => {
175 _
176 };
177}
178
179impl PartialEq for Data {
181 fn eq(&self, other: &Self) -> bool {
182 match (self, other) {
183 (Self::Bytes(x), Self::Bytes(y)) => *x == *y,
184 (Self::String(x), Self::String(y)) => *x == *y,
185 (Self::Int64(x), Self::Int64(y)) => *x == *y,
186 (Self::Uint64(x), Self::Uint64(y)) => *x == *y,
187 _ => false,
188 }
189 }
190}
191
192impl Data {
193 #[inline]
194 pub fn ordinal(&self) -> u64 {
195 match *self {
196 Self::Bytes(_) => 1,
197 Self::String(_) => 2,
198 Self::Int64(_) => 3,
199 Self::Uint64(_) => 4,
200 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
201 }
202 }
203
204 #[inline]
205 pub fn unknown_variant_for_testing() -> Self {
206 Self::__SourceBreaking { unknown_ordinal: 0 }
207 }
208
209 #[inline]
210 pub fn is_unknown(&self) -> bool {
211 match self {
212 Self::__SourceBreaking { .. } => true,
213 _ => false,
214 }
215 }
216}
217
218impl fidl::Persistable for Data {}
219
220pub mod capability_factory_ordinals {
221 pub const CREATE_CONNECTOR: u64 = 0x58be7506ad9c0d1b;
222 pub const CREATE_DIR_CONNECTOR: u64 = 0x47e63805e1a638fa;
223 pub const CREATE_DICTIONARY: u64 = 0x1d9473d8c1e82b02;
224 pub const CREATE_CONNECTOR_ROUTER: u64 = 0x10a5577bdd065d17;
225 pub const CREATE_DIR_CONNECTOR_ROUTER: u64 = 0x6da0f55bc0cb6916;
226 pub const CREATE_DICTIONARY_ROUTER: u64 = 0x22f371a3e3cbdf05;
227 pub const CREATE_DATA_ROUTER: u64 = 0x42ca43500520bd20;
228}
229
230pub mod connector_ordinals {
231 pub const CLONE: u64 = 0x20d8a7aba2168a79;
232 pub const CONNECT: u64 = 0x1c0c1727bd474e02;
233}
234
235pub mod connector_router_ordinals {
236 pub const CLONE: u64 = 0x20d8a7aba2168a79;
237 pub const ROUTE: u64 = 0x57a912c92a38f9f8;
238}
239
240pub mod data_router_ordinals {
241 pub const CLONE: u64 = 0x20d8a7aba2168a79;
242 pub const ROUTE: u64 = 0x646885ba7e10ceeb;
243}
244
245pub mod dictionary_ordinals {
246 pub const CLONE: u64 = 0x20d8a7aba2168a79;
247 pub const INSERT: u64 = 0x673364c89c4b0ed7;
248 pub const GET: u64 = 0x46d4b1dcd30feed9;
249 pub const REMOVE: u64 = 0x7931ac0ea29dffe7;
250 pub const ITERATE_KEYS: u64 = 0x331df1e1e73158a1;
251 pub const LEGACY_EXPORT: u64 = 0x722a26456a1ee1d0;
252}
253
254pub mod dictionary_key_iterator_ordinals {
255 pub const GET_NEXT: u64 = 0x3806bda34433db54;
256}
257
258pub mod dictionary_router_ordinals {
259 pub const CLONE: u64 = 0x20d8a7aba2168a79;
260 pub const ROUTE: u64 = 0x199389f437b3937b;
261}
262
263pub mod dir_connector_ordinals {
264 pub const CLONE: u64 = 0x20d8a7aba2168a79;
265 pub const CONNECT: u64 = 0x23fbb3d289ca7e5b;
266}
267
268pub mod dir_connector_router_ordinals {
269 pub const CLONE: u64 = 0x20d8a7aba2168a79;
270 pub const ROUTE: u64 = 0x233f2ac038127462;
271}
272
273pub mod dir_receiver_ordinals {
274 pub const RECEIVE: u64 = 0x4ac564d726bb325e;
275}
276
277pub mod receiver_ordinals {
278 pub const RECEIVE: u64 = 0x609ca5c7943b58d0;
279}
280
281mod internal {
282 use super::*;
283 unsafe impl fidl::encoding::TypeMarker for RouterError {
284 type Owned = Self;
285
286 #[inline(always)]
287 fn inline_align(_context: fidl::encoding::Context) -> usize {
288 std::mem::align_of::<u32>()
289 }
290
291 #[inline(always)]
292 fn inline_size(_context: fidl::encoding::Context) -> usize {
293 std::mem::size_of::<u32>()
294 }
295
296 #[inline(always)]
297 fn encode_is_copy() -> bool {
298 false
299 }
300
301 #[inline(always)]
302 fn decode_is_copy() -> bool {
303 false
304 }
305 }
306
307 impl fidl::encoding::ValueTypeMarker for RouterError {
308 type Borrowed<'a> = Self;
309 #[inline(always)]
310 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
311 *value
312 }
313 }
314
315 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RouterError {
316 #[inline]
317 unsafe fn encode(
318 self,
319 encoder: &mut fidl::encoding::Encoder<'_, D>,
320 offset: usize,
321 _depth: fidl::encoding::Depth,
322 ) -> fidl::Result<()> {
323 encoder.debug_check_bounds::<Self>(offset);
324 encoder.write_num(self.into_primitive(), offset);
325 Ok(())
326 }
327 }
328
329 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RouterError {
330 #[inline(always)]
331 fn new_empty() -> Self {
332 Self::unknown()
333 }
334
335 #[inline]
336 unsafe fn decode(
337 &mut self,
338 decoder: &mut fidl::encoding::Decoder<'_, D>,
339 offset: usize,
340 _depth: fidl::encoding::Depth,
341 ) -> fidl::Result<()> {
342 decoder.debug_check_bounds::<Self>(offset);
343 let prim = decoder.read_num::<u32>(offset);
344
345 *self = Self::from_primitive_allow_unknown(prim);
346 Ok(())
347 }
348 }
349 unsafe impl fidl::encoding::TypeMarker for RouterResponse {
350 type Owned = Self;
351
352 #[inline(always)]
353 fn inline_align(_context: fidl::encoding::Context) -> usize {
354 std::mem::align_of::<u32>()
355 }
356
357 #[inline(always)]
358 fn inline_size(_context: fidl::encoding::Context) -> usize {
359 std::mem::size_of::<u32>()
360 }
361
362 #[inline(always)]
363 fn encode_is_copy() -> bool {
364 false
365 }
366
367 #[inline(always)]
368 fn decode_is_copy() -> bool {
369 false
370 }
371 }
372
373 impl fidl::encoding::ValueTypeMarker for RouterResponse {
374 type Borrowed<'a> = Self;
375 #[inline(always)]
376 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
377 *value
378 }
379 }
380
381 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RouterResponse {
382 #[inline]
383 unsafe fn encode(
384 self,
385 encoder: &mut fidl::encoding::Encoder<'_, D>,
386 offset: usize,
387 _depth: fidl::encoding::Depth,
388 ) -> fidl::Result<()> {
389 encoder.debug_check_bounds::<Self>(offset);
390 encoder.write_num(self.into_primitive(), offset);
391 Ok(())
392 }
393 }
394
395 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RouterResponse {
396 #[inline(always)]
397 fn new_empty() -> Self {
398 Self::unknown()
399 }
400
401 #[inline]
402 unsafe fn decode(
403 &mut self,
404 decoder: &mut fidl::encoding::Decoder<'_, D>,
405 offset: usize,
406 _depth: fidl::encoding::Depth,
407 ) -> fidl::Result<()> {
408 decoder.debug_check_bounds::<Self>(offset);
409 let prim = decoder.read_num::<u32>(offset);
410
411 *self = Self::from_primitive_allow_unknown(prim);
412 Ok(())
413 }
414 }
415
416 impl fidl::encoding::ValueTypeMarker for DictionaryKeyIteratorGetNextResponse {
417 type Borrowed<'a> = &'a Self;
418 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
419 value
420 }
421 }
422
423 unsafe impl fidl::encoding::TypeMarker for DictionaryKeyIteratorGetNextResponse {
424 type Owned = Self;
425
426 #[inline(always)]
427 fn inline_align(_context: fidl::encoding::Context) -> usize {
428 8
429 }
430
431 #[inline(always)]
432 fn inline_size(_context: fidl::encoding::Context) -> usize {
433 16
434 }
435 }
436
437 unsafe impl<D: fidl::encoding::ResourceDialect>
438 fidl::encoding::Encode<DictionaryKeyIteratorGetNextResponse, D>
439 for &DictionaryKeyIteratorGetNextResponse
440 {
441 #[inline]
442 unsafe fn encode(
443 self,
444 encoder: &mut fidl::encoding::Encoder<'_, D>,
445 offset: usize,
446 _depth: fidl::encoding::Depth,
447 ) -> fidl::Result<()> {
448 encoder.debug_check_bounds::<DictionaryKeyIteratorGetNextResponse>(offset);
449 fidl::encoding::Encode::<DictionaryKeyIteratorGetNextResponse, D>::encode(
451 (
452 <fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<100>> as fidl::encoding::ValueTypeMarker>::borrow(&self.keys),
453 ),
454 encoder, offset, _depth
455 )
456 }
457 }
458 unsafe impl<
459 D: fidl::encoding::ResourceDialect,
460 T0: fidl::encoding::Encode<
461 fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<100>>,
462 D,
463 >,
464 > fidl::encoding::Encode<DictionaryKeyIteratorGetNextResponse, D> for (T0,)
465 {
466 #[inline]
467 unsafe fn encode(
468 self,
469 encoder: &mut fidl::encoding::Encoder<'_, D>,
470 offset: usize,
471 depth: fidl::encoding::Depth,
472 ) -> fidl::Result<()> {
473 encoder.debug_check_bounds::<DictionaryKeyIteratorGetNextResponse>(offset);
474 self.0.encode(encoder, offset + 0, depth)?;
478 Ok(())
479 }
480 }
481
482 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
483 for DictionaryKeyIteratorGetNextResponse
484 {
485 #[inline(always)]
486 fn new_empty() -> Self {
487 Self {
488 keys: fidl::new_empty!(
489 fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<100>>,
490 D
491 ),
492 }
493 }
494
495 #[inline]
496 unsafe fn decode(
497 &mut self,
498 decoder: &mut fidl::encoding::Decoder<'_, D>,
499 offset: usize,
500 _depth: fidl::encoding::Depth,
501 ) -> fidl::Result<()> {
502 decoder.debug_check_bounds::<Self>(offset);
503 fidl::decode!(
505 fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<100>>,
506 D,
507 &mut self.keys,
508 decoder,
509 offset + 0,
510 _depth
511 )?;
512 Ok(())
513 }
514 }
515
516 impl fidl::encoding::ValueTypeMarker for Data {
517 type Borrowed<'a> = &'a Self;
518 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
519 value
520 }
521 }
522
523 unsafe impl fidl::encoding::TypeMarker for Data {
524 type Owned = Self;
525
526 #[inline(always)]
527 fn inline_align(_context: fidl::encoding::Context) -> usize {
528 8
529 }
530
531 #[inline(always)]
532 fn inline_size(_context: fidl::encoding::Context) -> usize {
533 16
534 }
535 }
536
537 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Data, D> for &Data {
538 #[inline]
539 unsafe fn encode(
540 self,
541 encoder: &mut fidl::encoding::Encoder<'_, D>,
542 offset: usize,
543 _depth: fidl::encoding::Depth,
544 ) -> fidl::Result<()> {
545 encoder.debug_check_bounds::<Data>(offset);
546 encoder.write_num::<u64>(self.ordinal(), offset);
547 match self {
548 Data::Bytes(ref val) => {
549 fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<u8, 8192>, D>(
550 <fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow(val),
551 encoder, offset + 8, _depth
552 )
553 }
554 Data::String(ref val) => {
555 fidl::encoding::encode_in_envelope::<fidl::encoding::BoundedString<8192>, D>(
556 <fidl::encoding::BoundedString<8192> as fidl::encoding::ValueTypeMarker>::borrow(val),
557 encoder, offset + 8, _depth
558 )
559 }
560 Data::Int64(ref val) => {
561 fidl::encoding::encode_in_envelope::<i64, D>(
562 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
563 encoder, offset + 8, _depth
564 )
565 }
566 Data::Uint64(ref val) => {
567 fidl::encoding::encode_in_envelope::<u64, D>(
568 <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
569 encoder, offset + 8, _depth
570 )
571 }
572 Data::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
573 }
574 }
575 }
576
577 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Data {
578 #[inline(always)]
579 fn new_empty() -> Self {
580 Self::__SourceBreaking { unknown_ordinal: 0 }
581 }
582
583 #[inline]
584 unsafe fn decode(
585 &mut self,
586 decoder: &mut fidl::encoding::Decoder<'_, D>,
587 offset: usize,
588 mut depth: fidl::encoding::Depth,
589 ) -> fidl::Result<()> {
590 decoder.debug_check_bounds::<Self>(offset);
591 #[allow(unused_variables)]
592 let next_out_of_line = decoder.next_out_of_line();
593 let handles_before = decoder.remaining_handles();
594 let (ordinal, inlined, num_bytes, num_handles) =
595 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
596
597 let member_inline_size = match ordinal {
598 1 => <fidl::encoding::Vector<u8, 8192> as fidl::encoding::TypeMarker>::inline_size(
599 decoder.context,
600 ),
601 2 => {
602 <fidl::encoding::BoundedString<8192> as fidl::encoding::TypeMarker>::inline_size(
603 decoder.context,
604 )
605 }
606 3 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
607 4 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
608 0 => return Err(fidl::Error::UnknownUnionTag),
609 _ => num_bytes as usize,
610 };
611
612 if inlined != (member_inline_size <= 4) {
613 return Err(fidl::Error::InvalidInlineBitInEnvelope);
614 }
615 let _inner_offset;
616 if inlined {
617 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
618 _inner_offset = offset + 8;
619 } else {
620 depth.increment()?;
621 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
622 }
623 match ordinal {
624 1 => {
625 #[allow(irrefutable_let_patterns)]
626 if let Data::Bytes(_) = self {
627 } else {
629 *self = Data::Bytes(fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, D));
631 }
632 #[allow(irrefutable_let_patterns)]
633 if let Data::Bytes(ref mut val) = self {
634 fidl::decode!(fidl::encoding::Vector<u8, 8192>, D, val, decoder, _inner_offset, depth)?;
635 } else {
636 unreachable!()
637 }
638 }
639 2 => {
640 #[allow(irrefutable_let_patterns)]
641 if let Data::String(_) = self {
642 } else {
644 *self =
646 Data::String(fidl::new_empty!(fidl::encoding::BoundedString<8192>, D));
647 }
648 #[allow(irrefutable_let_patterns)]
649 if let Data::String(ref mut val) = self {
650 fidl::decode!(
651 fidl::encoding::BoundedString<8192>,
652 D,
653 val,
654 decoder,
655 _inner_offset,
656 depth
657 )?;
658 } else {
659 unreachable!()
660 }
661 }
662 3 => {
663 #[allow(irrefutable_let_patterns)]
664 if let Data::Int64(_) = self {
665 } else {
667 *self = Data::Int64(fidl::new_empty!(i64, D));
669 }
670 #[allow(irrefutable_let_patterns)]
671 if let Data::Int64(ref mut val) = self {
672 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
673 } else {
674 unreachable!()
675 }
676 }
677 4 => {
678 #[allow(irrefutable_let_patterns)]
679 if let Data::Uint64(_) = self {
680 } else {
682 *self = Data::Uint64(fidl::new_empty!(u64, D));
684 }
685 #[allow(irrefutable_let_patterns)]
686 if let Data::Uint64(ref mut val) = self {
687 fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
688 } else {
689 unreachable!()
690 }
691 }
692 #[allow(deprecated)]
693 ordinal => {
694 for _ in 0..num_handles {
695 decoder.drop_next_handle()?;
696 }
697 *self = Data::__SourceBreaking { unknown_ordinal: ordinal };
698 }
699 }
700 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
701 return Err(fidl::Error::InvalidNumBytesInEnvelope);
702 }
703 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
704 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
705 }
706 Ok(())
707 }
708 }
709}