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
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub enum GattError {
13 MissingParameters,
15 PeerNotFound,
17 HandleNotFound,
19 Internal,
21 #[doc(hidden)]
22 __SourceBreaking { unknown_ordinal: u32 },
23}
24
25#[macro_export]
27macro_rules! GattErrorUnknown {
28 () => {
29 _
30 };
31}
32
33impl GattError {
34 #[inline]
35 pub fn from_primitive(prim: u32) -> Option<Self> {
36 match prim {
37 1 => Some(Self::MissingParameters),
38 2 => Some(Self::PeerNotFound),
39 3 => Some(Self::HandleNotFound),
40 4 => Some(Self::Internal),
41 _ => None,
42 }
43 }
44
45 #[inline]
46 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
47 match prim {
48 1 => Self::MissingParameters,
49 2 => Self::PeerNotFound,
50 3 => Self::HandleNotFound,
51 4 => Self::Internal,
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::MissingParameters => 1,
65 Self::PeerNotFound => 2,
66 Self::HandleNotFound => 3,
67 Self::Internal => 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 GattResolvePeerAttHandleRequest {
83 pub id: Option<fidl_fuchsia_bluetooth_common::PeerId>,
85 pub attribute_handle: Option<u64>,
87 #[doc(hidden)]
88 pub __source_breaking: fidl::marker::SourceBreaking,
89}
90
91impl fidl::Persistable for GattResolvePeerAttHandleRequest {}
92
93#[derive(Clone, Debug, Default, PartialEq)]
94pub struct GattResolvePeerAttHandleResponse {
95 pub service_handle: Option<fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle>,
97 pub characteristic_handle: Option<fidl_fuchsia_bluetooth_gatt2_common::Handle>,
99 #[doc(hidden)]
100 pub __source_breaking: fidl::marker::SourceBreaking,
101}
102
103impl fidl::Persistable for GattResolvePeerAttHandleResponse {}
104
105pub mod gatt_ordinals {
106 pub const RESOLVE_PEER_ATT_HANDLE: u64 = 0x462b9cc1b4b58d4f;
107}
108
109mod internal {
110 use super::*;
111 unsafe impl fidl::encoding::TypeMarker for GattError {
112 type Owned = Self;
113
114 #[inline(always)]
115 fn inline_align(_context: fidl::encoding::Context) -> usize {
116 std::mem::align_of::<u32>()
117 }
118
119 #[inline(always)]
120 fn inline_size(_context: fidl::encoding::Context) -> usize {
121 std::mem::size_of::<u32>()
122 }
123
124 #[inline(always)]
125 fn encode_is_copy() -> bool {
126 false
127 }
128
129 #[inline(always)]
130 fn decode_is_copy() -> bool {
131 false
132 }
133 }
134
135 impl fidl::encoding::ValueTypeMarker for GattError {
136 type Borrowed<'a> = Self;
137 #[inline(always)]
138 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
139 *value
140 }
141 }
142
143 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GattError {
144 #[inline]
145 unsafe fn encode(
146 self,
147 encoder: &mut fidl::encoding::Encoder<'_, D>,
148 offset: usize,
149 _depth: fidl::encoding::Depth,
150 ) -> fidl::Result<()> {
151 encoder.debug_check_bounds::<Self>(offset);
152 encoder.write_num(self.into_primitive(), offset);
153 Ok(())
154 }
155 }
156
157 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GattError {
158 #[inline(always)]
159 fn new_empty() -> Self {
160 Self::unknown()
161 }
162
163 #[inline]
164 unsafe fn decode(
165 &mut self,
166 decoder: &mut fidl::encoding::Decoder<'_, D>,
167 offset: usize,
168 _depth: fidl::encoding::Depth,
169 ) -> fidl::Result<()> {
170 decoder.debug_check_bounds::<Self>(offset);
171 let prim = decoder.read_num::<u32>(offset);
172
173 *self = Self::from_primitive_allow_unknown(prim);
174 Ok(())
175 }
176 }
177
178 impl GattResolvePeerAttHandleRequest {
179 #[inline(always)]
180 fn max_ordinal_present(&self) -> u64 {
181 if let Some(_) = self.attribute_handle {
182 return 2;
183 }
184 if let Some(_) = self.id {
185 return 1;
186 }
187 0
188 }
189 }
190
191 impl fidl::encoding::ValueTypeMarker for GattResolvePeerAttHandleRequest {
192 type Borrowed<'a> = &'a Self;
193 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
194 value
195 }
196 }
197
198 unsafe impl fidl::encoding::TypeMarker for GattResolvePeerAttHandleRequest {
199 type Owned = Self;
200
201 #[inline(always)]
202 fn inline_align(_context: fidl::encoding::Context) -> usize {
203 8
204 }
205
206 #[inline(always)]
207 fn inline_size(_context: fidl::encoding::Context) -> usize {
208 16
209 }
210 }
211
212 unsafe impl<D: fidl::encoding::ResourceDialect>
213 fidl::encoding::Encode<GattResolvePeerAttHandleRequest, D>
214 for &GattResolvePeerAttHandleRequest
215 {
216 unsafe fn encode(
217 self,
218 encoder: &mut fidl::encoding::Encoder<'_, D>,
219 offset: usize,
220 mut depth: fidl::encoding::Depth,
221 ) -> fidl::Result<()> {
222 encoder.debug_check_bounds::<GattResolvePeerAttHandleRequest>(offset);
223 let max_ordinal: u64 = self.max_ordinal_present();
225 encoder.write_num(max_ordinal, offset);
226 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
227 if max_ordinal == 0 {
229 return Ok(());
230 }
231 depth.increment()?;
232 let envelope_size = 8;
233 let bytes_len = max_ordinal as usize * envelope_size;
234 #[allow(unused_variables)]
235 let offset = encoder.out_of_line_offset(bytes_len);
236 let mut _prev_end_offset: usize = 0;
237 if 1 > max_ordinal {
238 return Ok(());
239 }
240
241 let cur_offset: usize = (1 - 1) * envelope_size;
244
245 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
247
248 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_common::PeerId, D>(
253 self.id.as_ref().map(<fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::ValueTypeMarker>::borrow),
254 encoder, offset + cur_offset, depth
255 )?;
256
257 _prev_end_offset = cur_offset + envelope_size;
258 if 2 > max_ordinal {
259 return Ok(());
260 }
261
262 let cur_offset: usize = (2 - 1) * envelope_size;
265
266 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
268
269 fidl::encoding::encode_in_envelope_optional::<u64, D>(
274 self.attribute_handle
275 .as_ref()
276 .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
277 encoder,
278 offset + cur_offset,
279 depth,
280 )?;
281
282 _prev_end_offset = cur_offset + envelope_size;
283
284 Ok(())
285 }
286 }
287
288 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
289 for GattResolvePeerAttHandleRequest
290 {
291 #[inline(always)]
292 fn new_empty() -> Self {
293 Self::default()
294 }
295
296 unsafe fn decode(
297 &mut self,
298 decoder: &mut fidl::encoding::Decoder<'_, D>,
299 offset: usize,
300 mut depth: fidl::encoding::Depth,
301 ) -> fidl::Result<()> {
302 decoder.debug_check_bounds::<Self>(offset);
303 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
304 None => return Err(fidl::Error::NotNullable),
305 Some(len) => len,
306 };
307 if len == 0 {
309 return Ok(());
310 };
311 depth.increment()?;
312 let envelope_size = 8;
313 let bytes_len = len * envelope_size;
314 let offset = decoder.out_of_line_offset(bytes_len)?;
315 let mut _next_ordinal_to_read = 0;
317 let mut next_offset = offset;
318 let end_offset = offset + bytes_len;
319 _next_ordinal_to_read += 1;
320 if next_offset >= end_offset {
321 return Ok(());
322 }
323
324 while _next_ordinal_to_read < 1 {
326 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
327 _next_ordinal_to_read += 1;
328 next_offset += envelope_size;
329 }
330
331 let next_out_of_line = decoder.next_out_of_line();
332 let handles_before = decoder.remaining_handles();
333 if let Some((inlined, num_bytes, num_handles)) =
334 fidl::encoding::decode_envelope_header(decoder, next_offset)?
335 {
336 let member_inline_size = <fidl_fuchsia_bluetooth_common::PeerId as fidl::encoding::TypeMarker>::inline_size(decoder.context);
337 if inlined != (member_inline_size <= 4) {
338 return Err(fidl::Error::InvalidInlineBitInEnvelope);
339 }
340 let inner_offset;
341 let mut inner_depth = depth.clone();
342 if inlined {
343 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
344 inner_offset = next_offset;
345 } else {
346 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
347 inner_depth.increment()?;
348 }
349 let val_ref = self.id.get_or_insert_with(|| {
350 fidl::new_empty!(fidl_fuchsia_bluetooth_common::PeerId, D)
351 });
352 fidl::decode!(
353 fidl_fuchsia_bluetooth_common::PeerId,
354 D,
355 val_ref,
356 decoder,
357 inner_offset,
358 inner_depth
359 )?;
360 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
361 {
362 return Err(fidl::Error::InvalidNumBytesInEnvelope);
363 }
364 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
365 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
366 }
367 }
368
369 next_offset += envelope_size;
370 _next_ordinal_to_read += 1;
371 if next_offset >= end_offset {
372 return Ok(());
373 }
374
375 while _next_ordinal_to_read < 2 {
377 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
378 _next_ordinal_to_read += 1;
379 next_offset += envelope_size;
380 }
381
382 let next_out_of_line = decoder.next_out_of_line();
383 let handles_before = decoder.remaining_handles();
384 if let Some((inlined, num_bytes, num_handles)) =
385 fidl::encoding::decode_envelope_header(decoder, next_offset)?
386 {
387 let member_inline_size =
388 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
389 if inlined != (member_inline_size <= 4) {
390 return Err(fidl::Error::InvalidInlineBitInEnvelope);
391 }
392 let inner_offset;
393 let mut inner_depth = depth.clone();
394 if inlined {
395 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
396 inner_offset = next_offset;
397 } else {
398 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
399 inner_depth.increment()?;
400 }
401 let val_ref = self.attribute_handle.get_or_insert_with(|| fidl::new_empty!(u64, D));
402 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
403 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
404 {
405 return Err(fidl::Error::InvalidNumBytesInEnvelope);
406 }
407 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
408 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
409 }
410 }
411
412 next_offset += envelope_size;
413
414 while next_offset < end_offset {
416 _next_ordinal_to_read += 1;
417 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
418 next_offset += envelope_size;
419 }
420
421 Ok(())
422 }
423 }
424
425 impl GattResolvePeerAttHandleResponse {
426 #[inline(always)]
427 fn max_ordinal_present(&self) -> u64 {
428 if let Some(_) = self.characteristic_handle {
429 return 2;
430 }
431 if let Some(_) = self.service_handle {
432 return 1;
433 }
434 0
435 }
436 }
437
438 impl fidl::encoding::ValueTypeMarker for GattResolvePeerAttHandleResponse {
439 type Borrowed<'a> = &'a Self;
440 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
441 value
442 }
443 }
444
445 unsafe impl fidl::encoding::TypeMarker for GattResolvePeerAttHandleResponse {
446 type Owned = Self;
447
448 #[inline(always)]
449 fn inline_align(_context: fidl::encoding::Context) -> usize {
450 8
451 }
452
453 #[inline(always)]
454 fn inline_size(_context: fidl::encoding::Context) -> usize {
455 16
456 }
457 }
458
459 unsafe impl<D: fidl::encoding::ResourceDialect>
460 fidl::encoding::Encode<GattResolvePeerAttHandleResponse, D>
461 for &GattResolvePeerAttHandleResponse
462 {
463 unsafe fn encode(
464 self,
465 encoder: &mut fidl::encoding::Encoder<'_, D>,
466 offset: usize,
467 mut depth: fidl::encoding::Depth,
468 ) -> fidl::Result<()> {
469 encoder.debug_check_bounds::<GattResolvePeerAttHandleResponse>(offset);
470 let max_ordinal: u64 = self.max_ordinal_present();
472 encoder.write_num(max_ordinal, offset);
473 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
474 if max_ordinal == 0 {
476 return Ok(());
477 }
478 depth.increment()?;
479 let envelope_size = 8;
480 let bytes_len = max_ordinal as usize * envelope_size;
481 #[allow(unused_variables)]
482 let offset = encoder.out_of_line_offset(bytes_len);
483 let mut _prev_end_offset: usize = 0;
484 if 1 > max_ordinal {
485 return Ok(());
486 }
487
488 let cur_offset: usize = (1 - 1) * envelope_size;
491
492 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
494
495 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle, D>(
500 self.service_handle.as_ref().map(<fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle as fidl::encoding::ValueTypeMarker>::borrow),
501 encoder, offset + cur_offset, depth
502 )?;
503
504 _prev_end_offset = cur_offset + envelope_size;
505 if 2 > max_ordinal {
506 return Ok(());
507 }
508
509 let cur_offset: usize = (2 - 1) * envelope_size;
512
513 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
515
516 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth_gatt2_common::Handle, D>(
521 self.characteristic_handle.as_ref().map(<fidl_fuchsia_bluetooth_gatt2_common::Handle as fidl::encoding::ValueTypeMarker>::borrow),
522 encoder, offset + cur_offset, depth
523 )?;
524
525 _prev_end_offset = cur_offset + envelope_size;
526
527 Ok(())
528 }
529 }
530
531 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
532 for GattResolvePeerAttHandleResponse
533 {
534 #[inline(always)]
535 fn new_empty() -> Self {
536 Self::default()
537 }
538
539 unsafe fn decode(
540 &mut self,
541 decoder: &mut fidl::encoding::Decoder<'_, D>,
542 offset: usize,
543 mut depth: fidl::encoding::Depth,
544 ) -> fidl::Result<()> {
545 decoder.debug_check_bounds::<Self>(offset);
546 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
547 None => return Err(fidl::Error::NotNullable),
548 Some(len) => len,
549 };
550 if len == 0 {
552 return Ok(());
553 };
554 depth.increment()?;
555 let envelope_size = 8;
556 let bytes_len = len * envelope_size;
557 let offset = decoder.out_of_line_offset(bytes_len)?;
558 let mut _next_ordinal_to_read = 0;
560 let mut next_offset = offset;
561 let end_offset = offset + bytes_len;
562 _next_ordinal_to_read += 1;
563 if next_offset >= end_offset {
564 return Ok(());
565 }
566
567 while _next_ordinal_to_read < 1 {
569 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
570 _next_ordinal_to_read += 1;
571 next_offset += envelope_size;
572 }
573
574 let next_out_of_line = decoder.next_out_of_line();
575 let handles_before = decoder.remaining_handles();
576 if let Some((inlined, num_bytes, num_handles)) =
577 fidl::encoding::decode_envelope_header(decoder, next_offset)?
578 {
579 let member_inline_size = <fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
580 if inlined != (member_inline_size <= 4) {
581 return Err(fidl::Error::InvalidInlineBitInEnvelope);
582 }
583 let inner_offset;
584 let mut inner_depth = depth.clone();
585 if inlined {
586 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
587 inner_offset = next_offset;
588 } else {
589 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
590 inner_depth.increment()?;
591 }
592 let val_ref = self.service_handle.get_or_insert_with(|| {
593 fidl::new_empty!(fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle, D)
594 });
595 fidl::decode!(
596 fidl_fuchsia_bluetooth_gatt2_common::ServiceHandle,
597 D,
598 val_ref,
599 decoder,
600 inner_offset,
601 inner_depth
602 )?;
603 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
604 {
605 return Err(fidl::Error::InvalidNumBytesInEnvelope);
606 }
607 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
608 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
609 }
610 }
611
612 next_offset += envelope_size;
613 _next_ordinal_to_read += 1;
614 if next_offset >= end_offset {
615 return Ok(());
616 }
617
618 while _next_ordinal_to_read < 2 {
620 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
621 _next_ordinal_to_read += 1;
622 next_offset += envelope_size;
623 }
624
625 let next_out_of_line = decoder.next_out_of_line();
626 let handles_before = decoder.remaining_handles();
627 if let Some((inlined, num_bytes, num_handles)) =
628 fidl::encoding::decode_envelope_header(decoder, next_offset)?
629 {
630 let member_inline_size = <fidl_fuchsia_bluetooth_gatt2_common::Handle as fidl::encoding::TypeMarker>::inline_size(decoder.context);
631 if inlined != (member_inline_size <= 4) {
632 return Err(fidl::Error::InvalidInlineBitInEnvelope);
633 }
634 let inner_offset;
635 let mut inner_depth = depth.clone();
636 if inlined {
637 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
638 inner_offset = next_offset;
639 } else {
640 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
641 inner_depth.increment()?;
642 }
643 let val_ref = self.characteristic_handle.get_or_insert_with(|| {
644 fidl::new_empty!(fidl_fuchsia_bluetooth_gatt2_common::Handle, D)
645 });
646 fidl::decode!(
647 fidl_fuchsia_bluetooth_gatt2_common::Handle,
648 D,
649 val_ref,
650 decoder,
651 inner_offset,
652 inner_depth
653 )?;
654 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
655 {
656 return Err(fidl::Error::InvalidNumBytesInEnvelope);
657 }
658 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
659 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
660 }
661 }
662
663 next_offset += envelope_size;
664
665 while next_offset < end_offset {
667 _next_ordinal_to_read += 1;
668 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
669 next_offset += envelope_size;
670 }
671
672 Ok(())
673 }
674 }
675}