1#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5#[doc = " Clients should be aware of the max channel message size when using large transfers or many\n transactions. It is possible to generate a message that uses values less than the limits below\n but is still too big for the channel.\n\n The maximum number of bytes that can be read or written in a single `Transaction`.\n"]
6pub const MAX_TRANSFER_SIZE: u32 = 32768;
7
8#[doc = " If `read_size` is set: This is a read transfer, and `read_size` bytes will be read from the\n target.\n If `write_data` is set: This is a write transfer, and `write_data` will be written to the\n target.\n"]
9#[derive(Clone, Debug)]
10pub enum DataTransfer {
11 ReadSize(u32),
12
13 WriteData(Vec<u8>),
14
15 UnknownOrdinal_(u64),
16}
17
18impl ::fidl_next::Encodable for DataTransfer {
19 type Encoded = WireDataTransfer<'static>;
20}
21
22unsafe impl<___E> ::fidl_next::Encode<___E> for DataTransfer
23where
24 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
25 ___E: ::fidl_next::Encoder,
26{
27 #[inline]
28 fn encode(
29 self,
30 encoder: &mut ___E,
31 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
32 ) -> Result<(), ::fidl_next::EncodeError> {
33 ::fidl_next::munge!(let WireDataTransfer { raw, _phantom: _ } = out);
34
35 match self {
36 Self::ReadSize(value) => {
37 ::fidl_next::RawWireUnion::encode_as::<___E, u32>(value, 1, encoder, raw)?
38 }
39
40 Self::WriteData(value) => {
41 ::fidl_next::RawWireUnion::encode_as::<___E, Vec<u8>>(value, 2, encoder, raw)?
42 }
43
44 Self::UnknownOrdinal_(ordinal) => {
45 return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(ordinal as usize));
46 }
47 }
48
49 Ok(())
50 }
51}
52
53unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DataTransfer
54where
55 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
56 ___E: ::fidl_next::Encoder,
57{
58 #[inline]
59 fn encode_ref(
60 &self,
61 encoder: &mut ___E,
62 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
63 ) -> Result<(), ::fidl_next::EncodeError> {
64 ::fidl_next::munge!(let WireDataTransfer { raw, _phantom: _ } = out);
65
66 match self {
67 Self::ReadSize(value) => {
68 ::fidl_next::RawWireUnion::encode_as::<___E, &u32>(value, 1, encoder, raw)?
69 }
70
71 Self::WriteData(value) => {
72 ::fidl_next::RawWireUnion::encode_as::<___E, &Vec<u8>>(value, 2, encoder, raw)?
73 }
74
75 Self::UnknownOrdinal_(ordinal) => {
76 return Err(::fidl_next::EncodeError::UnknownUnionOrdinal(*ordinal as usize));
77 }
78 }
79
80 Ok(())
81 }
82}
83
84impl ::fidl_next::EncodableOption for DataTransfer {
85 type EncodedOption = WireOptionalDataTransfer<'static>;
86}
87
88unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DataTransfer
89where
90 ___E: ?Sized,
91 DataTransfer: ::fidl_next::Encode<___E>,
92{
93 #[inline]
94 fn encode_option(
95 this: Option<Self>,
96 encoder: &mut ___E,
97 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
98 ) -> Result<(), ::fidl_next::EncodeError> {
99 ::fidl_next::munge!(let WireOptionalDataTransfer { raw, _phantom: _ } = &mut *out);
100
101 if let Some(inner) = this {
102 let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
103 ::fidl_next::Encode::encode(inner, encoder, value_out)?;
104 } else {
105 ::fidl_next::RawWireUnion::encode_absent(raw);
106 }
107
108 Ok(())
109 }
110}
111
112unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DataTransfer
113where
114 ___E: ?Sized,
115 DataTransfer: ::fidl_next::EncodeRef<___E>,
116{
117 #[inline]
118 fn encode_option_ref(
119 this: Option<&Self>,
120 encoder: &mut ___E,
121 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
122 ) -> Result<(), ::fidl_next::EncodeError> {
123 ::fidl_next::munge!(let WireOptionalDataTransfer { raw, _phantom: _ } = &mut *out);
124
125 if let Some(inner) = this {
126 let value_out = unsafe { &mut *out.as_mut_ptr().cast() };
127 ::fidl_next::EncodeRef::encode_ref(inner, encoder, value_out)?;
128 } else {
129 ::fidl_next::RawWireUnion::encode_absent(raw);
130 }
131
132 Ok(())
133 }
134}
135
136impl<'de> ::fidl_next::FromWire<WireDataTransfer<'de>> for DataTransfer {
137 #[inline]
138 fn from_wire(wire: WireDataTransfer<'de>) -> Self {
139 let wire = ::core::mem::ManuallyDrop::new(wire);
140 match wire.raw.ordinal() {
141 1 => Self::ReadSize(::fidl_next::FromWire::from_wire(unsafe {
142 wire.raw.get().read_unchecked::<::fidl_next::WireU32>()
143 })),
144
145 2 => Self::WriteData(::fidl_next::FromWire::from_wire(unsafe {
146 wire.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>()
147 })),
148
149 _ => unsafe { ::core::hint::unreachable_unchecked() },
150 }
151 }
152}
153
154impl<'de> ::fidl_next::FromWireRef<WireDataTransfer<'de>> for DataTransfer {
155 #[inline]
156 fn from_wire_ref(wire: &WireDataTransfer<'de>) -> Self {
157 match wire.raw.ordinal() {
158 1 => Self::ReadSize(::fidl_next::FromWireRef::from_wire_ref(unsafe {
159 wire.raw.get().deref_unchecked::<::fidl_next::WireU32>()
160 })),
161
162 2 => Self::WriteData(::fidl_next::FromWireRef::from_wire_ref(unsafe {
163 wire.raw.get().deref_unchecked::<::fidl_next::WireVector<'de, u8>>()
164 })),
165
166 _ => unsafe { ::core::hint::unreachable_unchecked() },
167 }
168 }
169}
170
171impl<'de> ::fidl_next::FromWireOption<WireOptionalDataTransfer<'de>> for Box<DataTransfer> {
172 #[inline]
173 fn from_wire_option(wire: WireOptionalDataTransfer<'de>) -> Option<Self> {
174 if let Some(inner) = wire.into_option() {
175 Some(Box::new(::fidl_next::FromWire::from_wire(inner)))
176 } else {
177 None
178 }
179 }
180}
181
182impl<'de> ::fidl_next::FromWireOptionRef<WireOptionalDataTransfer<'de>> for Box<DataTransfer> {
183 #[inline]
184 fn from_wire_option_ref(wire: &WireOptionalDataTransfer<'de>) -> Option<Self> {
185 if let Some(inner) = wire.as_ref() {
186 Some(Box::new(::fidl_next::FromWireRef::from_wire_ref(inner)))
187 } else {
188 None
189 }
190 }
191}
192
193#[repr(transparent)]
195pub struct WireDataTransfer<'de> {
196 raw: ::fidl_next::RawWireUnion,
197 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
198}
199
200impl<'de> Drop for WireDataTransfer<'de> {
201 fn drop(&mut self) {
202 match self.raw.ordinal() {
203 1 => {
204 let _ = unsafe { self.raw.get().read_unchecked::<::fidl_next::WireU32>() };
205 }
206
207 2 => {
208 let _ =
209 unsafe { self.raw.get().read_unchecked::<::fidl_next::WireVector<'de, u8>>() };
210 }
211
212 _ => (),
213 }
214 }
215}
216
217unsafe impl ::fidl_next::Wire for WireDataTransfer<'static> {
218 type Decoded<'de> = WireDataTransfer<'de>;
219
220 #[inline]
221 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
222 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
223 ::fidl_next::RawWireUnion::zero_padding(raw);
224 }
225}
226
227pub mod data_transfer {
228 pub enum Ref<'de> {
229 ReadSize(&'de ::fidl_next::WireU32),
230
231 WriteData(&'de ::fidl_next::WireVector<'de, u8>),
232
233 UnknownOrdinal_(u64),
234 }
235}
236
237impl<'de> WireDataTransfer<'de> {
238 pub fn as_ref(&self) -> crate::data_transfer::Ref<'_> {
239 match self.raw.ordinal() {
240 1 => crate::data_transfer::Ref::ReadSize(unsafe {
241 self.raw.get().deref_unchecked::<::fidl_next::WireU32>()
242 }),
243
244 2 => crate::data_transfer::Ref::WriteData(unsafe {
245 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>()
246 }),
247
248 unknown => crate::data_transfer::Ref::UnknownOrdinal_(unknown),
249 }
250 }
251}
252
253unsafe impl<___D> ::fidl_next::Decode<___D> for WireDataTransfer<'static>
254where
255 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
256 ___D: ::fidl_next::Decoder,
257{
258 fn decode(
259 mut slot: ::fidl_next::Slot<'_, Self>,
260 decoder: &mut ___D,
261 ) -> Result<(), ::fidl_next::DecodeError> {
262 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
263 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
264 1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireU32>(raw, decoder)?,
265
266 2 => {
267 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
268 raw, decoder,
269 )?
270 }
271
272 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
273 }
274
275 Ok(())
276 }
277}
278
279impl<'de> ::core::fmt::Debug for WireDataTransfer<'de> {
280 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
281 match self.raw.ordinal() {
282 1 => unsafe { self.raw.get().deref_unchecked::<::fidl_next::WireU32>().fmt(f) },
283 2 => unsafe {
284 self.raw.get().deref_unchecked::<::fidl_next::WireVector<'_, u8>>().fmt(f)
285 },
286 _ => unsafe { ::core::hint::unreachable_unchecked() },
287 }
288 }
289}
290
291#[repr(transparent)]
292pub struct WireOptionalDataTransfer<'de> {
293 raw: ::fidl_next::RawWireUnion,
294 _phantom: ::core::marker::PhantomData<&'de mut [::fidl_next::Chunk]>,
295}
296
297unsafe impl ::fidl_next::Wire for WireOptionalDataTransfer<'static> {
298 type Decoded<'de> = WireOptionalDataTransfer<'de>;
299
300 #[inline]
301 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
302 ::fidl_next::munge!(let Self { raw, _phantom: _ } = out);
303 ::fidl_next::RawWireUnion::zero_padding(raw);
304 }
305}
306
307impl<'de> WireOptionalDataTransfer<'de> {
308 pub fn is_some(&self) -> bool {
309 self.raw.is_some()
310 }
311
312 pub fn is_none(&self) -> bool {
313 self.raw.is_none()
314 }
315
316 pub fn as_ref(&self) -> Option<&WireDataTransfer<'de>> {
317 if self.is_some() { Some(unsafe { &*(self as *const Self).cast() }) } else { None }
318 }
319
320 pub fn into_option(self) -> Option<WireDataTransfer<'de>> {
321 if self.is_some() {
322 Some(WireDataTransfer { raw: self.raw, _phantom: ::core::marker::PhantomData })
323 } else {
324 None
325 }
326 }
327}
328
329unsafe impl<___D> ::fidl_next::Decode<___D> for WireOptionalDataTransfer<'static>
330where
331 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
332 ___D: ::fidl_next::Decoder,
333{
334 fn decode(
335 mut slot: ::fidl_next::Slot<'_, Self>,
336 decoder: &mut ___D,
337 ) -> Result<(), ::fidl_next::DecodeError> {
338 ::fidl_next::munge!(let Self { mut raw, _phantom: _ } = slot.as_mut());
339 match ::fidl_next::RawWireUnion::encoded_ordinal(raw.as_mut()) {
340 1 => ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireU32>(raw, decoder)?,
341
342 2 => {
343 ::fidl_next::RawWireUnion::decode_as::<___D, ::fidl_next::WireVector<'static, u8>>(
344 raw, decoder,
345 )?
346 }
347
348 0 => ::fidl_next::RawWireUnion::decode_absent(raw)?,
349 _ => ::fidl_next::RawWireUnion::decode_unknown(raw, decoder)?,
350 }
351
352 Ok(())
353 }
354}
355
356impl<'de> ::core::fmt::Debug for WireOptionalDataTransfer<'de> {
357 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
358 self.as_ref().fmt(f)
359 }
360}
361
362#[doc = " `data_transfer` is mandatory, and specifies whether this transaction has a read or a write\n transfer (see above).\n `stop` is optional, and specifies whether this transaction is terminated by a stop condition (if\n true) or by a repeated-start (if false or unspecified). If this transaction is the last in the\n list then a stop condition is generated regardless of the value of `stop`.\n"]
363#[derive(Clone, Debug, Default)]
364pub struct Transaction {
365 pub data_transfer: Option<crate::DataTransfer>,
366
367 pub stop: Option<bool>,
368}
369
370impl Transaction {
371 fn __max_ordinal(&self) -> usize {
372 if self.stop.is_some() {
373 return 2;
374 }
375
376 if self.data_transfer.is_some() {
377 return 1;
378 }
379
380 0
381 }
382}
383
384impl ::fidl_next::Encodable for Transaction {
385 type Encoded = WireTransaction<'static>;
386}
387
388unsafe impl<___E> ::fidl_next::Encode<___E> for Transaction
389where
390 ___E: ::fidl_next::Encoder + ?Sized,
391{
392 #[inline]
393 fn encode(
394 mut self,
395 encoder: &mut ___E,
396 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
397 ) -> Result<(), ::fidl_next::EncodeError> {
398 ::fidl_next::munge!(let WireTransaction { table } = out);
399
400 let max_ord = self.__max_ordinal();
401
402 let mut out = ::core::mem::MaybeUninit::<::fidl_next::WireEnvelope>::uninit();
403 ::fidl_next::Wire::zero_padding(&mut out);
404
405 let mut preallocated =
406 ::fidl_next::EncoderExt::preallocate::<::fidl_next::WireEnvelope>(encoder, max_ord);
407
408 for i in 1..=max_ord {
409 match i {
410 2 => {
411 if let Some(stop) = self.stop.take() {
412 ::fidl_next::WireEnvelope::encode_value(
413 stop,
414 preallocated.encoder,
415 &mut out,
416 )?;
417 } else {
418 ::fidl_next::WireEnvelope::encode_zero(&mut out)
419 }
420 }
421
422 1 => {
423 if let Some(data_transfer) = self.data_transfer.take() {
424 ::fidl_next::WireEnvelope::encode_value(
425 data_transfer,
426 preallocated.encoder,
427 &mut out,
428 )?;
429 } else {
430 ::fidl_next::WireEnvelope::encode_zero(&mut out)
431 }
432 }
433
434 _ => ::fidl_next::WireEnvelope::encode_zero(&mut out),
435 }
436 unsafe {
437 preallocated.write_next(out.assume_init_ref());
438 }
439 }
440
441 ::fidl_next::WireTable::encode_len(table, max_ord);
442
443 Ok(())
444 }
445}
446
447unsafe impl<___E> ::fidl_next::EncodeRef<___E> for Transaction
448where
449 ___E: ::fidl_next::Encoder + ?Sized,
450{
451 #[inline]
452 fn encode_ref(
453 &self,
454 encoder: &mut ___E,
455 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
456 ) -> Result<(), ::fidl_next::EncodeError> {
457 ::fidl_next::munge!(let WireTransaction { table } = out);
458
459 let max_ord = self.__max_ordinal();
460
461 let mut out = ::core::mem::MaybeUninit::<::fidl_next::WireEnvelope>::uninit();
462 ::fidl_next::Wire::zero_padding(&mut out);
463
464 let mut preallocated =
465 ::fidl_next::EncoderExt::preallocate::<::fidl_next::WireEnvelope>(encoder, max_ord);
466
467 for i in 1..=max_ord {
468 match i {
469 2 => {
470 if let Some(stop) = &self.stop {
471 ::fidl_next::WireEnvelope::encode_value(
472 stop,
473 preallocated.encoder,
474 &mut out,
475 )?;
476 } else {
477 ::fidl_next::WireEnvelope::encode_zero(&mut out)
478 }
479 }
480
481 1 => {
482 if let Some(data_transfer) = &self.data_transfer {
483 ::fidl_next::WireEnvelope::encode_value(
484 data_transfer,
485 preallocated.encoder,
486 &mut out,
487 )?;
488 } else {
489 ::fidl_next::WireEnvelope::encode_zero(&mut out)
490 }
491 }
492
493 _ => ::fidl_next::WireEnvelope::encode_zero(&mut out),
494 }
495 unsafe {
496 preallocated.write_next(out.assume_init_ref());
497 }
498 }
499
500 ::fidl_next::WireTable::encode_len(table, max_ord);
501
502 Ok(())
503 }
504}
505
506impl<'de> ::fidl_next::FromWire<WireTransaction<'de>> for Transaction {
507 #[inline]
508 fn from_wire(wire: WireTransaction<'de>) -> Self {
509 let wire = ::core::mem::ManuallyDrop::new(wire);
510
511 let data_transfer = wire.table.get(1);
512
513 let stop = wire.table.get(2);
514
515 Self {
516 data_transfer: data_transfer.map(|envelope| {
517 ::fidl_next::FromWire::from_wire(unsafe {
518 envelope.read_unchecked::<crate::WireDataTransfer<'de>>()
519 })
520 }),
521
522 stop: stop.map(|envelope| {
523 ::fidl_next::FromWire::from_wire(unsafe { envelope.read_unchecked::<bool>() })
524 }),
525 }
526 }
527}
528
529impl<'de> ::fidl_next::FromWireRef<WireTransaction<'de>> for Transaction {
530 #[inline]
531 fn from_wire_ref(wire: &WireTransaction<'de>) -> Self {
532 Self {
533 data_transfer: wire.table.get(1).map(|envelope| {
534 ::fidl_next::FromWireRef::from_wire_ref(unsafe {
535 envelope.deref_unchecked::<crate::WireDataTransfer<'de>>()
536 })
537 }),
538
539 stop: wire.table.get(2).map(|envelope| {
540 ::fidl_next::FromWireRef::from_wire_ref(unsafe {
541 envelope.deref_unchecked::<bool>()
542 })
543 }),
544 }
545 }
546}
547
548#[repr(C)]
550pub struct WireTransaction<'de> {
551 table: ::fidl_next::WireTable<'de>,
552}
553
554impl<'de> Drop for WireTransaction<'de> {
555 fn drop(&mut self) {
556 let _ = self
557 .table
558 .get(1)
559 .map(|envelope| unsafe { envelope.read_unchecked::<crate::WireDataTransfer<'de>>() });
560
561 let _ = self.table.get(2).map(|envelope| unsafe { envelope.read_unchecked::<bool>() });
562 }
563}
564
565unsafe impl ::fidl_next::Wire for WireTransaction<'static> {
566 type Decoded<'de> = WireTransaction<'de>;
567
568 #[inline]
569 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {
570 ::fidl_next::munge!(let Self { table } = out);
571 ::fidl_next::WireTable::zero_padding(table);
572 }
573}
574
575unsafe impl<___D> ::fidl_next::Decode<___D> for WireTransaction<'static>
576where
577 ___D: ::fidl_next::Decoder + ?Sized,
578{
579 fn decode(
580 slot: ::fidl_next::Slot<'_, Self>,
581 decoder: &mut ___D,
582 ) -> Result<(), ::fidl_next::DecodeError> {
583 ::fidl_next::munge!(let Self { table } = slot);
584
585 ::fidl_next::WireTable::decode_with(table, decoder, |ordinal, mut slot, decoder| {
586 match ordinal {
587 0 => unsafe { ::core::hint::unreachable_unchecked() },
588
589 1 => {
590 ::fidl_next::WireEnvelope::decode_as::<___D, crate::WireDataTransfer<'static>>(
591 slot.as_mut(),
592 decoder,
593 )?;
594
595 Ok(())
596 }
597
598 2 => {
599 ::fidl_next::WireEnvelope::decode_as::<___D, bool>(slot.as_mut(), decoder)?;
600
601 Ok(())
602 }
603
604 _ => ::fidl_next::WireEnvelope::decode_unknown(slot, decoder),
605 }
606 })
607 }
608}
609
610impl<'de> WireTransaction<'de> {
611 pub fn data_transfer(&self) -> Option<&crate::WireDataTransfer<'de>> {
612 unsafe { Some(self.table.get(1)?.deref_unchecked()) }
613 }
614
615 pub fn stop(&self) -> Option<&bool> {
616 unsafe { Some(self.table.get(2)?.deref_unchecked()) }
617 }
618}
619
620impl<'de> ::core::fmt::Debug for WireTransaction<'de> {
621 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> Result<(), ::core::fmt::Error> {
622 f.debug_struct("Transaction")
623 .field("data_transfer", &self.data_transfer())
624 .field("stop", &self.stop())
625 .finish()
626 }
627}
628
629#[doc = " The maximum number of transactions that can be specified in a call to `Transfer`.\n"]
630pub const MAX_COUNT_TRANSACTIONS: u32 = 256;
631
632#[derive(Clone, Debug)]
633pub struct DeviceTransferRequest {
634 pub transactions: Vec<crate::Transaction>,
635}
636
637impl ::fidl_next::Encodable for DeviceTransferRequest {
638 type Encoded = WireDeviceTransferRequest<'static>;
639}
640
641unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceTransferRequest
642where
643 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
644 ___E: ::fidl_next::Encoder,
645{
646 #[inline]
647 fn encode(
648 self,
649 encoder: &mut ___E,
650 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
651 ) -> Result<(), ::fidl_next::EncodeError> {
652 ::fidl_next::munge! {
653 let Self::Encoded {
654 transactions,
655
656 } = out;
657 }
658
659 ::fidl_next::Encode::encode(self.transactions, encoder, transactions)?;
660
661 Ok(())
662 }
663}
664
665unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DeviceTransferRequest
666where
667 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
668 ___E: ::fidl_next::Encoder,
669{
670 #[inline]
671 fn encode_ref(
672 &self,
673 encoder: &mut ___E,
674 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
675 ) -> Result<(), ::fidl_next::EncodeError> {
676 ::fidl_next::munge! {
677 let Self::Encoded {
678 transactions,
679
680 } = out;
681 }
682
683 ::fidl_next::EncodeRef::encode_ref(&self.transactions, encoder, transactions)?;
684
685 Ok(())
686 }
687}
688
689impl ::fidl_next::EncodableOption for DeviceTransferRequest {
690 type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceTransferRequest<'static>>;
691}
692
693unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceTransferRequest
694where
695 ___E: ::fidl_next::Encoder + ?Sized,
696 DeviceTransferRequest: ::fidl_next::Encode<___E>,
697{
698 #[inline]
699 fn encode_option(
700 this: Option<Self>,
701 encoder: &mut ___E,
702 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
703 ) -> Result<(), ::fidl_next::EncodeError> {
704 if let Some(inner) = this {
705 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
706 ::fidl_next::WireBox::encode_present(out);
707 } else {
708 ::fidl_next::WireBox::encode_absent(out);
709 }
710
711 Ok(())
712 }
713}
714
715unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DeviceTransferRequest
716where
717 ___E: ::fidl_next::Encoder + ?Sized,
718 DeviceTransferRequest: ::fidl_next::EncodeRef<___E>,
719{
720 #[inline]
721 fn encode_option_ref(
722 this: Option<&Self>,
723 encoder: &mut ___E,
724 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
725 ) -> Result<(), ::fidl_next::EncodeError> {
726 if let Some(inner) = this {
727 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
728 ::fidl_next::WireBox::encode_present(out);
729 } else {
730 ::fidl_next::WireBox::encode_absent(out);
731 }
732
733 Ok(())
734 }
735}
736
737impl<'de> ::fidl_next::FromWire<WireDeviceTransferRequest<'de>> for DeviceTransferRequest {
738 #[inline]
739 fn from_wire(wire: WireDeviceTransferRequest<'de>) -> Self {
740 Self { transactions: ::fidl_next::FromWire::from_wire(wire.transactions) }
741 }
742}
743
744impl<'de> ::fidl_next::FromWireRef<WireDeviceTransferRequest<'de>> for DeviceTransferRequest {
745 #[inline]
746 fn from_wire_ref(wire: &WireDeviceTransferRequest<'de>) -> Self {
747 Self { transactions: ::fidl_next::FromWireRef::from_wire_ref(&wire.transactions) }
748 }
749}
750
751#[derive(Debug)]
753#[repr(C)]
754pub struct WireDeviceTransferRequest<'de> {
755 pub transactions: ::fidl_next::WireVector<'de, crate::WireTransaction<'de>>,
756}
757
758unsafe impl ::fidl_next::Wire for WireDeviceTransferRequest<'static> {
759 type Decoded<'de> = WireDeviceTransferRequest<'de>;
760
761 #[inline]
762 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
763}
764
765unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceTransferRequest<'static>
766where
767 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
768 ___D: ::fidl_next::Decoder,
769{
770 fn decode(
771 slot: ::fidl_next::Slot<'_, Self>,
772 decoder: &mut ___D,
773 ) -> Result<(), ::fidl_next::DecodeError> {
774 ::fidl_next::munge! {
775 let Self {
776 mut transactions,
777
778 } = slot;
779 }
780
781 ::fidl_next::Decode::decode(transactions.as_mut(), decoder)?;
782
783 let transactions = unsafe { transactions.deref_unchecked() };
784
785 if transactions.len() > 256 {
786 return Err(::fidl_next::DecodeError::VectorTooLong {
787 size: transactions.len() as u64,
788 limit: 256,
789 });
790 }
791
792 Ok(())
793 }
794}
795
796#[doc = " Used to return data from read transfers.\n"]
797pub type ReadData = Vec<u8>;
798
799pub type WireReadData<'de> = ::fidl_next::WireVector<'de, u8>;
801
802#[derive(Clone, Debug)]
803pub struct DeviceTransferResponse {
804 pub read_data: Vec<Vec<u8>>,
805}
806
807impl ::fidl_next::Encodable for DeviceTransferResponse {
808 type Encoded = WireDeviceTransferResponse<'static>;
809}
810
811unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceTransferResponse
812where
813 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
814 ___E: ::fidl_next::Encoder,
815{
816 #[inline]
817 fn encode(
818 self,
819 encoder: &mut ___E,
820 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
821 ) -> Result<(), ::fidl_next::EncodeError> {
822 ::fidl_next::munge! {
823 let Self::Encoded {
824 read_data,
825
826 } = out;
827 }
828
829 ::fidl_next::Encode::encode(self.read_data, encoder, read_data)?;
830
831 Ok(())
832 }
833}
834
835unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DeviceTransferResponse
836where
837 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
838 ___E: ::fidl_next::Encoder,
839{
840 #[inline]
841 fn encode_ref(
842 &self,
843 encoder: &mut ___E,
844 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
845 ) -> Result<(), ::fidl_next::EncodeError> {
846 ::fidl_next::munge! {
847 let Self::Encoded {
848 read_data,
849
850 } = out;
851 }
852
853 ::fidl_next::EncodeRef::encode_ref(&self.read_data, encoder, read_data)?;
854
855 Ok(())
856 }
857}
858
859impl ::fidl_next::EncodableOption for DeviceTransferResponse {
860 type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceTransferResponse<'static>>;
861}
862
863unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceTransferResponse
864where
865 ___E: ::fidl_next::Encoder + ?Sized,
866 DeviceTransferResponse: ::fidl_next::Encode<___E>,
867{
868 #[inline]
869 fn encode_option(
870 this: Option<Self>,
871 encoder: &mut ___E,
872 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
873 ) -> Result<(), ::fidl_next::EncodeError> {
874 if let Some(inner) = this {
875 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
876 ::fidl_next::WireBox::encode_present(out);
877 } else {
878 ::fidl_next::WireBox::encode_absent(out);
879 }
880
881 Ok(())
882 }
883}
884
885unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DeviceTransferResponse
886where
887 ___E: ::fidl_next::Encoder + ?Sized,
888 DeviceTransferResponse: ::fidl_next::EncodeRef<___E>,
889{
890 #[inline]
891 fn encode_option_ref(
892 this: Option<&Self>,
893 encoder: &mut ___E,
894 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
895 ) -> Result<(), ::fidl_next::EncodeError> {
896 if let Some(inner) = this {
897 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
898 ::fidl_next::WireBox::encode_present(out);
899 } else {
900 ::fidl_next::WireBox::encode_absent(out);
901 }
902
903 Ok(())
904 }
905}
906
907impl<'de> ::fidl_next::FromWire<WireDeviceTransferResponse<'de>> for DeviceTransferResponse {
908 #[inline]
909 fn from_wire(wire: WireDeviceTransferResponse<'de>) -> Self {
910 Self { read_data: ::fidl_next::FromWire::from_wire(wire.read_data) }
911 }
912}
913
914impl<'de> ::fidl_next::FromWireRef<WireDeviceTransferResponse<'de>> for DeviceTransferResponse {
915 #[inline]
916 fn from_wire_ref(wire: &WireDeviceTransferResponse<'de>) -> Self {
917 Self { read_data: ::fidl_next::FromWireRef::from_wire_ref(&wire.read_data) }
918 }
919}
920
921#[derive(Debug)]
923#[repr(C)]
924pub struct WireDeviceTransferResponse<'de> {
925 pub read_data: ::fidl_next::WireVector<'de, ::fidl_next::WireVector<'de, u8>>,
926}
927
928unsafe impl ::fidl_next::Wire for WireDeviceTransferResponse<'static> {
929 type Decoded<'de> = WireDeviceTransferResponse<'de>;
930
931 #[inline]
932 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
933}
934
935unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceTransferResponse<'static>
936where
937 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
938 ___D: ::fidl_next::Decoder,
939{
940 fn decode(
941 slot: ::fidl_next::Slot<'_, Self>,
942 decoder: &mut ___D,
943 ) -> Result<(), ::fidl_next::DecodeError> {
944 ::fidl_next::munge! {
945 let Self {
946 mut read_data,
947
948 } = slot;
949 }
950
951 ::fidl_next::Decode::decode(read_data.as_mut(), decoder)?;
952
953 let read_data = unsafe { read_data.deref_unchecked() };
954
955 if read_data.len() > 256 {
956 return Err(::fidl_next::DecodeError::VectorTooLong {
957 size: read_data.len() as u64,
958 limit: 256,
959 });
960 }
961
962 Ok(())
963 }
964}
965
966#[doc = " Maximum length of the I2C Channel name.\n"]
967pub const MAX_I2_C_NAME_LEN: u32 = 64;
968
969#[derive(Clone, Debug)]
970pub struct DeviceGetNameResponse {
971 pub name: String,
972}
973
974impl ::fidl_next::Encodable for DeviceGetNameResponse {
975 type Encoded = WireDeviceGetNameResponse<'static>;
976}
977
978unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetNameResponse
979where
980 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
981 ___E: ::fidl_next::Encoder,
982{
983 #[inline]
984 fn encode(
985 self,
986 encoder: &mut ___E,
987 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
988 ) -> Result<(), ::fidl_next::EncodeError> {
989 ::fidl_next::munge! {
990 let Self::Encoded {
991 name,
992
993 } = out;
994 }
995
996 ::fidl_next::Encode::encode(self.name, encoder, name)?;
997
998 Ok(())
999 }
1000}
1001
1002unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DeviceGetNameResponse
1003where
1004 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
1005 ___E: ::fidl_next::Encoder,
1006{
1007 #[inline]
1008 fn encode_ref(
1009 &self,
1010 encoder: &mut ___E,
1011 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
1012 ) -> Result<(), ::fidl_next::EncodeError> {
1013 ::fidl_next::munge! {
1014 let Self::Encoded {
1015 name,
1016
1017 } = out;
1018 }
1019
1020 ::fidl_next::EncodeRef::encode_ref(&self.name, encoder, name)?;
1021
1022 Ok(())
1023 }
1024}
1025
1026impl ::fidl_next::EncodableOption for DeviceGetNameResponse {
1027 type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceGetNameResponse<'static>>;
1028}
1029
1030unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceGetNameResponse
1031where
1032 ___E: ::fidl_next::Encoder + ?Sized,
1033 DeviceGetNameResponse: ::fidl_next::Encode<___E>,
1034{
1035 #[inline]
1036 fn encode_option(
1037 this: Option<Self>,
1038 encoder: &mut ___E,
1039 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
1040 ) -> Result<(), ::fidl_next::EncodeError> {
1041 if let Some(inner) = this {
1042 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
1043 ::fidl_next::WireBox::encode_present(out);
1044 } else {
1045 ::fidl_next::WireBox::encode_absent(out);
1046 }
1047
1048 Ok(())
1049 }
1050}
1051
1052unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DeviceGetNameResponse
1053where
1054 ___E: ::fidl_next::Encoder + ?Sized,
1055 DeviceGetNameResponse: ::fidl_next::EncodeRef<___E>,
1056{
1057 #[inline]
1058 fn encode_option_ref(
1059 this: Option<&Self>,
1060 encoder: &mut ___E,
1061 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
1062 ) -> Result<(), ::fidl_next::EncodeError> {
1063 if let Some(inner) = this {
1064 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
1065 ::fidl_next::WireBox::encode_present(out);
1066 } else {
1067 ::fidl_next::WireBox::encode_absent(out);
1068 }
1069
1070 Ok(())
1071 }
1072}
1073
1074impl<'de> ::fidl_next::FromWire<WireDeviceGetNameResponse<'de>> for DeviceGetNameResponse {
1075 #[inline]
1076 fn from_wire(wire: WireDeviceGetNameResponse<'de>) -> Self {
1077 Self { name: ::fidl_next::FromWire::from_wire(wire.name) }
1078 }
1079}
1080
1081impl<'de> ::fidl_next::FromWireRef<WireDeviceGetNameResponse<'de>> for DeviceGetNameResponse {
1082 #[inline]
1083 fn from_wire_ref(wire: &WireDeviceGetNameResponse<'de>) -> Self {
1084 Self { name: ::fidl_next::FromWireRef::from_wire_ref(&wire.name) }
1085 }
1086}
1087
1088#[derive(Debug)]
1090#[repr(C)]
1091pub struct WireDeviceGetNameResponse<'de> {
1092 pub name: ::fidl_next::WireString<'de>,
1093}
1094
1095unsafe impl ::fidl_next::Wire for WireDeviceGetNameResponse<'static> {
1096 type Decoded<'de> = WireDeviceGetNameResponse<'de>;
1097
1098 #[inline]
1099 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
1100}
1101
1102unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetNameResponse<'static>
1103where
1104 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
1105 ___D: ::fidl_next::Decoder,
1106{
1107 fn decode(
1108 slot: ::fidl_next::Slot<'_, Self>,
1109 decoder: &mut ___D,
1110 ) -> Result<(), ::fidl_next::DecodeError> {
1111 ::fidl_next::munge! {
1112 let Self {
1113 mut name,
1114
1115 } = slot;
1116 }
1117
1118 ::fidl_next::Decode::decode(name.as_mut(), decoder)?;
1119
1120 let name = unsafe { name.deref_unchecked() };
1121
1122 if name.len() > 64 {
1123 return Err(::fidl_next::DecodeError::VectorTooLong {
1124 size: name.len() as u64,
1125 limit: 64,
1126 });
1127 }
1128
1129 Ok(())
1130 }
1131}
1132
1133#[derive(Debug)]
1135pub struct Device;
1136
1137impl ::fidl_next::Discoverable for Device {
1138 const PROTOCOL_NAME: &'static str = "fuchsia.hardware.i2c.Device";
1139}
1140
1141pub mod device {
1142 pub mod prelude {
1143 pub use crate::{Device, DeviceClientHandler, DeviceServerHandler, device};
1144
1145 pub use crate::DeviceTransferRequest;
1146
1147 pub use crate::DeviceGetNameResponse;
1148
1149 pub use crate::DeviceTransferResponse;
1150 }
1151
1152 pub struct Transfer;
1153
1154 impl ::fidl_next::Method for Transfer {
1155 const ORDINAL: u64 = 871058866166117179;
1156
1157 type Protocol = crate::Device;
1158
1159 type Request = crate::WireDeviceTransferRequest<'static>;
1160
1161 type Response = ::fidl_next::WireResult<
1162 'static,
1163 crate::WireDeviceTransferResponse<'static>,
1164 ::fidl_next::WireI32,
1165 >;
1166 }
1167
1168 pub struct GetName;
1169
1170 impl ::fidl_next::Method for GetName {
1171 const ORDINAL: u64 = 8381876914474840322;
1172
1173 type Protocol = crate::Device;
1174
1175 type Request = ();
1176
1177 type Response = ::fidl_next::WireResult<
1178 'static,
1179 crate::WireDeviceGetNameResponse<'static>,
1180 ::fidl_next::WireI32,
1181 >;
1182 }
1183
1184 mod ___detail {
1185
1186 pub struct Transfer<T0> {
1187 transactions: T0,
1188 }
1189
1190 impl<T0> ::fidl_next::Encodable for Transfer<T0>
1191 where
1192 T0: ::fidl_next::Encodable<
1193 Encoded = ::fidl_next::WireVector<'static, crate::WireTransaction<'static>>,
1194 >,
1195 {
1196 type Encoded = crate::WireDeviceTransferRequest<'static>;
1197 }
1198
1199 unsafe impl<___E, T0> ::fidl_next::Encode<___E> for Transfer<T0>
1200 where
1201 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
1202 ___E: ::fidl_next::Encoder,
1203 T0: ::fidl_next::Encode<
1204 ___E,
1205 Encoded = ::fidl_next::WireVector<'static, crate::WireTransaction<'static>>,
1206 >,
1207 {
1208 #[inline]
1209 fn encode(
1210 self,
1211 encoder: &mut ___E,
1212 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
1213 ) -> Result<(), ::fidl_next::EncodeError> {
1214 ::fidl_next::munge! {
1215 let Self::Encoded {
1216 transactions,
1217
1218 } = out;
1219 }
1220
1221 ::fidl_next::Encode::encode(self.transactions, encoder, transactions)?;
1222
1223 Ok(())
1224 }
1225 }
1226
1227 unsafe impl<___T> ::fidl_next::Protocol<___T> for crate::Device
1228 where
1229 ___T: ::fidl_next::Transport,
1230 {
1231 type ClientSender = DeviceClientSender<___T>;
1232 type ServerSender = DeviceServerSender<___T>;
1233 }
1234
1235 #[repr(transparent)]
1237 pub struct DeviceClientSender<___T: ::fidl_next::Transport> {
1238 #[allow(dead_code)]
1239 sender: ::fidl_next::protocol::ClientSender<___T>,
1240 }
1241
1242 impl<___T> DeviceClientSender<___T>
1243 where
1244 ___T: ::fidl_next::Transport,
1245 {
1246 #[doc = " Issue one or more transactions to a particular I2C device.\n\n Each `Transaction` is performed in the order in which it appears in `transactions`. Data for\n read transfers (if there are any) is returned through `read_data`, which has one entry for\n each read transfer in `transactions`. Transaction processing continues until all transfers\n have been completed, an error occurs, or the target issues a NACK in response to a write\n transfer.\n\n The possible error values are:\n ZX_ERR_INVALID_ARGS: `transactions` has zero elements, `data_transfer` was not specified\n for a `Transaction`, or there was a zero-length `DataTransfer`.\n ZX_ERR_OUT_OF_RANGE: A `DataTransfer` was too large to be handled by this I2C controller.\n ZX_ERR_IO_NOT_PRESENT: The device did not respond to its I2C address.\n ZX_ERR_IO_REFUSED: The device issued a NACK before the end of a write transfer.\n"]
1247 pub fn transfer(
1248 &self,
1249
1250 transactions: impl ::fidl_next::Encode<
1251 <___T as ::fidl_next::Transport>::SendBuffer,
1252 Encoded = ::fidl_next::WireVector<'static, crate::WireTransaction<'static>>,
1253 >,
1254 ) -> ::fidl_next::TwoWayFuture<'_, super::Transfer, ___T>
1255 where
1256 <___T as ::fidl_next::Transport>::SendBuffer:
1257 ::fidl_next::encoder::InternalHandleEncoder,
1258 <___T as ::fidl_next::Transport>::SendBuffer: ::fidl_next::Encoder,
1259 {
1260 self.transfer_with(Transfer { transactions })
1261 }
1262
1263 #[doc = " Issue one or more transactions to a particular I2C device.\n\n Each `Transaction` is performed in the order in which it appears in `transactions`. Data for\n read transfers (if there are any) is returned through `read_data`, which has one entry for\n each read transfer in `transactions`. Transaction processing continues until all transfers\n have been completed, an error occurs, or the target issues a NACK in response to a write\n transfer.\n\n The possible error values are:\n ZX_ERR_INVALID_ARGS: `transactions` has zero elements, `data_transfer` was not specified\n for a `Transaction`, or there was a zero-length `DataTransfer`.\n ZX_ERR_OUT_OF_RANGE: A `DataTransfer` was too large to be handled by this I2C controller.\n ZX_ERR_IO_NOT_PRESENT: The device did not respond to its I2C address.\n ZX_ERR_IO_REFUSED: The device issued a NACK before the end of a write transfer.\n"]
1264 pub fn transfer_with<___R>(
1265 &self,
1266 request: ___R,
1267 ) -> ::fidl_next::TwoWayFuture<'_, super::Transfer, ___T>
1268 where
1269 ___R: ::fidl_next::Encode<
1270 <___T as ::fidl_next::Transport>::SendBuffer,
1271 Encoded = crate::WireDeviceTransferRequest<'static>,
1272 >,
1273 {
1274 ::fidl_next::TwoWayFuture::from_untyped(
1275 self.sender.send_two_way(871058866166117179, request),
1276 )
1277 }
1278
1279 #[doc = " Get the name of this I2C Device. Returns ZX_ERR_NOT_SUPPORTED if the\n name is unspecified or the empty string.\n"]
1280 pub fn get_name(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetName, ___T> {
1281 ::fidl_next::TwoWayFuture::from_untyped(
1282 self.sender.send_two_way(8381876914474840322, ()),
1283 )
1284 }
1285 }
1286
1287 #[repr(transparent)]
1289 pub struct DeviceServerSender<___T: ::fidl_next::Transport> {
1290 sender: ::fidl_next::protocol::ServerSender<___T>,
1291 }
1292
1293 impl<___T> DeviceServerSender<___T> where ___T: ::fidl_next::Transport {}
1294 }
1295}
1296
1297pub trait DeviceClientHandler<
1301 #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
1302 #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
1303>
1304{
1305}
1306
1307impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
1308where
1309 ___H: DeviceClientHandler<___T> + ::core::marker::Send,
1310 ___T: ::fidl_next::Transport,
1311 <device::Transfer as ::fidl_next::Method>::Response:
1312 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1313 <device::GetName as ::fidl_next::Method>::Response:
1314 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1315{
1316 async fn on_event(
1317 handler: &mut ___H,
1318 sender: &::fidl_next::ClientSender<Self, ___T>,
1319 ordinal: u64,
1320 buffer: ___T::RecvBuffer,
1321 ) {
1322 match ordinal {
1323 ordinal => sender.close(),
1324 }
1325 }
1326}
1327
1328pub trait DeviceServerHandler<
1332 #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
1333 #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
1334>
1335{
1336 #[doc = " Issue one or more transactions to a particular I2C device.\n\n Each `Transaction` is performed in the order in which it appears in `transactions`. Data for\n read transfers (if there are any) is returned through `read_data`, which has one entry for\n each read transfer in `transactions`. Transaction processing continues until all transfers\n have been completed, an error occurs, or the target issues a NACK in response to a write\n transfer.\n\n The possible error values are:\n ZX_ERR_INVALID_ARGS: `transactions` has zero elements, `data_transfer` was not specified\n for a `Transaction`, or there was a zero-length `DataTransfer`.\n ZX_ERR_OUT_OF_RANGE: A `DataTransfer` was too large to be handled by this I2C controller.\n ZX_ERR_IO_NOT_PRESENT: The device did not respond to its I2C address.\n ZX_ERR_IO_REFUSED: The device issued a NACK before the end of a write transfer.\n"]
1337 fn transfer(
1338 &mut self,
1339 sender: &::fidl_next::ServerSender<Device, ___T>,
1340
1341 request: ::fidl_next::Request<device::Transfer, ___T>,
1342
1343 responder: ::fidl_next::Responder<device::Transfer>,
1344 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1345
1346 #[doc = " Get the name of this I2C Device. Returns ZX_ERR_NOT_SUPPORTED if the\n name is unspecified or the empty string.\n"]
1347 fn get_name(
1348 &mut self,
1349 sender: &::fidl_next::ServerSender<Device, ___T>,
1350
1351 responder: ::fidl_next::Responder<device::GetName>,
1352 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1353}
1354
1355impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
1356where
1357 ___H: DeviceServerHandler<___T> + ::core::marker::Send,
1358 ___T: ::fidl_next::Transport,
1359 <device::Transfer as ::fidl_next::Method>::Request:
1360 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1361{
1362 async fn on_one_way(
1363 handler: &mut ___H,
1364 sender: &::fidl_next::ServerSender<Self, ___T>,
1365 ordinal: u64,
1366 buffer: ___T::RecvBuffer,
1367 ) {
1368 match ordinal {
1369 ordinal => sender.close(),
1370 }
1371 }
1372
1373 async fn on_two_way(
1374 handler: &mut ___H,
1375 sender: &::fidl_next::ServerSender<Self, ___T>,
1376 ordinal: u64,
1377 buffer: ___T::RecvBuffer,
1378 responder: ::fidl_next::protocol::Responder,
1379 ) {
1380 match ordinal {
1381 871058866166117179 => {
1382 let responder = ::fidl_next::Responder::from_untyped(responder);
1383
1384 match ::fidl_next::DecoderExt::decode(buffer) {
1385 Ok(decoded) => handler.transfer(sender, decoded, responder).await,
1386 Err(e) => sender.close(),
1387 }
1388 }
1389
1390 8381876914474840322 => {
1391 let responder = ::fidl_next::Responder::from_untyped(responder);
1392
1393 handler.get_name(sender, responder).await;
1394 }
1395
1396 ordinal => sender.close(),
1397 }
1398 }
1399}
1400
1401#[derive(Debug)]
1403pub struct Service;
1404
1405impl ::fidl_next::DiscoverableService for Service {
1406 const SERVICE_NAME: &'static str = "fuchsia.hardware.i2c.Service";
1407 const MEMBER_NAMES: &'static [&'static str] = &["device"];
1408}
1409
1410impl<___C> ::fidl_next::Service<___C> for Service
1411where
1412 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1413{
1414 type Connector = ServiceConnector<___C>;
1415}
1416
1417#[repr(transparent)]
1419pub struct ServiceConnector<___C> {
1420 #[allow(dead_code)]
1421 connector: ___C,
1422}
1423
1424impl<___C> ServiceConnector<___C>
1425where
1426 ___C: ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>,
1427{
1428 pub fn device(
1430 &self,
1431 server_end: ::fidl_next::ServerEnd<crate::Device, ::fidl_next::fuchsia::zx::Channel>,
1432 ) -> Result<
1433 (),
1434 <___C as ::fidl_next::protocol::ServiceConnector<::fidl_next::fuchsia::zx::Channel>>::Error,
1435 > {
1436 ::fidl_next::protocol::ServiceConnector::<
1437 ::fidl_next::fuchsia::zx::Channel
1438 >::connect_to_member(
1439 &self.connector,
1440 "device",
1441 server_end.into_untyped(),
1442 )
1443 }
1444}
1445
1446pub trait ServiceHandler<___T> {
1448 fn device(&self, server_end: ::fidl_next::ServerEnd<crate::Device, ___T>);
1450}
1451
1452impl<___H, ___T> ::fidl_next::DispatchServiceHandler<___H, ___T> for Service
1453where
1454 ___H: ServiceHandler<___T>,
1455{
1456 fn on_connection(handler: &___H, member: &str, server_end: ___T) {
1457 match member {
1458 "device" => handler.device(::fidl_next::ServerEnd::from_untyped(server_end)),
1459
1460 _ => unreachable!(),
1461 }
1462 }
1463}
1464
1465pub mod compat {
1467
1468 impl ::fidl_next::CompatFrom<crate::DataTransfer> for ::fidl_fuchsia_hardware_i2c::DataTransfer {
1469 fn compat_from(value: crate::DataTransfer) -> Self {
1470 match value {
1471 crate::DataTransfer::ReadSize(value) => {
1472 Self::ReadSize(::fidl_next::CompatFrom::compat_from(value))
1473 }
1474
1475 crate::DataTransfer::WriteData(value) => {
1476 Self::WriteData(::fidl_next::CompatFrom::compat_from(value))
1477 }
1478
1479 crate::DataTransfer::UnknownOrdinal_(unknown_ordinal) => {
1480 Self::__SourceBreaking { unknown_ordinal }
1481 }
1482 }
1483 }
1484 }
1485
1486 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::DataTransfer> for crate::DataTransfer {
1487 fn compat_from(value: ::fidl_fuchsia_hardware_i2c::DataTransfer) -> Self {
1488 match value {
1489 ::fidl_fuchsia_hardware_i2c::DataTransfer::ReadSize(value) => {
1490 Self::ReadSize(::fidl_next::CompatFrom::compat_from(value))
1491 }
1492
1493 ::fidl_fuchsia_hardware_i2c::DataTransfer::WriteData(value) => {
1494 Self::WriteData(::fidl_next::CompatFrom::compat_from(value))
1495 }
1496
1497 ::fidl_fuchsia_hardware_i2c::DataTransfer::__SourceBreaking { unknown_ordinal } => {
1498 Self::UnknownOrdinal_(unknown_ordinal)
1499 }
1500 }
1501 }
1502 }
1503
1504 impl ::fidl_next::CompatFrom<crate::Transaction> for ::fidl_fuchsia_hardware_i2c::Transaction {
1505 fn compat_from(value: crate::Transaction) -> Self {
1506 Self {
1507 data_transfer: ::fidl_next::CompatFrom::compat_from(value.data_transfer),
1508
1509 stop: ::fidl_next::CompatFrom::compat_from(value.stop),
1510
1511 __source_breaking: ::fidl::marker::SourceBreaking,
1512 }
1513 }
1514 }
1515
1516 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::Transaction> for crate::Transaction {
1517 fn compat_from(value: ::fidl_fuchsia_hardware_i2c::Transaction) -> Self {
1518 Self {
1519 data_transfer: ::fidl_next::CompatFrom::compat_from(value.data_transfer),
1520
1521 stop: ::fidl_next::CompatFrom::compat_from(value.stop),
1522 }
1523 }
1524 }
1525
1526 impl ::fidl_next::CompatFrom<crate::DeviceTransferRequest>
1527 for ::fidl_fuchsia_hardware_i2c::DeviceTransferRequest
1528 {
1529 #[inline]
1530 fn compat_from(value: crate::DeviceTransferRequest) -> Self {
1531 Self { transactions: ::fidl_next::CompatFrom::compat_from(value.transactions) }
1532 }
1533 }
1534
1535 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::DeviceTransferRequest>
1536 for crate::DeviceTransferRequest
1537 {
1538 #[inline]
1539 fn compat_from(value: ::fidl_fuchsia_hardware_i2c::DeviceTransferRequest) -> Self {
1540 Self { transactions: ::fidl_next::CompatFrom::compat_from(value.transactions) }
1541 }
1542 }
1543
1544 impl ::fidl_next::CompatFrom<crate::DeviceTransferResponse>
1545 for ::fidl_fuchsia_hardware_i2c::DeviceTransferResponse
1546 {
1547 #[inline]
1548 fn compat_from(value: crate::DeviceTransferResponse) -> Self {
1549 Self { read_data: ::fidl_next::CompatFrom::compat_from(value.read_data) }
1550 }
1551 }
1552
1553 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::DeviceTransferResponse>
1554 for crate::DeviceTransferResponse
1555 {
1556 #[inline]
1557 fn compat_from(value: ::fidl_fuchsia_hardware_i2c::DeviceTransferResponse) -> Self {
1558 Self { read_data: ::fidl_next::CompatFrom::compat_from(value.read_data) }
1559 }
1560 }
1561
1562 impl ::fidl_next::CompatFrom<crate::DeviceGetNameResponse>
1563 for ::fidl_fuchsia_hardware_i2c::DeviceGetNameResponse
1564 {
1565 #[inline]
1566 fn compat_from(value: crate::DeviceGetNameResponse) -> Self {
1567 Self { name: ::fidl_next::CompatFrom::compat_from(value.name) }
1568 }
1569 }
1570
1571 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::DeviceGetNameResponse>
1572 for crate::DeviceGetNameResponse
1573 {
1574 #[inline]
1575 fn compat_from(value: ::fidl_fuchsia_hardware_i2c::DeviceGetNameResponse) -> Self {
1576 Self { name: ::fidl_next::CompatFrom::compat_from(value.name) }
1577 }
1578 }
1579
1580 #[cfg(target_os = "fuchsia")]
1581 pub type DeviceProxy = ::fidl_next::ClientSender<crate::Device>;
1584
1585 impl ::fidl_next::CompatFrom<crate::Device> for ::fidl_fuchsia_hardware_i2c::DeviceMarker {
1586 fn compat_from(_: crate::Device) -> Self {
1587 Self
1588 }
1589 }
1590
1591 impl ::fidl_next::CompatFrom<::fidl_fuchsia_hardware_i2c::DeviceMarker> for crate::Device {
1592 fn compat_from(_: ::fidl_fuchsia_hardware_i2c::DeviceMarker) -> Self {
1593 Self
1594 }
1595 }
1596
1597 #[cfg(target_os = "fuchsia")]
1598
1599 impl ::fidl_next::ClientCompatFrom<::fidl_fuchsia_hardware_i2c::DeviceProxy> for crate::Device {
1600 fn client_compat_from(
1601 proxy: ::fidl_fuchsia_hardware_i2c::DeviceProxy,
1602 ) -> ::fidl_next::Client<Self, ::fidl_next::fuchsia::zx::Channel> {
1603 let channel = ::fidl::endpoints::Proxy::into_channel(proxy).unwrap().into_zx_channel();
1604 let client_end = ::fidl_next::ClientEnd::from_untyped(channel);
1605 ::fidl_next::Client::new(client_end)
1606 }
1607 }
1608}