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