Skip to main content

fidl_next_common_fuchsia_driver_metadata/
fidl_next_common_fuchsia_driver_metadata.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub mod natural {
6
7    #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
8    pub struct MetadataGetPersistedMetadataResponse {
9        pub persisted_metadata: ::std::vec::Vec<u8>,
10    }
11
12    unsafe impl<___E>
13        ::fidl_next::Encode<crate::wire::MetadataGetPersistedMetadataResponse<'static>, ___E>
14        for MetadataGetPersistedMetadataResponse
15    where
16        ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
17        ___E: ::fidl_next::Encoder,
18    {
19        #[inline]
20        fn encode(
21            self,
22            encoder_: &mut ___E,
23            out_: &mut ::core::mem::MaybeUninit<
24                crate::wire::MetadataGetPersistedMetadataResponse<'static>,
25            >,
26            _: (),
27        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
28            ::fidl_next::munge! {
29                let crate::wire::MetadataGetPersistedMetadataResponse {
30                    persisted_metadata,
31
32                } = out_;
33            }
34
35            ::fidl_next::Encode::encode(
36                self.persisted_metadata,
37                encoder_,
38                persisted_metadata,
39                (4294967295, ()),
40            )?;
41
42            let mut _field =
43                unsafe { ::fidl_next::Slot::new_unchecked(persisted_metadata.as_mut_ptr()) };
44            ::fidl_next::Constrained::validate(_field, (4294967295, ()))?;
45
46            Ok(())
47        }
48    }
49
50    unsafe impl<'a, ___E>
51        ::fidl_next::Encode<crate::wire::MetadataGetPersistedMetadataResponse<'static>, ___E>
52        for &'a MetadataGetPersistedMetadataResponse
53    where
54        ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
55        ___E: ::fidl_next::Encoder,
56    {
57        #[inline]
58        fn encode(
59            self,
60            encoder_: &mut ___E,
61            out_: &mut ::core::mem::MaybeUninit<
62                crate::wire::MetadataGetPersistedMetadataResponse<'static>,
63            >,
64            _: (),
65        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
66            ::fidl_next::munge! {
67                let crate::wire::MetadataGetPersistedMetadataResponse {
68                    persisted_metadata,
69
70                } = out_;
71            }
72
73            ::fidl_next::Encode::encode(
74                &self.persisted_metadata,
75                encoder_,
76                persisted_metadata,
77                (4294967295, ()),
78            )?;
79
80            let mut _field =
81                unsafe { ::fidl_next::Slot::new_unchecked(persisted_metadata.as_mut_ptr()) };
82            ::fidl_next::Constrained::validate(_field, (4294967295, ()))?;
83
84            Ok(())
85        }
86    }
87
88    unsafe impl<___E>
89        ::fidl_next::EncodeOption<
90            ::fidl_next::wire::Box<
91                'static,
92                crate::wire::MetadataGetPersistedMetadataResponse<'static>,
93            >,
94            ___E,
95        > for MetadataGetPersistedMetadataResponse
96    where
97        ___E: ::fidl_next::Encoder + ?Sized,
98        MetadataGetPersistedMetadataResponse:
99            ::fidl_next::Encode<crate::wire::MetadataGetPersistedMetadataResponse<'static>, ___E>,
100    {
101        #[inline]
102        fn encode_option(
103            this: ::core::option::Option<Self>,
104            encoder: &mut ___E,
105            out: &mut ::core::mem::MaybeUninit<
106                ::fidl_next::wire::Box<
107                    'static,
108                    crate::wire::MetadataGetPersistedMetadataResponse<'static>,
109                >,
110            >,
111            _: (),
112        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
113            if let Some(inner) = this {
114                ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
115                ::fidl_next::wire::Box::encode_present(out);
116            } else {
117                ::fidl_next::wire::Box::encode_absent(out);
118            }
119
120            Ok(())
121        }
122    }
123
124    unsafe impl<'a, ___E>
125        ::fidl_next::EncodeOption<
126            ::fidl_next::wire::Box<
127                'static,
128                crate::wire::MetadataGetPersistedMetadataResponse<'static>,
129            >,
130            ___E,
131        > for &'a MetadataGetPersistedMetadataResponse
132    where
133        ___E: ::fidl_next::Encoder + ?Sized,
134        &'a MetadataGetPersistedMetadataResponse:
135            ::fidl_next::Encode<crate::wire::MetadataGetPersistedMetadataResponse<'static>, ___E>,
136    {
137        #[inline]
138        fn encode_option(
139            this: ::core::option::Option<Self>,
140            encoder: &mut ___E,
141            out: &mut ::core::mem::MaybeUninit<
142                ::fidl_next::wire::Box<
143                    'static,
144                    crate::wire::MetadataGetPersistedMetadataResponse<'static>,
145                >,
146            >,
147            _: (),
148        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
149            if let Some(inner) = this {
150                ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
151                ::fidl_next::wire::Box::encode_present(out);
152            } else {
153                ::fidl_next::wire::Box::encode_absent(out);
154            }
155
156            Ok(())
157        }
158    }
159
160    impl<'de> ::fidl_next::FromWire<crate::wire::MetadataGetPersistedMetadataResponse<'de>>
161        for MetadataGetPersistedMetadataResponse
162    {
163        #[inline]
164        fn from_wire(wire: crate::wire::MetadataGetPersistedMetadataResponse<'de>) -> Self {
165            Self { persisted_metadata: ::fidl_next::FromWire::from_wire(wire.persisted_metadata) }
166        }
167    }
168
169    impl<'de> ::fidl_next::FromWireRef<crate::wire::MetadataGetPersistedMetadataResponse<'de>>
170        for MetadataGetPersistedMetadataResponse
171    {
172        #[inline]
173        fn from_wire_ref(wire: &crate::wire::MetadataGetPersistedMetadataResponse<'de>) -> Self {
174            Self {
175                persisted_metadata: ::fidl_next::FromWireRef::from_wire_ref(
176                    &wire.persisted_metadata,
177                ),
178            }
179        }
180    }
181}
182
183pub mod wire {
184
185    /// The wire type corresponding to [`MetadataGetPersistedMetadataResponse`].
186    #[derive(Debug)]
187    #[repr(C)]
188    pub struct MetadataGetPersistedMetadataResponse<'de> {
189        pub persisted_metadata: ::fidl_next::wire::Vector<'de, u8>,
190    }
191
192    static_assertions::const_assert_eq!(
193        std::mem::size_of::<MetadataGetPersistedMetadataResponse<'_>>(),
194        16
195    );
196    static_assertions::const_assert_eq!(
197        std::mem::align_of::<MetadataGetPersistedMetadataResponse<'_>>(),
198        8
199    );
200
201    static_assertions::const_assert_eq!(
202        std::mem::offset_of!(MetadataGetPersistedMetadataResponse<'_>, persisted_metadata),
203        0
204    );
205
206    impl ::fidl_next::Constrained for MetadataGetPersistedMetadataResponse<'_> {
207        type Constraint = ();
208
209        fn validate(
210            _: ::fidl_next::Slot<'_, Self>,
211            _: Self::Constraint,
212        ) -> Result<(), ::fidl_next::ValidationError> {
213            Ok(())
214        }
215    }
216
217    unsafe impl ::fidl_next::Wire for MetadataGetPersistedMetadataResponse<'static> {
218        type Narrowed<'de> = MetadataGetPersistedMetadataResponse<'de>;
219
220        #[inline]
221        fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
222            ::fidl_next::munge! {
223                let Self {
224                    persisted_metadata,
225
226                } = &mut *out_;
227            }
228
229            ::fidl_next::Wire::zero_padding(persisted_metadata);
230        }
231    }
232
233    unsafe impl<'de, ___D> ::fidl_next::Decode<___D> for MetadataGetPersistedMetadataResponse<'de>
234    where
235        ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
236        ___D: ::fidl_next::Decoder<'de>,
237    {
238        fn decode(
239            slot_: ::fidl_next::Slot<'_, Self>,
240            decoder_: &mut ___D,
241            _: (),
242        ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
243            ::fidl_next::munge! {
244                let Self {
245                    mut persisted_metadata,
246
247                } = slot_;
248            }
249
250            let _field = persisted_metadata.as_mut();
251            ::fidl_next::Constrained::validate(_field, (4294967295, ()))?;
252            ::fidl_next::Decode::decode(persisted_metadata.as_mut(), decoder_, (4294967295, ()))?;
253
254            Ok(())
255        }
256    }
257
258    impl<'de> ::fidl_next::IntoNatural for MetadataGetPersistedMetadataResponse<'de> {
259        type Natural = crate::natural::MetadataGetPersistedMetadataResponse;
260    }
261}
262
263pub mod wire_optional {}
264
265pub mod generic {
266
267    /// The generic type corresponding to [`MetadataGetPersistedMetadataResponse`].
268    pub struct MetadataGetPersistedMetadataResponse<T0> {
269        pub persisted_metadata: T0,
270    }
271
272    unsafe impl<___E, T0>
273        ::fidl_next::Encode<crate::wire::MetadataGetPersistedMetadataResponse<'static>, ___E>
274        for MetadataGetPersistedMetadataResponse<T0>
275    where
276        ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
277        ___E: ::fidl_next::Encoder,
278        T0: ::fidl_next::Encode<::fidl_next::wire::Vector<'static, u8>, ___E>,
279    {
280        #[inline]
281        fn encode(
282            self,
283            encoder_: &mut ___E,
284            out_: &mut ::core::mem::MaybeUninit<
285                crate::wire::MetadataGetPersistedMetadataResponse<'static>,
286            >,
287            _: (),
288        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
289            ::fidl_next::munge! {
290                let crate::wire::MetadataGetPersistedMetadataResponse {
291                    persisted_metadata,
292
293                } = out_;
294            }
295
296            ::fidl_next::Encode::encode(
297                self.persisted_metadata,
298                encoder_,
299                persisted_metadata,
300                (4294967295, ()),
301            )?;
302
303            Ok(())
304        }
305    }
306}
307
308pub use self::natural::*;
309
310/// The type corresponding to the Metadata protocol.
311#[derive(PartialEq, Debug)]
312pub struct Metadata;
313
314#[cfg(target_os = "fuchsia")]
315impl ::fidl_next::HasTransport for Metadata {
316    type Transport = ::fidl_next::fuchsia::zx::Channel;
317}
318
319pub mod metadata {
320    pub mod prelude {
321        pub use crate::{
322            Metadata, MetadataClientHandler, MetadataLocalClientHandler,
323            MetadataLocalServerHandler, MetadataServerHandler, metadata,
324        };
325
326        pub use crate::natural::MetadataGetPersistedMetadataResponse;
327    }
328
329    pub struct GetPersistedMetadata;
330
331    impl ::fidl_next::Method for GetPersistedMetadata {
332        const ORDINAL: u64 = 4835307543437455991;
333        const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
334            ::fidl_next::protocol::Flexibility::Strict;
335
336        type Protocol = crate::Metadata;
337
338        type Request = ::fidl_next::wire::EmptyMessageBody;
339    }
340
341    impl ::fidl_next::TwoWayMethod for GetPersistedMetadata {
342        type Response = ::fidl_next::wire::Result<
343            'static,
344            crate::wire::MetadataGetPersistedMetadataResponse<'static>,
345            ::fidl_next::wire::Int32,
346        >;
347    }
348
349    impl<___R> ::fidl_next::Respond<___R> for GetPersistedMetadata {
350        type Output = ::core::result::Result<
351            crate::generic::MetadataGetPersistedMetadataResponse<___R>,
352            ::fidl_next::util::Never,
353        >;
354
355        fn respond(response: ___R) -> Self::Output {
356            ::core::result::Result::Ok(crate::generic::MetadataGetPersistedMetadataResponse {
357                persisted_metadata: response,
358            })
359        }
360    }
361
362    impl<___R> ::fidl_next::RespondErr<___R> for GetPersistedMetadata {
363        type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
364
365        fn respond_err(response: ___R) -> Self::Output {
366            ::core::result::Result::Err(response)
367        }
368    }
369
370    mod ___detail {
371        unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Metadata
372        where
373            ___T: ::fidl_next::Transport,
374        {
375            type Client = MetadataClient<___T>;
376            type Server = MetadataServer<___T>;
377        }
378
379        /// The client for the `Metadata` protocol.
380        #[repr(transparent)]
381        pub struct MetadataClient<___T: ::fidl_next::Transport> {
382            #[allow(dead_code)]
383            client: ::fidl_next::protocol::Client<___T>,
384        }
385
386        impl<___T> MetadataClient<___T>
387        where
388            ___T: ::fidl_next::Transport,
389        {
390            #[doc = " Retrieve the persisted metadata provided by the server. Returns ZX_ERR_NOT_FOUND if the\n server does not have metadata to provide.\n"]
391            pub fn get_persisted_metadata(
392                &self,
393            ) -> ::fidl_next::TwoWayFuture<'_, super::GetPersistedMetadata, ___T> {
394                ::fidl_next::TwoWayFuture::from_untyped(
395                    self.client.send_two_way::<::fidl_next::wire::EmptyMessageBody>(
396                        4835307543437455991,
397                        <super::GetPersistedMetadata as ::fidl_next::Method>::FLEXIBILITY,
398                        (),
399                    ),
400                )
401            }
402        }
403
404        /// The server for the `Metadata` protocol.
405        #[repr(transparent)]
406        pub struct MetadataServer<___T: ::fidl_next::Transport> {
407            server: ::fidl_next::protocol::Server<___T>,
408        }
409
410        impl<___T> MetadataServer<___T> where ___T: ::fidl_next::Transport {}
411    }
412}
413
414#[diagnostic::on_unimplemented(
415    note = "If {Self} implements the non-local MetadataClientHandler trait, use `spawn_as_local` or the `Local` adapter type"
416)]
417
418/// A client handler for the Metadata protocol.
419///
420/// See [`Metadata`] for more details.
421pub trait MetadataLocalClientHandler<
422    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
423    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
424>
425{
426}
427
428impl<___H, ___T> ::fidl_next::DispatchLocalClientMessage<___H, ___T> for Metadata
429where
430    ___H: MetadataLocalClientHandler<___T>,
431    ___T: ::fidl_next::Transport,
432{
433    async fn on_event(
434        handler: &mut ___H,
435        ordinal: u64,
436        flexibility: ::fidl_next::protocol::Flexibility,
437        body: ::fidl_next::Body<___T>,
438    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
439        match ordinal {
440            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
441        }
442    }
443}
444
445#[diagnostic::on_unimplemented(
446    note = "If {Self} implements the non-local MetadataServerHandler trait, use `spawn_as_local` or the `Local` adapter type"
447)]
448
449/// A server handler for the Metadata protocol.
450///
451/// See [`Metadata`] for more details.
452pub trait MetadataLocalServerHandler<
453    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
454    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
455>
456{
457    #[doc = " Retrieve the persisted metadata provided by the server. Returns ZX_ERR_NOT_FOUND if the\n server does not have metadata to provide.\n"]
458    fn get_persisted_metadata(
459        &mut self,
460
461        responder: ::fidl_next::Responder<metadata::GetPersistedMetadata, ___T>,
462    ) -> impl ::core::future::Future<Output = ()>;
463}
464
465impl<___H, ___T> ::fidl_next::DispatchLocalServerMessage<___H, ___T> for Metadata
466where
467    ___H: MetadataLocalServerHandler<___T>,
468    ___T: ::fidl_next::Transport,
469{
470    async fn on_one_way(
471        handler: &mut ___H,
472        ordinal: u64,
473        flexibility: ::fidl_next::protocol::Flexibility,
474        body: ::fidl_next::Body<___T>,
475    ) -> ::core::result::Result<
476        (),
477        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
478    > {
479        match ordinal {
480            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
481        }
482    }
483
484    async fn on_two_way(
485        handler: &mut ___H,
486        ordinal: u64,
487        flexibility: ::fidl_next::protocol::Flexibility,
488        body: ::fidl_next::Body<___T>,
489        responder: ::fidl_next::protocol::Responder<___T>,
490    ) -> ::core::result::Result<
491        (),
492        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
493    > {
494        match ordinal {
495            4835307543437455991 => {
496                let responder = ::fidl_next::Responder::from_untyped(responder);
497
498                handler.get_persisted_metadata(responder).await;
499                Ok(())
500            }
501
502            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
503        }
504    }
505}
506
507/// A client handler for the Metadata protocol.
508///
509/// See [`Metadata`] for more details.
510pub trait MetadataClientHandler<
511    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
512    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
513>
514{
515}
516
517impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Metadata
518where
519    ___H: MetadataClientHandler<___T> + ::core::marker::Send,
520    ___T: ::fidl_next::Transport,
521{
522    async fn on_event(
523        handler: &mut ___H,
524        ordinal: u64,
525        flexibility: ::fidl_next::protocol::Flexibility,
526        body: ::fidl_next::Body<___T>,
527    ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
528        match ordinal {
529            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
530        }
531    }
532}
533
534/// A server handler for the Metadata protocol.
535///
536/// See [`Metadata`] for more details.
537pub trait MetadataServerHandler<
538    #[cfg(target_os = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
539    #[cfg(not(target_os = "fuchsia"))] ___T: ::fidl_next::Transport,
540>
541{
542    #[doc = " Retrieve the persisted metadata provided by the server. Returns ZX_ERR_NOT_FOUND if the\n server does not have metadata to provide.\n"]
543    fn get_persisted_metadata(
544        &mut self,
545
546        responder: ::fidl_next::Responder<metadata::GetPersistedMetadata, ___T>,
547    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
548}
549
550impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Metadata
551where
552    ___H: MetadataServerHandler<___T> + ::core::marker::Send,
553    ___T: ::fidl_next::Transport,
554{
555    async fn on_one_way(
556        handler: &mut ___H,
557        ordinal: u64,
558        flexibility: ::fidl_next::protocol::Flexibility,
559        body: ::fidl_next::Body<___T>,
560    ) -> ::core::result::Result<
561        (),
562        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
563    > {
564        match ordinal {
565            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
566        }
567    }
568
569    async fn on_two_way(
570        handler: &mut ___H,
571        ordinal: u64,
572        flexibility: ::fidl_next::protocol::Flexibility,
573        body: ::fidl_next::Body<___T>,
574        responder: ::fidl_next::protocol::Responder<___T>,
575    ) -> ::core::result::Result<
576        (),
577        ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
578    > {
579        match ordinal {
580            4835307543437455991 => {
581                let responder = ::fidl_next::Responder::from_untyped(responder);
582
583                handler.get_persisted_metadata(responder).await;
584                Ok(())
585            }
586
587            ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
588        }
589    }
590}
591
592impl<___T> MetadataClientHandler<___T> for ::fidl_next::IgnoreEvents where
593    ___T: ::fidl_next::Transport
594{
595}
596
597impl<___H, ___T> MetadataLocalClientHandler<___T> for ::fidl_next::Local<___H>
598where
599    ___H: MetadataClientHandler<___T>,
600    ___T: ::fidl_next::Transport,
601{
602}
603
604impl<___H, ___T> MetadataLocalServerHandler<___T> for ::fidl_next::Local<___H>
605where
606    ___H: MetadataServerHandler<___T>,
607    ___T: ::fidl_next::Transport,
608{
609    async fn get_persisted_metadata(
610        &mut self,
611
612        responder: ::fidl_next::Responder<metadata::GetPersistedMetadata, ___T>,
613    ) {
614        ___H::get_persisted_metadata(&mut self.0, responder).await
615    }
616}