fidl_fuchsia_bluetooth_pandora_common/
fidl_fuchsia_bluetooth_pandora_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub enum ServiceError {
13    /// The requested component was already running.
14    AlreadyRunning,
15    /// The provided IP address could not be parsed.
16    InvalidIp,
17    /// A connection could not be established to the provided address.
18    ConnectionFailed,
19    /// The request failed internally.
20    Failed,
21    #[doc(hidden)]
22    __SourceBreaking { unknown_ordinal: u32 },
23}
24
25/// Pattern that matches an unknown `ServiceError` member.
26#[macro_export]
27macro_rules! ServiceErrorUnknown {
28    () => {
29        _
30    };
31}
32
33impl ServiceError {
34    #[inline]
35    pub fn from_primitive(prim: u32) -> Option<Self> {
36        match prim {
37            1 => Some(Self::AlreadyRunning),
38            2 => Some(Self::InvalidIp),
39            3 => Some(Self::ConnectionFailed),
40            4 => Some(Self::Failed),
41            _ => None,
42        }
43    }
44
45    #[inline]
46    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
47        match prim {
48            1 => Self::AlreadyRunning,
49            2 => Self::InvalidIp,
50            3 => Self::ConnectionFailed,
51            4 => Self::Failed,
52            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
53        }
54    }
55
56    #[inline]
57    pub fn unknown() -> Self {
58        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
59    }
60
61    #[inline]
62    pub const fn into_primitive(self) -> u32 {
63        match self {
64            Self::AlreadyRunning => 1,
65            Self::InvalidIp => 2,
66            Self::ConnectionFailed => 3,
67            Self::Failed => 4,
68            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
69        }
70    }
71
72    #[inline]
73    pub fn is_unknown(&self) -> bool {
74        match self {
75            Self::__SourceBreaking { unknown_ordinal: _ } => true,
76            _ => false,
77        }
78    }
79}
80
81#[derive(Clone, Debug, Default, PartialEq)]
82pub struct GrpcServerControllerStartRequest {
83    pub port: Option<u16>,
84    #[doc(hidden)]
85    pub __source_breaking: fidl::marker::SourceBreaking,
86}
87
88impl fidl::Persistable for GrpcServerControllerStartRequest {}
89
90#[derive(Clone, Debug, Default, PartialEq)]
91pub struct RootcanalClientControllerStartRequest {
92    pub ip: Option<String>,
93    pub port: Option<u16>,
94    #[doc(hidden)]
95    pub __source_breaking: fidl::marker::SourceBreaking,
96}
97
98impl fidl::Persistable for RootcanalClientControllerStartRequest {}
99
100mod internal {
101    use super::*;
102    unsafe impl fidl::encoding::TypeMarker for ServiceError {
103        type Owned = Self;
104
105        #[inline(always)]
106        fn inline_align(_context: fidl::encoding::Context) -> usize {
107            std::mem::align_of::<u32>()
108        }
109
110        #[inline(always)]
111        fn inline_size(_context: fidl::encoding::Context) -> usize {
112            std::mem::size_of::<u32>()
113        }
114
115        #[inline(always)]
116        fn encode_is_copy() -> bool {
117            false
118        }
119
120        #[inline(always)]
121        fn decode_is_copy() -> bool {
122            false
123        }
124    }
125
126    impl fidl::encoding::ValueTypeMarker for ServiceError {
127        type Borrowed<'a> = Self;
128        #[inline(always)]
129        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
130            *value
131        }
132    }
133
134    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ServiceError {
135        #[inline]
136        unsafe fn encode(
137            self,
138            encoder: &mut fidl::encoding::Encoder<'_, D>,
139            offset: usize,
140            _depth: fidl::encoding::Depth,
141        ) -> fidl::Result<()> {
142            encoder.debug_check_bounds::<Self>(offset);
143            encoder.write_num(self.into_primitive(), offset);
144            Ok(())
145        }
146    }
147
148    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ServiceError {
149        #[inline(always)]
150        fn new_empty() -> Self {
151            Self::unknown()
152        }
153
154        #[inline]
155        unsafe fn decode(
156            &mut self,
157            decoder: &mut fidl::encoding::Decoder<'_, D>,
158            offset: usize,
159            _depth: fidl::encoding::Depth,
160        ) -> fidl::Result<()> {
161            decoder.debug_check_bounds::<Self>(offset);
162            let prim = decoder.read_num::<u32>(offset);
163
164            *self = Self::from_primitive_allow_unknown(prim);
165            Ok(())
166        }
167    }
168
169    impl GrpcServerControllerStartRequest {
170        #[inline(always)]
171        fn max_ordinal_present(&self) -> u64 {
172            if let Some(_) = self.port {
173                return 1;
174            }
175            0
176        }
177    }
178
179    impl fidl::encoding::ValueTypeMarker for GrpcServerControllerStartRequest {
180        type Borrowed<'a> = &'a Self;
181        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
182            value
183        }
184    }
185
186    unsafe impl fidl::encoding::TypeMarker for GrpcServerControllerStartRequest {
187        type Owned = Self;
188
189        #[inline(always)]
190        fn inline_align(_context: fidl::encoding::Context) -> usize {
191            8
192        }
193
194        #[inline(always)]
195        fn inline_size(_context: fidl::encoding::Context) -> usize {
196            16
197        }
198    }
199
200    unsafe impl<D: fidl::encoding::ResourceDialect>
201        fidl::encoding::Encode<GrpcServerControllerStartRequest, D>
202        for &GrpcServerControllerStartRequest
203    {
204        unsafe fn encode(
205            self,
206            encoder: &mut fidl::encoding::Encoder<'_, D>,
207            offset: usize,
208            mut depth: fidl::encoding::Depth,
209        ) -> fidl::Result<()> {
210            encoder.debug_check_bounds::<GrpcServerControllerStartRequest>(offset);
211            // Vector header
212            let max_ordinal: u64 = self.max_ordinal_present();
213            encoder.write_num(max_ordinal, offset);
214            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
215            // Calling encoder.out_of_line_offset(0) is not allowed.
216            if max_ordinal == 0 {
217                return Ok(());
218            }
219            depth.increment()?;
220            let envelope_size = 8;
221            let bytes_len = max_ordinal as usize * envelope_size;
222            #[allow(unused_variables)]
223            let offset = encoder.out_of_line_offset(bytes_len);
224            let mut _prev_end_offset: usize = 0;
225            if 1 > max_ordinal {
226                return Ok(());
227            }
228
229            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
230            // are envelope_size bytes.
231            let cur_offset: usize = (1 - 1) * envelope_size;
232
233            // Zero reserved fields.
234            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
235
236            // Safety:
237            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
238            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
239            //   envelope_size bytes, there is always sufficient room.
240            fidl::encoding::encode_in_envelope_optional::<u16, D>(
241                self.port.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
242                encoder,
243                offset + cur_offset,
244                depth,
245            )?;
246
247            _prev_end_offset = cur_offset + envelope_size;
248
249            Ok(())
250        }
251    }
252
253    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
254        for GrpcServerControllerStartRequest
255    {
256        #[inline(always)]
257        fn new_empty() -> Self {
258            Self::default()
259        }
260
261        unsafe fn decode(
262            &mut self,
263            decoder: &mut fidl::encoding::Decoder<'_, D>,
264            offset: usize,
265            mut depth: fidl::encoding::Depth,
266        ) -> fidl::Result<()> {
267            decoder.debug_check_bounds::<Self>(offset);
268            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
269                None => return Err(fidl::Error::NotNullable),
270                Some(len) => len,
271            };
272            // Calling decoder.out_of_line_offset(0) is not allowed.
273            if len == 0 {
274                return Ok(());
275            };
276            depth.increment()?;
277            let envelope_size = 8;
278            let bytes_len = len * envelope_size;
279            let offset = decoder.out_of_line_offset(bytes_len)?;
280            // Decode the envelope for each type.
281            let mut _next_ordinal_to_read = 0;
282            let mut next_offset = offset;
283            let end_offset = offset + bytes_len;
284            _next_ordinal_to_read += 1;
285            if next_offset >= end_offset {
286                return Ok(());
287            }
288
289            // Decode unknown envelopes for gaps in ordinals.
290            while _next_ordinal_to_read < 1 {
291                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
292                _next_ordinal_to_read += 1;
293                next_offset += envelope_size;
294            }
295
296            let next_out_of_line = decoder.next_out_of_line();
297            let handles_before = decoder.remaining_handles();
298            if let Some((inlined, num_bytes, num_handles)) =
299                fidl::encoding::decode_envelope_header(decoder, next_offset)?
300            {
301                let member_inline_size =
302                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
303                if inlined != (member_inline_size <= 4) {
304                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
305                }
306                let inner_offset;
307                let mut inner_depth = depth.clone();
308                if inlined {
309                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
310                    inner_offset = next_offset;
311                } else {
312                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
313                    inner_depth.increment()?;
314                }
315                let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u16, D));
316                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
317                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
318                {
319                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
320                }
321                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
322                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
323                }
324            }
325
326            next_offset += envelope_size;
327
328            // Decode the remaining unknown envelopes.
329            while next_offset < end_offset {
330                _next_ordinal_to_read += 1;
331                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
332                next_offset += envelope_size;
333            }
334
335            Ok(())
336        }
337    }
338
339    impl RootcanalClientControllerStartRequest {
340        #[inline(always)]
341        fn max_ordinal_present(&self) -> u64 {
342            if let Some(_) = self.port {
343                return 2;
344            }
345            if let Some(_) = self.ip {
346                return 1;
347            }
348            0
349        }
350    }
351
352    impl fidl::encoding::ValueTypeMarker for RootcanalClientControllerStartRequest {
353        type Borrowed<'a> = &'a Self;
354        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
355            value
356        }
357    }
358
359    unsafe impl fidl::encoding::TypeMarker for RootcanalClientControllerStartRequest {
360        type Owned = Self;
361
362        #[inline(always)]
363        fn inline_align(_context: fidl::encoding::Context) -> usize {
364            8
365        }
366
367        #[inline(always)]
368        fn inline_size(_context: fidl::encoding::Context) -> usize {
369            16
370        }
371    }
372
373    unsafe impl<D: fidl::encoding::ResourceDialect>
374        fidl::encoding::Encode<RootcanalClientControllerStartRequest, D>
375        for &RootcanalClientControllerStartRequest
376    {
377        unsafe fn encode(
378            self,
379            encoder: &mut fidl::encoding::Encoder<'_, D>,
380            offset: usize,
381            mut depth: fidl::encoding::Depth,
382        ) -> fidl::Result<()> {
383            encoder.debug_check_bounds::<RootcanalClientControllerStartRequest>(offset);
384            // Vector header
385            let max_ordinal: u64 = self.max_ordinal_present();
386            encoder.write_num(max_ordinal, offset);
387            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
388            // Calling encoder.out_of_line_offset(0) is not allowed.
389            if max_ordinal == 0 {
390                return Ok(());
391            }
392            depth.increment()?;
393            let envelope_size = 8;
394            let bytes_len = max_ordinal as usize * envelope_size;
395            #[allow(unused_variables)]
396            let offset = encoder.out_of_line_offset(bytes_len);
397            let mut _prev_end_offset: usize = 0;
398            if 1 > max_ordinal {
399                return Ok(());
400            }
401
402            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
403            // are envelope_size bytes.
404            let cur_offset: usize = (1 - 1) * envelope_size;
405
406            // Zero reserved fields.
407            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
408
409            // Safety:
410            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
411            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
412            //   envelope_size bytes, there is always sufficient room.
413            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<32>, D>(
414                self.ip.as_ref().map(
415                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
416                ),
417                encoder,
418                offset + cur_offset,
419                depth,
420            )?;
421
422            _prev_end_offset = cur_offset + envelope_size;
423            if 2 > max_ordinal {
424                return Ok(());
425            }
426
427            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
428            // are envelope_size bytes.
429            let cur_offset: usize = (2 - 1) * envelope_size;
430
431            // Zero reserved fields.
432            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
433
434            // Safety:
435            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
436            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
437            //   envelope_size bytes, there is always sufficient room.
438            fidl::encoding::encode_in_envelope_optional::<u16, D>(
439                self.port.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
440                encoder,
441                offset + cur_offset,
442                depth,
443            )?;
444
445            _prev_end_offset = cur_offset + envelope_size;
446
447            Ok(())
448        }
449    }
450
451    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
452        for RootcanalClientControllerStartRequest
453    {
454        #[inline(always)]
455        fn new_empty() -> Self {
456            Self::default()
457        }
458
459        unsafe fn decode(
460            &mut self,
461            decoder: &mut fidl::encoding::Decoder<'_, D>,
462            offset: usize,
463            mut depth: fidl::encoding::Depth,
464        ) -> fidl::Result<()> {
465            decoder.debug_check_bounds::<Self>(offset);
466            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
467                None => return Err(fidl::Error::NotNullable),
468                Some(len) => len,
469            };
470            // Calling decoder.out_of_line_offset(0) is not allowed.
471            if len == 0 {
472                return Ok(());
473            };
474            depth.increment()?;
475            let envelope_size = 8;
476            let bytes_len = len * envelope_size;
477            let offset = decoder.out_of_line_offset(bytes_len)?;
478            // Decode the envelope for each type.
479            let mut _next_ordinal_to_read = 0;
480            let mut next_offset = offset;
481            let end_offset = offset + bytes_len;
482            _next_ordinal_to_read += 1;
483            if next_offset >= end_offset {
484                return Ok(());
485            }
486
487            // Decode unknown envelopes for gaps in ordinals.
488            while _next_ordinal_to_read < 1 {
489                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
490                _next_ordinal_to_read += 1;
491                next_offset += envelope_size;
492            }
493
494            let next_out_of_line = decoder.next_out_of_line();
495            let handles_before = decoder.remaining_handles();
496            if let Some((inlined, num_bytes, num_handles)) =
497                fidl::encoding::decode_envelope_header(decoder, next_offset)?
498            {
499                let member_inline_size =
500                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
501                        decoder.context,
502                    );
503                if inlined != (member_inline_size <= 4) {
504                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
505                }
506                let inner_offset;
507                let mut inner_depth = depth.clone();
508                if inlined {
509                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
510                    inner_offset = next_offset;
511                } else {
512                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
513                    inner_depth.increment()?;
514                }
515                let val_ref = self
516                    .ip
517                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<32>, D));
518                fidl::decode!(
519                    fidl::encoding::BoundedString<32>,
520                    D,
521                    val_ref,
522                    decoder,
523                    inner_offset,
524                    inner_depth
525                )?;
526                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
527                {
528                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
529                }
530                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
531                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
532                }
533            }
534
535            next_offset += envelope_size;
536            _next_ordinal_to_read += 1;
537            if next_offset >= end_offset {
538                return Ok(());
539            }
540
541            // Decode unknown envelopes for gaps in ordinals.
542            while _next_ordinal_to_read < 2 {
543                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
544                _next_ordinal_to_read += 1;
545                next_offset += envelope_size;
546            }
547
548            let next_out_of_line = decoder.next_out_of_line();
549            let handles_before = decoder.remaining_handles();
550            if let Some((inlined, num_bytes, num_handles)) =
551                fidl::encoding::decode_envelope_header(decoder, next_offset)?
552            {
553                let member_inline_size =
554                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
555                if inlined != (member_inline_size <= 4) {
556                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
557                }
558                let inner_offset;
559                let mut inner_depth = depth.clone();
560                if inlined {
561                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
562                    inner_offset = next_offset;
563                } else {
564                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
565                    inner_depth.increment()?;
566                }
567                let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u16, D));
568                fidl::decode!(u16, D, val_ref, decoder, inner_offset, inner_depth)?;
569                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
570                {
571                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
572                }
573                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
574                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
575                }
576            }
577
578            next_offset += envelope_size;
579
580            // Decode the remaining unknown envelopes.
581            while next_offset < end_offset {
582                _next_ordinal_to_read += 1;
583                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
584                next_offset += envelope_size;
585            }
586
587            Ok(())
588        }
589    }
590}