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_ENDPOINTS: u32 = 255;
12
13pub const MAX_INTERFACES: u32 = 32;
14
15pub const MAX_STRINGS: u32 = 255;
16
17pub const MAX_STRING_LEN: u32 = 126;
18
19#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20#[repr(C)]
21pub struct EndpointDescriptor {
22 pub bm_attributes: u8,
23 pub w_max_packet_size: u16,
28 pub b_interval: u8,
29}
30
31impl fidl::Persistable for EndpointDescriptor {}
32
33#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34#[repr(C)]
35pub struct SuperSpeedEndpointCompanionDescriptor {
36 pub b_max_burst: u8,
37 pub bm_attributes: u8,
38 pub w_bytes_per_interval: u16,
43}
44
45impl fidl::Persistable for SuperSpeedEndpointCompanionDescriptor {}
46
47#[derive(Clone, Debug, PartialEq)]
48pub struct UsbFunctionConfigureEndpointRequest {
49 pub endpoint_address: u8,
50 pub endpoint_configuration: EndpointConfiguration,
51}
52
53impl fidl::Persistable for UsbFunctionConfigureEndpointRequest {}
54
55#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56#[repr(C)]
57pub struct UsbFunctionDisableEndpointRequest {
58 pub endpoint_address: u8,
59}
60
61impl fidl::Persistable for UsbFunctionDisableEndpointRequest {}
62
63#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
64#[repr(C)]
65pub struct UsbFunctionEndpointClearStallRequest {
66 pub endpoint_address: u8,
67}
68
69impl fidl::Persistable for UsbFunctionEndpointClearStallRequest {}
70
71#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
72#[repr(C)]
73pub struct UsbFunctionEndpointSetStallRequest {
74 pub endpoint_address: u8,
75}
76
77impl fidl::Persistable for UsbFunctionEndpointSetStallRequest {}
78
79#[derive(Clone, Debug, PartialEq)]
80pub struct UsbFunctionInterfaceControlRequest {
81 pub setup: fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup,
82 pub write: Vec<u8>,
83}
84
85impl fidl::Persistable for UsbFunctionInterfaceControlRequest {}
86
87#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
88pub struct UsbFunctionInterfaceSetConfiguredRequest {
89 pub configured: bool,
90 pub speed: fidl_fuchsia_hardware_usb_descriptor_common::UsbSpeed,
91}
92
93impl fidl::Persistable for UsbFunctionInterfaceSetConfiguredRequest {}
94
95#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96#[repr(C)]
97pub struct UsbFunctionInterfaceSetInterfaceRequest {
98 pub interface: u8,
99 pub alt_setting: u8,
100}
101
102impl fidl::Persistable for UsbFunctionInterfaceSetInterfaceRequest {}
103
104#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
105pub struct UsbFunctionInterfaceControlResponse {
106 pub read: Vec<u8>,
107}
108
109impl fidl::Persistable for UsbFunctionInterfaceControlResponse {}
110
111#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112pub struct UsbFunctionAllocResourcesResponse {
113 pub interface_nums: Vec<u8>,
114 pub endpoint_addrs: Vec<u8>,
115 pub string_indices: Vec<u8>,
116}
117
118impl fidl::Persistable for UsbFunctionAllocResourcesResponse {}
119
120#[derive(Clone, Debug, Default, PartialEq)]
122pub struct EndpointConfiguration {
123 pub descriptor: Option<EndpointDescriptor>,
124 pub super_speed_companion: Option<SuperSpeedEndpointCompanionDescriptor>,
125 #[doc(hidden)]
126 pub __source_breaking: fidl::marker::SourceBreaking,
127}
128
129impl fidl::Persistable for EndpointConfiguration {}
130
131pub mod usb_function_ordinals {
132 pub const CONNECT_TO_ENDPOINT: u64 = 0x11541c67eb1b7f8;
133 pub const CONFIGURE: u64 = 0x42a444f4abf08b89;
134 pub const DECONFIGURE: u64 = 0x26ee8c8c826367b2;
135 pub const ALLOC_RESOURCES: u64 = 0x5ab7133ab195daa0;
136 pub const ENDPOINT_SET_STALL: u64 = 0x1f32c374dac955f1;
137 pub const ENDPOINT_CLEAR_STALL: u64 = 0x221d9488ac58aaba;
138 pub const CONFIGURE_ENDPOINT: u64 = 0x314c9dc3c37ebb7c;
139 pub const DISABLE_ENDPOINT: u64 = 0x112a132561499b6e;
140}
141
142pub mod usb_function_interface_ordinals {
143 pub const CONTROL: u64 = 0x3cce27231c012cff;
144 pub const SET_CONFIGURED: u64 = 0x5c26cc1f53f57a72;
145 pub const SET_INTERFACE: u64 = 0x42ebdcefc1543f32;
146}
147
148mod internal {
149 use super::*;
150
151 impl fidl::encoding::ValueTypeMarker for EndpointDescriptor {
152 type Borrowed<'a> = &'a Self;
153 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
154 value
155 }
156 }
157
158 unsafe impl fidl::encoding::TypeMarker for EndpointDescriptor {
159 type Owned = Self;
160
161 #[inline(always)]
162 fn inline_align(_context: fidl::encoding::Context) -> usize {
163 2
164 }
165
166 #[inline(always)]
167 fn inline_size(_context: fidl::encoding::Context) -> usize {
168 6
169 }
170 }
171
172 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EndpointDescriptor, D>
173 for &EndpointDescriptor
174 {
175 #[inline]
176 unsafe fn encode(
177 self,
178 encoder: &mut fidl::encoding::Encoder<'_, D>,
179 offset: usize,
180 _depth: fidl::encoding::Depth,
181 ) -> fidl::Result<()> {
182 encoder.debug_check_bounds::<EndpointDescriptor>(offset);
183 unsafe {
184 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
186 (buf_ptr as *mut EndpointDescriptor)
187 .write_unaligned((self as *const EndpointDescriptor).read());
188 let padding_ptr = buf_ptr.offset(0) as *mut u16;
191 let padding_mask = 0xff00u16;
192 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
193 let padding_ptr = buf_ptr.offset(4) as *mut u16;
194 let padding_mask = 0xff00u16;
195 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
196 }
197 Ok(())
198 }
199 }
200 unsafe impl<
201 D: fidl::encoding::ResourceDialect,
202 T0: fidl::encoding::Encode<u8, D>,
203 T1: fidl::encoding::Encode<u16, D>,
204 T2: fidl::encoding::Encode<u8, D>,
205 > fidl::encoding::Encode<EndpointDescriptor, D> for (T0, T1, T2)
206 {
207 #[inline]
208 unsafe fn encode(
209 self,
210 encoder: &mut fidl::encoding::Encoder<'_, D>,
211 offset: usize,
212 depth: fidl::encoding::Depth,
213 ) -> fidl::Result<()> {
214 encoder.debug_check_bounds::<EndpointDescriptor>(offset);
215 unsafe {
218 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
219 (ptr as *mut u16).write_unaligned(0);
220 }
221 unsafe {
222 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
223 (ptr as *mut u16).write_unaligned(0);
224 }
225 self.0.encode(encoder, offset + 0, depth)?;
227 self.1.encode(encoder, offset + 2, depth)?;
228 self.2.encode(encoder, offset + 4, depth)?;
229 Ok(())
230 }
231 }
232
233 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EndpointDescriptor {
234 #[inline(always)]
235 fn new_empty() -> Self {
236 Self {
237 bm_attributes: fidl::new_empty!(u8, D),
238 w_max_packet_size: fidl::new_empty!(u16, D),
239 b_interval: fidl::new_empty!(u8, D),
240 }
241 }
242
243 #[inline]
244 unsafe fn decode(
245 &mut self,
246 decoder: &mut fidl::encoding::Decoder<'_, D>,
247 offset: usize,
248 _depth: fidl::encoding::Depth,
249 ) -> fidl::Result<()> {
250 decoder.debug_check_bounds::<Self>(offset);
251 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
252 let ptr = unsafe { buf_ptr.offset(0) };
254 let padval = unsafe { (ptr as *const u16).read_unaligned() };
255 let mask = 0xff00u16;
256 let maskedval = padval & mask;
257 if maskedval != 0 {
258 return Err(fidl::Error::NonZeroPadding {
259 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
260 });
261 }
262 let ptr = unsafe { buf_ptr.offset(4) };
263 let padval = unsafe { (ptr as *const u16).read_unaligned() };
264 let mask = 0xff00u16;
265 let maskedval = padval & mask;
266 if maskedval != 0 {
267 return Err(fidl::Error::NonZeroPadding {
268 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
269 });
270 }
271 unsafe {
273 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 6);
274 }
275 Ok(())
276 }
277 }
278
279 impl fidl::encoding::ValueTypeMarker for SuperSpeedEndpointCompanionDescriptor {
280 type Borrowed<'a> = &'a Self;
281 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
282 value
283 }
284 }
285
286 unsafe impl fidl::encoding::TypeMarker for SuperSpeedEndpointCompanionDescriptor {
287 type Owned = Self;
288
289 #[inline(always)]
290 fn inline_align(_context: fidl::encoding::Context) -> usize {
291 2
292 }
293
294 #[inline(always)]
295 fn inline_size(_context: fidl::encoding::Context) -> usize {
296 4
297 }
298 #[inline(always)]
299 fn encode_is_copy() -> bool {
300 true
301 }
302
303 #[inline(always)]
304 fn decode_is_copy() -> bool {
305 true
306 }
307 }
308
309 unsafe impl<D: fidl::encoding::ResourceDialect>
310 fidl::encoding::Encode<SuperSpeedEndpointCompanionDescriptor, D>
311 for &SuperSpeedEndpointCompanionDescriptor
312 {
313 #[inline]
314 unsafe fn encode(
315 self,
316 encoder: &mut fidl::encoding::Encoder<'_, D>,
317 offset: usize,
318 _depth: fidl::encoding::Depth,
319 ) -> fidl::Result<()> {
320 encoder.debug_check_bounds::<SuperSpeedEndpointCompanionDescriptor>(offset);
321 unsafe {
322 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
324 (buf_ptr as *mut SuperSpeedEndpointCompanionDescriptor)
325 .write_unaligned((self as *const SuperSpeedEndpointCompanionDescriptor).read());
326 }
329 Ok(())
330 }
331 }
332 unsafe impl<
333 D: fidl::encoding::ResourceDialect,
334 T0: fidl::encoding::Encode<u8, D>,
335 T1: fidl::encoding::Encode<u8, D>,
336 T2: fidl::encoding::Encode<u16, D>,
337 > fidl::encoding::Encode<SuperSpeedEndpointCompanionDescriptor, D> for (T0, T1, T2)
338 {
339 #[inline]
340 unsafe fn encode(
341 self,
342 encoder: &mut fidl::encoding::Encoder<'_, D>,
343 offset: usize,
344 depth: fidl::encoding::Depth,
345 ) -> fidl::Result<()> {
346 encoder.debug_check_bounds::<SuperSpeedEndpointCompanionDescriptor>(offset);
347 self.0.encode(encoder, offset + 0, depth)?;
351 self.1.encode(encoder, offset + 1, depth)?;
352 self.2.encode(encoder, offset + 2, depth)?;
353 Ok(())
354 }
355 }
356
357 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
358 for SuperSpeedEndpointCompanionDescriptor
359 {
360 #[inline(always)]
361 fn new_empty() -> Self {
362 Self {
363 b_max_burst: fidl::new_empty!(u8, D),
364 bm_attributes: fidl::new_empty!(u8, D),
365 w_bytes_per_interval: fidl::new_empty!(u16, D),
366 }
367 }
368
369 #[inline]
370 unsafe fn decode(
371 &mut self,
372 decoder: &mut fidl::encoding::Decoder<'_, D>,
373 offset: usize,
374 _depth: fidl::encoding::Depth,
375 ) -> fidl::Result<()> {
376 decoder.debug_check_bounds::<Self>(offset);
377 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
378 unsafe {
381 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
382 }
383 Ok(())
384 }
385 }
386
387 impl fidl::encoding::ValueTypeMarker for UsbFunctionConfigureEndpointRequest {
388 type Borrowed<'a> = &'a Self;
389 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
390 value
391 }
392 }
393
394 unsafe impl fidl::encoding::TypeMarker for UsbFunctionConfigureEndpointRequest {
395 type Owned = Self;
396
397 #[inline(always)]
398 fn inline_align(_context: fidl::encoding::Context) -> usize {
399 8
400 }
401
402 #[inline(always)]
403 fn inline_size(_context: fidl::encoding::Context) -> usize {
404 24
405 }
406 }
407
408 unsafe impl<D: fidl::encoding::ResourceDialect>
409 fidl::encoding::Encode<UsbFunctionConfigureEndpointRequest, D>
410 for &UsbFunctionConfigureEndpointRequest
411 {
412 #[inline]
413 unsafe fn encode(
414 self,
415 encoder: &mut fidl::encoding::Encoder<'_, D>,
416 offset: usize,
417 _depth: fidl::encoding::Depth,
418 ) -> fidl::Result<()> {
419 encoder.debug_check_bounds::<UsbFunctionConfigureEndpointRequest>(offset);
420 fidl::encoding::Encode::<UsbFunctionConfigureEndpointRequest, D>::encode(
422 (
423 <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.endpoint_address),
424 <EndpointConfiguration as fidl::encoding::ValueTypeMarker>::borrow(
425 &self.endpoint_configuration,
426 ),
427 ),
428 encoder,
429 offset,
430 _depth,
431 )
432 }
433 }
434 unsafe impl<
435 D: fidl::encoding::ResourceDialect,
436 T0: fidl::encoding::Encode<u8, D>,
437 T1: fidl::encoding::Encode<EndpointConfiguration, D>,
438 > fidl::encoding::Encode<UsbFunctionConfigureEndpointRequest, D> for (T0, T1)
439 {
440 #[inline]
441 unsafe fn encode(
442 self,
443 encoder: &mut fidl::encoding::Encoder<'_, D>,
444 offset: usize,
445 depth: fidl::encoding::Depth,
446 ) -> fidl::Result<()> {
447 encoder.debug_check_bounds::<UsbFunctionConfigureEndpointRequest>(offset);
448 unsafe {
451 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
452 (ptr as *mut u64).write_unaligned(0);
453 }
454 self.0.encode(encoder, offset + 0, depth)?;
456 self.1.encode(encoder, offset + 8, depth)?;
457 Ok(())
458 }
459 }
460
461 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
462 for UsbFunctionConfigureEndpointRequest
463 {
464 #[inline(always)]
465 fn new_empty() -> Self {
466 Self {
467 endpoint_address: fidl::new_empty!(u8, D),
468 endpoint_configuration: fidl::new_empty!(EndpointConfiguration, D),
469 }
470 }
471
472 #[inline]
473 unsafe fn decode(
474 &mut self,
475 decoder: &mut fidl::encoding::Decoder<'_, D>,
476 offset: usize,
477 _depth: fidl::encoding::Depth,
478 ) -> fidl::Result<()> {
479 decoder.debug_check_bounds::<Self>(offset);
480 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
482 let padval = unsafe { (ptr as *const u64).read_unaligned() };
483 let mask = 0xffffffffffffff00u64;
484 let maskedval = padval & mask;
485 if maskedval != 0 {
486 return Err(fidl::Error::NonZeroPadding {
487 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
488 });
489 }
490 fidl::decode!(u8, D, &mut self.endpoint_address, decoder, offset + 0, _depth)?;
491 fidl::decode!(
492 EndpointConfiguration,
493 D,
494 &mut self.endpoint_configuration,
495 decoder,
496 offset + 8,
497 _depth
498 )?;
499 Ok(())
500 }
501 }
502
503 impl fidl::encoding::ValueTypeMarker for UsbFunctionDisableEndpointRequest {
504 type Borrowed<'a> = &'a Self;
505 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
506 value
507 }
508 }
509
510 unsafe impl fidl::encoding::TypeMarker for UsbFunctionDisableEndpointRequest {
511 type Owned = Self;
512
513 #[inline(always)]
514 fn inline_align(_context: fidl::encoding::Context) -> usize {
515 1
516 }
517
518 #[inline(always)]
519 fn inline_size(_context: fidl::encoding::Context) -> usize {
520 1
521 }
522 #[inline(always)]
523 fn encode_is_copy() -> bool {
524 true
525 }
526
527 #[inline(always)]
528 fn decode_is_copy() -> bool {
529 true
530 }
531 }
532
533 unsafe impl<D: fidl::encoding::ResourceDialect>
534 fidl::encoding::Encode<UsbFunctionDisableEndpointRequest, D>
535 for &UsbFunctionDisableEndpointRequest
536 {
537 #[inline]
538 unsafe fn encode(
539 self,
540 encoder: &mut fidl::encoding::Encoder<'_, D>,
541 offset: usize,
542 _depth: fidl::encoding::Depth,
543 ) -> fidl::Result<()> {
544 encoder.debug_check_bounds::<UsbFunctionDisableEndpointRequest>(offset);
545 unsafe {
546 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
548 (buf_ptr as *mut UsbFunctionDisableEndpointRequest)
549 .write_unaligned((self as *const UsbFunctionDisableEndpointRequest).read());
550 }
553 Ok(())
554 }
555 }
556 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
557 fidl::encoding::Encode<UsbFunctionDisableEndpointRequest, D> for (T0,)
558 {
559 #[inline]
560 unsafe fn encode(
561 self,
562 encoder: &mut fidl::encoding::Encoder<'_, D>,
563 offset: usize,
564 depth: fidl::encoding::Depth,
565 ) -> fidl::Result<()> {
566 encoder.debug_check_bounds::<UsbFunctionDisableEndpointRequest>(offset);
567 self.0.encode(encoder, offset + 0, depth)?;
571 Ok(())
572 }
573 }
574
575 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
576 for UsbFunctionDisableEndpointRequest
577 {
578 #[inline(always)]
579 fn new_empty() -> Self {
580 Self { endpoint_address: fidl::new_empty!(u8, D) }
581 }
582
583 #[inline]
584 unsafe fn decode(
585 &mut self,
586 decoder: &mut fidl::encoding::Decoder<'_, D>,
587 offset: usize,
588 _depth: fidl::encoding::Depth,
589 ) -> fidl::Result<()> {
590 decoder.debug_check_bounds::<Self>(offset);
591 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
592 unsafe {
595 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
596 }
597 Ok(())
598 }
599 }
600
601 impl fidl::encoding::ValueTypeMarker for UsbFunctionEndpointClearStallRequest {
602 type Borrowed<'a> = &'a Self;
603 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
604 value
605 }
606 }
607
608 unsafe impl fidl::encoding::TypeMarker for UsbFunctionEndpointClearStallRequest {
609 type Owned = Self;
610
611 #[inline(always)]
612 fn inline_align(_context: fidl::encoding::Context) -> usize {
613 1
614 }
615
616 #[inline(always)]
617 fn inline_size(_context: fidl::encoding::Context) -> usize {
618 1
619 }
620 #[inline(always)]
621 fn encode_is_copy() -> bool {
622 true
623 }
624
625 #[inline(always)]
626 fn decode_is_copy() -> bool {
627 true
628 }
629 }
630
631 unsafe impl<D: fidl::encoding::ResourceDialect>
632 fidl::encoding::Encode<UsbFunctionEndpointClearStallRequest, D>
633 for &UsbFunctionEndpointClearStallRequest
634 {
635 #[inline]
636 unsafe fn encode(
637 self,
638 encoder: &mut fidl::encoding::Encoder<'_, D>,
639 offset: usize,
640 _depth: fidl::encoding::Depth,
641 ) -> fidl::Result<()> {
642 encoder.debug_check_bounds::<UsbFunctionEndpointClearStallRequest>(offset);
643 unsafe {
644 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
646 (buf_ptr as *mut UsbFunctionEndpointClearStallRequest)
647 .write_unaligned((self as *const UsbFunctionEndpointClearStallRequest).read());
648 }
651 Ok(())
652 }
653 }
654 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
655 fidl::encoding::Encode<UsbFunctionEndpointClearStallRequest, D> for (T0,)
656 {
657 #[inline]
658 unsafe fn encode(
659 self,
660 encoder: &mut fidl::encoding::Encoder<'_, D>,
661 offset: usize,
662 depth: fidl::encoding::Depth,
663 ) -> fidl::Result<()> {
664 encoder.debug_check_bounds::<UsbFunctionEndpointClearStallRequest>(offset);
665 self.0.encode(encoder, offset + 0, depth)?;
669 Ok(())
670 }
671 }
672
673 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
674 for UsbFunctionEndpointClearStallRequest
675 {
676 #[inline(always)]
677 fn new_empty() -> Self {
678 Self { endpoint_address: fidl::new_empty!(u8, D) }
679 }
680
681 #[inline]
682 unsafe fn decode(
683 &mut self,
684 decoder: &mut fidl::encoding::Decoder<'_, D>,
685 offset: usize,
686 _depth: fidl::encoding::Depth,
687 ) -> fidl::Result<()> {
688 decoder.debug_check_bounds::<Self>(offset);
689 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
690 unsafe {
693 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
694 }
695 Ok(())
696 }
697 }
698
699 impl fidl::encoding::ValueTypeMarker for UsbFunctionEndpointSetStallRequest {
700 type Borrowed<'a> = &'a Self;
701 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
702 value
703 }
704 }
705
706 unsafe impl fidl::encoding::TypeMarker for UsbFunctionEndpointSetStallRequest {
707 type Owned = Self;
708
709 #[inline(always)]
710 fn inline_align(_context: fidl::encoding::Context) -> usize {
711 1
712 }
713
714 #[inline(always)]
715 fn inline_size(_context: fidl::encoding::Context) -> usize {
716 1
717 }
718 #[inline(always)]
719 fn encode_is_copy() -> bool {
720 true
721 }
722
723 #[inline(always)]
724 fn decode_is_copy() -> bool {
725 true
726 }
727 }
728
729 unsafe impl<D: fidl::encoding::ResourceDialect>
730 fidl::encoding::Encode<UsbFunctionEndpointSetStallRequest, D>
731 for &UsbFunctionEndpointSetStallRequest
732 {
733 #[inline]
734 unsafe fn encode(
735 self,
736 encoder: &mut fidl::encoding::Encoder<'_, D>,
737 offset: usize,
738 _depth: fidl::encoding::Depth,
739 ) -> fidl::Result<()> {
740 encoder.debug_check_bounds::<UsbFunctionEndpointSetStallRequest>(offset);
741 unsafe {
742 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
744 (buf_ptr as *mut UsbFunctionEndpointSetStallRequest)
745 .write_unaligned((self as *const UsbFunctionEndpointSetStallRequest).read());
746 }
749 Ok(())
750 }
751 }
752 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
753 fidl::encoding::Encode<UsbFunctionEndpointSetStallRequest, D> for (T0,)
754 {
755 #[inline]
756 unsafe fn encode(
757 self,
758 encoder: &mut fidl::encoding::Encoder<'_, D>,
759 offset: usize,
760 depth: fidl::encoding::Depth,
761 ) -> fidl::Result<()> {
762 encoder.debug_check_bounds::<UsbFunctionEndpointSetStallRequest>(offset);
763 self.0.encode(encoder, offset + 0, depth)?;
767 Ok(())
768 }
769 }
770
771 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
772 for UsbFunctionEndpointSetStallRequest
773 {
774 #[inline(always)]
775 fn new_empty() -> Self {
776 Self { endpoint_address: fidl::new_empty!(u8, D) }
777 }
778
779 #[inline]
780 unsafe fn decode(
781 &mut self,
782 decoder: &mut fidl::encoding::Decoder<'_, D>,
783 offset: usize,
784 _depth: fidl::encoding::Depth,
785 ) -> fidl::Result<()> {
786 decoder.debug_check_bounds::<Self>(offset);
787 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
788 unsafe {
791 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
792 }
793 Ok(())
794 }
795 }
796
797 impl fidl::encoding::ValueTypeMarker for UsbFunctionInterfaceControlRequest {
798 type Borrowed<'a> = &'a Self;
799 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
800 value
801 }
802 }
803
804 unsafe impl fidl::encoding::TypeMarker for UsbFunctionInterfaceControlRequest {
805 type Owned = Self;
806
807 #[inline(always)]
808 fn inline_align(_context: fidl::encoding::Context) -> usize {
809 8
810 }
811
812 #[inline(always)]
813 fn inline_size(_context: fidl::encoding::Context) -> usize {
814 24
815 }
816 }
817
818 unsafe impl<D: fidl::encoding::ResourceDialect>
819 fidl::encoding::Encode<UsbFunctionInterfaceControlRequest, D>
820 for &UsbFunctionInterfaceControlRequest
821 {
822 #[inline]
823 unsafe fn encode(
824 self,
825 encoder: &mut fidl::encoding::Encoder<'_, D>,
826 offset: usize,
827 _depth: fidl::encoding::Depth,
828 ) -> fidl::Result<()> {
829 encoder.debug_check_bounds::<UsbFunctionInterfaceControlRequest>(offset);
830 fidl::encoding::Encode::<UsbFunctionInterfaceControlRequest, D>::encode(
832 (
833 <fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup as fidl::encoding::ValueTypeMarker>::borrow(&self.setup),
834 <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.write),
835 ),
836 encoder, offset, _depth
837 )
838 }
839 }
840 unsafe impl<
841 D: fidl::encoding::ResourceDialect,
842 T0: fidl::encoding::Encode<fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup, D>,
843 T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
844 > fidl::encoding::Encode<UsbFunctionInterfaceControlRequest, D> for (T0, T1)
845 {
846 #[inline]
847 unsafe fn encode(
848 self,
849 encoder: &mut fidl::encoding::Encoder<'_, D>,
850 offset: usize,
851 depth: fidl::encoding::Depth,
852 ) -> fidl::Result<()> {
853 encoder.debug_check_bounds::<UsbFunctionInterfaceControlRequest>(offset);
854 self.0.encode(encoder, offset + 0, depth)?;
858 self.1.encode(encoder, offset + 8, depth)?;
859 Ok(())
860 }
861 }
862
863 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
864 for UsbFunctionInterfaceControlRequest
865 {
866 #[inline(always)]
867 fn new_empty() -> Self {
868 Self {
869 setup: fidl::new_empty!(fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup, D),
870 write: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
871 }
872 }
873
874 #[inline]
875 unsafe fn decode(
876 &mut self,
877 decoder: &mut fidl::encoding::Decoder<'_, D>,
878 offset: usize,
879 _depth: fidl::encoding::Depth,
880 ) -> fidl::Result<()> {
881 decoder.debug_check_bounds::<Self>(offset);
882 fidl::decode!(
884 fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup,
885 D,
886 &mut self.setup,
887 decoder,
888 offset + 0,
889 _depth
890 )?;
891 fidl::decode!(
892 fidl::encoding::UnboundedVector<u8>,
893 D,
894 &mut self.write,
895 decoder,
896 offset + 8,
897 _depth
898 )?;
899 Ok(())
900 }
901 }
902
903 impl fidl::encoding::ValueTypeMarker for UsbFunctionInterfaceSetConfiguredRequest {
904 type Borrowed<'a> = &'a Self;
905 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
906 value
907 }
908 }
909
910 unsafe impl fidl::encoding::TypeMarker for UsbFunctionInterfaceSetConfiguredRequest {
911 type Owned = Self;
912
913 #[inline(always)]
914 fn inline_align(_context: fidl::encoding::Context) -> usize {
915 4
916 }
917
918 #[inline(always)]
919 fn inline_size(_context: fidl::encoding::Context) -> usize {
920 8
921 }
922 }
923
924 unsafe impl<D: fidl::encoding::ResourceDialect>
925 fidl::encoding::Encode<UsbFunctionInterfaceSetConfiguredRequest, D>
926 for &UsbFunctionInterfaceSetConfiguredRequest
927 {
928 #[inline]
929 unsafe fn encode(
930 self,
931 encoder: &mut fidl::encoding::Encoder<'_, D>,
932 offset: usize,
933 _depth: fidl::encoding::Depth,
934 ) -> fidl::Result<()> {
935 encoder.debug_check_bounds::<UsbFunctionInterfaceSetConfiguredRequest>(offset);
936 fidl::encoding::Encode::<UsbFunctionInterfaceSetConfiguredRequest, D>::encode(
938 (
939 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.configured),
940 <fidl_fuchsia_hardware_usb_descriptor_common::UsbSpeed as fidl::encoding::ValueTypeMarker>::borrow(&self.speed),
941 ),
942 encoder, offset, _depth
943 )
944 }
945 }
946 unsafe impl<
947 D: fidl::encoding::ResourceDialect,
948 T0: fidl::encoding::Encode<bool, D>,
949 T1: fidl::encoding::Encode<fidl_fuchsia_hardware_usb_descriptor_common::UsbSpeed, D>,
950 > fidl::encoding::Encode<UsbFunctionInterfaceSetConfiguredRequest, D> for (T0, T1)
951 {
952 #[inline]
953 unsafe fn encode(
954 self,
955 encoder: &mut fidl::encoding::Encoder<'_, D>,
956 offset: usize,
957 depth: fidl::encoding::Depth,
958 ) -> fidl::Result<()> {
959 encoder.debug_check_bounds::<UsbFunctionInterfaceSetConfiguredRequest>(offset);
960 unsafe {
963 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
964 (ptr as *mut u32).write_unaligned(0);
965 }
966 self.0.encode(encoder, offset + 0, depth)?;
968 self.1.encode(encoder, offset + 4, depth)?;
969 Ok(())
970 }
971 }
972
973 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
974 for UsbFunctionInterfaceSetConfiguredRequest
975 {
976 #[inline(always)]
977 fn new_empty() -> Self {
978 Self {
979 configured: fidl::new_empty!(bool, D),
980 speed: fidl::new_empty!(fidl_fuchsia_hardware_usb_descriptor_common::UsbSpeed, D),
981 }
982 }
983
984 #[inline]
985 unsafe fn decode(
986 &mut self,
987 decoder: &mut fidl::encoding::Decoder<'_, D>,
988 offset: usize,
989 _depth: fidl::encoding::Depth,
990 ) -> fidl::Result<()> {
991 decoder.debug_check_bounds::<Self>(offset);
992 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
994 let padval = unsafe { (ptr as *const u32).read_unaligned() };
995 let mask = 0xffffff00u32;
996 let maskedval = padval & mask;
997 if maskedval != 0 {
998 return Err(fidl::Error::NonZeroPadding {
999 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1000 });
1001 }
1002 fidl::decode!(bool, D, &mut self.configured, decoder, offset + 0, _depth)?;
1003 fidl::decode!(
1004 fidl_fuchsia_hardware_usb_descriptor_common::UsbSpeed,
1005 D,
1006 &mut self.speed,
1007 decoder,
1008 offset + 4,
1009 _depth
1010 )?;
1011 Ok(())
1012 }
1013 }
1014
1015 impl fidl::encoding::ValueTypeMarker for UsbFunctionInterfaceSetInterfaceRequest {
1016 type Borrowed<'a> = &'a Self;
1017 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1018 value
1019 }
1020 }
1021
1022 unsafe impl fidl::encoding::TypeMarker for UsbFunctionInterfaceSetInterfaceRequest {
1023 type Owned = Self;
1024
1025 #[inline(always)]
1026 fn inline_align(_context: fidl::encoding::Context) -> usize {
1027 1
1028 }
1029
1030 #[inline(always)]
1031 fn inline_size(_context: fidl::encoding::Context) -> usize {
1032 2
1033 }
1034 #[inline(always)]
1035 fn encode_is_copy() -> bool {
1036 true
1037 }
1038
1039 #[inline(always)]
1040 fn decode_is_copy() -> bool {
1041 true
1042 }
1043 }
1044
1045 unsafe impl<D: fidl::encoding::ResourceDialect>
1046 fidl::encoding::Encode<UsbFunctionInterfaceSetInterfaceRequest, D>
1047 for &UsbFunctionInterfaceSetInterfaceRequest
1048 {
1049 #[inline]
1050 unsafe fn encode(
1051 self,
1052 encoder: &mut fidl::encoding::Encoder<'_, D>,
1053 offset: usize,
1054 _depth: fidl::encoding::Depth,
1055 ) -> fidl::Result<()> {
1056 encoder.debug_check_bounds::<UsbFunctionInterfaceSetInterfaceRequest>(offset);
1057 unsafe {
1058 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1060 (buf_ptr as *mut UsbFunctionInterfaceSetInterfaceRequest).write_unaligned(
1061 (self as *const UsbFunctionInterfaceSetInterfaceRequest).read(),
1062 );
1063 }
1066 Ok(())
1067 }
1068 }
1069 unsafe impl<
1070 D: fidl::encoding::ResourceDialect,
1071 T0: fidl::encoding::Encode<u8, D>,
1072 T1: fidl::encoding::Encode<u8, D>,
1073 > fidl::encoding::Encode<UsbFunctionInterfaceSetInterfaceRequest, D> for (T0, T1)
1074 {
1075 #[inline]
1076 unsafe fn encode(
1077 self,
1078 encoder: &mut fidl::encoding::Encoder<'_, D>,
1079 offset: usize,
1080 depth: fidl::encoding::Depth,
1081 ) -> fidl::Result<()> {
1082 encoder.debug_check_bounds::<UsbFunctionInterfaceSetInterfaceRequest>(offset);
1083 self.0.encode(encoder, offset + 0, depth)?;
1087 self.1.encode(encoder, offset + 1, depth)?;
1088 Ok(())
1089 }
1090 }
1091
1092 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1093 for UsbFunctionInterfaceSetInterfaceRequest
1094 {
1095 #[inline(always)]
1096 fn new_empty() -> Self {
1097 Self { interface: fidl::new_empty!(u8, D), alt_setting: fidl::new_empty!(u8, D) }
1098 }
1099
1100 #[inline]
1101 unsafe fn decode(
1102 &mut self,
1103 decoder: &mut fidl::encoding::Decoder<'_, D>,
1104 offset: usize,
1105 _depth: fidl::encoding::Depth,
1106 ) -> fidl::Result<()> {
1107 decoder.debug_check_bounds::<Self>(offset);
1108 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1109 unsafe {
1112 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
1113 }
1114 Ok(())
1115 }
1116 }
1117
1118 impl fidl::encoding::ValueTypeMarker for UsbFunctionInterfaceControlResponse {
1119 type Borrowed<'a> = &'a Self;
1120 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1121 value
1122 }
1123 }
1124
1125 unsafe impl fidl::encoding::TypeMarker for UsbFunctionInterfaceControlResponse {
1126 type Owned = Self;
1127
1128 #[inline(always)]
1129 fn inline_align(_context: fidl::encoding::Context) -> usize {
1130 8
1131 }
1132
1133 #[inline(always)]
1134 fn inline_size(_context: fidl::encoding::Context) -> usize {
1135 16
1136 }
1137 }
1138
1139 unsafe impl<D: fidl::encoding::ResourceDialect>
1140 fidl::encoding::Encode<UsbFunctionInterfaceControlResponse, D>
1141 for &UsbFunctionInterfaceControlResponse
1142 {
1143 #[inline]
1144 unsafe fn encode(
1145 self,
1146 encoder: &mut fidl::encoding::Encoder<'_, D>,
1147 offset: usize,
1148 _depth: fidl::encoding::Depth,
1149 ) -> fidl::Result<()> {
1150 encoder.debug_check_bounds::<UsbFunctionInterfaceControlResponse>(offset);
1151 fidl::encoding::Encode::<UsbFunctionInterfaceControlResponse, D>::encode(
1153 (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
1154 &self.read,
1155 ),),
1156 encoder,
1157 offset,
1158 _depth,
1159 )
1160 }
1161 }
1162 unsafe impl<
1163 D: fidl::encoding::ResourceDialect,
1164 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
1165 > fidl::encoding::Encode<UsbFunctionInterfaceControlResponse, D> for (T0,)
1166 {
1167 #[inline]
1168 unsafe fn encode(
1169 self,
1170 encoder: &mut fidl::encoding::Encoder<'_, D>,
1171 offset: usize,
1172 depth: fidl::encoding::Depth,
1173 ) -> fidl::Result<()> {
1174 encoder.debug_check_bounds::<UsbFunctionInterfaceControlResponse>(offset);
1175 self.0.encode(encoder, offset + 0, depth)?;
1179 Ok(())
1180 }
1181 }
1182
1183 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1184 for UsbFunctionInterfaceControlResponse
1185 {
1186 #[inline(always)]
1187 fn new_empty() -> Self {
1188 Self { read: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
1189 }
1190
1191 #[inline]
1192 unsafe fn decode(
1193 &mut self,
1194 decoder: &mut fidl::encoding::Decoder<'_, D>,
1195 offset: usize,
1196 _depth: fidl::encoding::Depth,
1197 ) -> fidl::Result<()> {
1198 decoder.debug_check_bounds::<Self>(offset);
1199 fidl::decode!(
1201 fidl::encoding::UnboundedVector<u8>,
1202 D,
1203 &mut self.read,
1204 decoder,
1205 offset + 0,
1206 _depth
1207 )?;
1208 Ok(())
1209 }
1210 }
1211
1212 impl fidl::encoding::ValueTypeMarker for UsbFunctionAllocResourcesResponse {
1213 type Borrowed<'a> = &'a Self;
1214 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1215 value
1216 }
1217 }
1218
1219 unsafe impl fidl::encoding::TypeMarker for UsbFunctionAllocResourcesResponse {
1220 type Owned = Self;
1221
1222 #[inline(always)]
1223 fn inline_align(_context: fidl::encoding::Context) -> usize {
1224 8
1225 }
1226
1227 #[inline(always)]
1228 fn inline_size(_context: fidl::encoding::Context) -> usize {
1229 48
1230 }
1231 }
1232
1233 unsafe impl<D: fidl::encoding::ResourceDialect>
1234 fidl::encoding::Encode<UsbFunctionAllocResourcesResponse, D>
1235 for &UsbFunctionAllocResourcesResponse
1236 {
1237 #[inline]
1238 unsafe fn encode(
1239 self,
1240 encoder: &mut fidl::encoding::Encoder<'_, D>,
1241 offset: usize,
1242 _depth: fidl::encoding::Depth,
1243 ) -> fidl::Result<()> {
1244 encoder.debug_check_bounds::<UsbFunctionAllocResourcesResponse>(offset);
1245 fidl::encoding::Encode::<UsbFunctionAllocResourcesResponse, D>::encode(
1247 (
1248 <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
1249 &self.interface_nums,
1250 ),
1251 <fidl::encoding::Vector<u8, 255> as fidl::encoding::ValueTypeMarker>::borrow(
1252 &self.endpoint_addrs,
1253 ),
1254 <fidl::encoding::Vector<u8, 255> as fidl::encoding::ValueTypeMarker>::borrow(
1255 &self.string_indices,
1256 ),
1257 ),
1258 encoder,
1259 offset,
1260 _depth,
1261 )
1262 }
1263 }
1264 unsafe impl<
1265 D: fidl::encoding::ResourceDialect,
1266 T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 32>, D>,
1267 T1: fidl::encoding::Encode<fidl::encoding::Vector<u8, 255>, D>,
1268 T2: fidl::encoding::Encode<fidl::encoding::Vector<u8, 255>, D>,
1269 > fidl::encoding::Encode<UsbFunctionAllocResourcesResponse, D> for (T0, T1, T2)
1270 {
1271 #[inline]
1272 unsafe fn encode(
1273 self,
1274 encoder: &mut fidl::encoding::Encoder<'_, D>,
1275 offset: usize,
1276 depth: fidl::encoding::Depth,
1277 ) -> fidl::Result<()> {
1278 encoder.debug_check_bounds::<UsbFunctionAllocResourcesResponse>(offset);
1279 self.0.encode(encoder, offset + 0, depth)?;
1283 self.1.encode(encoder, offset + 16, depth)?;
1284 self.2.encode(encoder, offset + 32, depth)?;
1285 Ok(())
1286 }
1287 }
1288
1289 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1290 for UsbFunctionAllocResourcesResponse
1291 {
1292 #[inline(always)]
1293 fn new_empty() -> Self {
1294 Self {
1295 interface_nums: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D),
1296 endpoint_addrs: fidl::new_empty!(fidl::encoding::Vector<u8, 255>, D),
1297 string_indices: fidl::new_empty!(fidl::encoding::Vector<u8, 255>, D),
1298 }
1299 }
1300
1301 #[inline]
1302 unsafe fn decode(
1303 &mut self,
1304 decoder: &mut fidl::encoding::Decoder<'_, D>,
1305 offset: usize,
1306 _depth: fidl::encoding::Depth,
1307 ) -> fidl::Result<()> {
1308 decoder.debug_check_bounds::<Self>(offset);
1309 fidl::decode!(fidl::encoding::Vector<u8, 32>, D, &mut self.interface_nums, decoder, offset + 0, _depth)?;
1311 fidl::decode!(fidl::encoding::Vector<u8, 255>, D, &mut self.endpoint_addrs, decoder, offset + 16, _depth)?;
1312 fidl::decode!(fidl::encoding::Vector<u8, 255>, D, &mut self.string_indices, decoder, offset + 32, _depth)?;
1313 Ok(())
1314 }
1315 }
1316
1317 impl EndpointConfiguration {
1318 #[inline(always)]
1319 fn max_ordinal_present(&self) -> u64 {
1320 if let Some(_) = self.super_speed_companion {
1321 return 2;
1322 }
1323 if let Some(_) = self.descriptor {
1324 return 1;
1325 }
1326 0
1327 }
1328 }
1329
1330 impl fidl::encoding::ValueTypeMarker for EndpointConfiguration {
1331 type Borrowed<'a> = &'a Self;
1332 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1333 value
1334 }
1335 }
1336
1337 unsafe impl fidl::encoding::TypeMarker for EndpointConfiguration {
1338 type Owned = Self;
1339
1340 #[inline(always)]
1341 fn inline_align(_context: fidl::encoding::Context) -> usize {
1342 8
1343 }
1344
1345 #[inline(always)]
1346 fn inline_size(_context: fidl::encoding::Context) -> usize {
1347 16
1348 }
1349 }
1350
1351 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EndpointConfiguration, D>
1352 for &EndpointConfiguration
1353 {
1354 unsafe fn encode(
1355 self,
1356 encoder: &mut fidl::encoding::Encoder<'_, D>,
1357 offset: usize,
1358 mut depth: fidl::encoding::Depth,
1359 ) -> fidl::Result<()> {
1360 encoder.debug_check_bounds::<EndpointConfiguration>(offset);
1361 let max_ordinal: u64 = self.max_ordinal_present();
1363 encoder.write_num(max_ordinal, offset);
1364 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1365 if max_ordinal == 0 {
1367 return Ok(());
1368 }
1369 depth.increment()?;
1370 let envelope_size = 8;
1371 let bytes_len = max_ordinal as usize * envelope_size;
1372 #[allow(unused_variables)]
1373 let offset = encoder.out_of_line_offset(bytes_len);
1374 let mut _prev_end_offset: usize = 0;
1375 if 1 > max_ordinal {
1376 return Ok(());
1377 }
1378
1379 let cur_offset: usize = (1 - 1) * envelope_size;
1382
1383 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1385
1386 fidl::encoding::encode_in_envelope_optional::<EndpointDescriptor, D>(
1391 self.descriptor
1392 .as_ref()
1393 .map(<EndpointDescriptor as fidl::encoding::ValueTypeMarker>::borrow),
1394 encoder,
1395 offset + cur_offset,
1396 depth,
1397 )?;
1398
1399 _prev_end_offset = cur_offset + envelope_size;
1400 if 2 > max_ordinal {
1401 return Ok(());
1402 }
1403
1404 let cur_offset: usize = (2 - 1) * envelope_size;
1407
1408 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1410
1411 fidl::encoding::encode_in_envelope_optional::<SuperSpeedEndpointCompanionDescriptor, D>(
1416 self.super_speed_companion.as_ref().map(<SuperSpeedEndpointCompanionDescriptor as fidl::encoding::ValueTypeMarker>::borrow),
1417 encoder, offset + cur_offset, depth
1418 )?;
1419
1420 _prev_end_offset = cur_offset + envelope_size;
1421
1422 Ok(())
1423 }
1424 }
1425
1426 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EndpointConfiguration {
1427 #[inline(always)]
1428 fn new_empty() -> Self {
1429 Self::default()
1430 }
1431
1432 unsafe fn decode(
1433 &mut self,
1434 decoder: &mut fidl::encoding::Decoder<'_, D>,
1435 offset: usize,
1436 mut depth: fidl::encoding::Depth,
1437 ) -> fidl::Result<()> {
1438 decoder.debug_check_bounds::<Self>(offset);
1439 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1440 None => return Err(fidl::Error::NotNullable),
1441 Some(len) => len,
1442 };
1443 if len == 0 {
1445 return Ok(());
1446 };
1447 depth.increment()?;
1448 let envelope_size = 8;
1449 let bytes_len = len * envelope_size;
1450 let offset = decoder.out_of_line_offset(bytes_len)?;
1451 let mut _next_ordinal_to_read = 0;
1453 let mut next_offset = offset;
1454 let end_offset = offset + bytes_len;
1455 _next_ordinal_to_read += 1;
1456 if next_offset >= end_offset {
1457 return Ok(());
1458 }
1459
1460 while _next_ordinal_to_read < 1 {
1462 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1463 _next_ordinal_to_read += 1;
1464 next_offset += envelope_size;
1465 }
1466
1467 let next_out_of_line = decoder.next_out_of_line();
1468 let handles_before = decoder.remaining_handles();
1469 if let Some((inlined, num_bytes, num_handles)) =
1470 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1471 {
1472 let member_inline_size =
1473 <EndpointDescriptor as fidl::encoding::TypeMarker>::inline_size(
1474 decoder.context,
1475 );
1476 if inlined != (member_inline_size <= 4) {
1477 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1478 }
1479 let inner_offset;
1480 let mut inner_depth = depth.clone();
1481 if inlined {
1482 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1483 inner_offset = next_offset;
1484 } else {
1485 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1486 inner_depth.increment()?;
1487 }
1488 let val_ref =
1489 self.descriptor.get_or_insert_with(|| fidl::new_empty!(EndpointDescriptor, D));
1490 fidl::decode!(EndpointDescriptor, D, val_ref, decoder, inner_offset, inner_depth)?;
1491 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1492 {
1493 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1494 }
1495 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1496 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1497 }
1498 }
1499
1500 next_offset += envelope_size;
1501 _next_ordinal_to_read += 1;
1502 if next_offset >= end_offset {
1503 return Ok(());
1504 }
1505
1506 while _next_ordinal_to_read < 2 {
1508 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1509 _next_ordinal_to_read += 1;
1510 next_offset += envelope_size;
1511 }
1512
1513 let next_out_of_line = decoder.next_out_of_line();
1514 let handles_before = decoder.remaining_handles();
1515 if let Some((inlined, num_bytes, num_handles)) =
1516 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1517 {
1518 let member_inline_size = <SuperSpeedEndpointCompanionDescriptor as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1519 if inlined != (member_inline_size <= 4) {
1520 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1521 }
1522 let inner_offset;
1523 let mut inner_depth = depth.clone();
1524 if inlined {
1525 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1526 inner_offset = next_offset;
1527 } else {
1528 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1529 inner_depth.increment()?;
1530 }
1531 let val_ref = self.super_speed_companion.get_or_insert_with(|| {
1532 fidl::new_empty!(SuperSpeedEndpointCompanionDescriptor, D)
1533 });
1534 fidl::decode!(
1535 SuperSpeedEndpointCompanionDescriptor,
1536 D,
1537 val_ref,
1538 decoder,
1539 inner_offset,
1540 inner_depth
1541 )?;
1542 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1543 {
1544 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1545 }
1546 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1547 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1548 }
1549 }
1550
1551 next_offset += envelope_size;
1552
1553 while next_offset < end_offset {
1555 _next_ordinal_to_read += 1;
1556 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1557 next_offset += envelope_size;
1558 }
1559
1560 Ok(())
1561 }
1562 }
1563}