fidl_fuchsia_ui_app/
fidl_fuchsia_ui_app.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_ui_app_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ViewProviderCreateView2Request {
16    pub args: CreateView2Args,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ViewProviderCreateView2Request
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct ViewProviderCreateViewWithViewRefRequest {
26    pub token: fidl::EventPair,
27    pub view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
28    pub view_ref: fidl_fuchsia_ui_views::ViewRef,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for ViewProviderCreateViewWithViewRefRequest
33{
34}
35
36#[derive(Debug, Default, PartialEq)]
37pub struct CreateView2Args {
38    /// Non-optional.  This token can be provided to Flatland to attach the client's child view
39    /// to the parent's viewport.
40    pub view_creation_token: Option<fidl_fuchsia_ui_views::ViewCreationToken>,
41    #[doc(hidden)]
42    pub __source_breaking: fidl::marker::SourceBreaking,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CreateView2Args {}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
48pub struct ViewProviderMarker;
49
50impl fidl::endpoints::ProtocolMarker for ViewProviderMarker {
51    type Proxy = ViewProviderProxy;
52    type RequestStream = ViewProviderRequestStream;
53    #[cfg(target_os = "fuchsia")]
54    type SynchronousProxy = ViewProviderSynchronousProxy;
55
56    const DEBUG_NAME: &'static str = "fuchsia.ui.app.ViewProvider";
57}
58impl fidl::endpoints::DiscoverableProtocolMarker for ViewProviderMarker {}
59
60pub trait ViewProviderProxyInterface: Send + Sync {
61    fn r#create_view_with_view_ref(
62        &self,
63        token: fidl::EventPair,
64        view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
65        view_ref: fidl_fuchsia_ui_views::ViewRef,
66    ) -> Result<(), fidl::Error>;
67    fn r#create_view2(&self, args: CreateView2Args) -> Result<(), fidl::Error>;
68}
69#[derive(Debug)]
70#[cfg(target_os = "fuchsia")]
71pub struct ViewProviderSynchronousProxy {
72    client: fidl::client::sync::Client,
73}
74
75#[cfg(target_os = "fuchsia")]
76impl fidl::endpoints::SynchronousProxy for ViewProviderSynchronousProxy {
77    type Proxy = ViewProviderProxy;
78    type Protocol = ViewProviderMarker;
79
80    fn from_channel(inner: fidl::Channel) -> Self {
81        Self::new(inner)
82    }
83
84    fn into_channel(self) -> fidl::Channel {
85        self.client.into_channel()
86    }
87
88    fn as_channel(&self) -> &fidl::Channel {
89        self.client.as_channel()
90    }
91}
92
93#[cfg(target_os = "fuchsia")]
94impl ViewProviderSynchronousProxy {
95    pub fn new(channel: fidl::Channel) -> Self {
96        let protocol_name = <ViewProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
97        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
98    }
99
100    pub fn into_channel(self) -> fidl::Channel {
101        self.client.into_channel()
102    }
103
104    /// Waits until an event arrives and returns it. It is safe for other
105    /// threads to make concurrent requests while waiting for an event.
106    pub fn wait_for_event(
107        &self,
108        deadline: zx::MonotonicInstant,
109    ) -> Result<ViewProviderEvent, fidl::Error> {
110        ViewProviderEvent::decode(self.client.wait_for_event(deadline)?)
111    }
112
113    /// Creates a new View under the control of the ViewProvider.
114    ///
115    /// `token` is one half of the shared eventpair which will bind the new View
116    /// to its associated ViewHolder.  The ViewProvider will use `token` to
117    /// create its internal View representation.  The caller is expected to use
118    /// its half to create corresponding ViewHolder object.
119    ///
120    /// `view_ref_control` and `view_ref` are two typed handles to each half of the
121    /// same event pair. The `view_ref` can be cloned before passing it to this method,
122    /// which will allow clients to track the view (e.g., in a focus chain update).
123    ///
124    /// `view_ref_control` must not have the ZX_RIGHT_DUPLICATE set, or view creation
125    /// will fail.
126    pub fn r#create_view_with_view_ref(
127        &self,
128        mut token: fidl::EventPair,
129        mut view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
130        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
131    ) -> Result<(), fidl::Error> {
132        self.client.send::<ViewProviderCreateViewWithViewRefRequest>(
133            (token, &mut view_ref_control, &mut view_ref),
134            0x586d23a5e4f69a86,
135            fidl::encoding::DynamicFlags::empty(),
136        )
137    }
138
139    /// Creates a new View under the control of the ViewProvider.
140    ///
141    /// The args are provided as a table, for forward compatibility.  See documentation on the
142    /// individual table fields.
143    pub fn r#create_view2(&self, mut args: CreateView2Args) -> Result<(), fidl::Error> {
144        self.client.send::<ViewProviderCreateView2Request>(
145            (&mut args,),
146            0x78b4a51b5e630482,
147            fidl::encoding::DynamicFlags::empty(),
148        )
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl From<ViewProviderSynchronousProxy> for zx::Handle {
154    fn from(value: ViewProviderSynchronousProxy) -> Self {
155        value.into_channel().into()
156    }
157}
158
159#[cfg(target_os = "fuchsia")]
160impl From<fidl::Channel> for ViewProviderSynchronousProxy {
161    fn from(value: fidl::Channel) -> Self {
162        Self::new(value)
163    }
164}
165
166#[derive(Debug, Clone)]
167pub struct ViewProviderProxy {
168    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
169}
170
171impl fidl::endpoints::Proxy for ViewProviderProxy {
172    type Protocol = ViewProviderMarker;
173
174    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
175        Self::new(inner)
176    }
177
178    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
179        self.client.into_channel().map_err(|client| Self { client })
180    }
181
182    fn as_channel(&self) -> &::fidl::AsyncChannel {
183        self.client.as_channel()
184    }
185}
186
187impl ViewProviderProxy {
188    /// Create a new Proxy for fuchsia.ui.app/ViewProvider.
189    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
190        let protocol_name = <ViewProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
191        Self { client: fidl::client::Client::new(channel, protocol_name) }
192    }
193
194    /// Get a Stream of events from the remote end of the protocol.
195    ///
196    /// # Panics
197    ///
198    /// Panics if the event stream was already taken.
199    pub fn take_event_stream(&self) -> ViewProviderEventStream {
200        ViewProviderEventStream { event_receiver: self.client.take_event_receiver() }
201    }
202
203    /// Creates a new View under the control of the ViewProvider.
204    ///
205    /// `token` is one half of the shared eventpair which will bind the new View
206    /// to its associated ViewHolder.  The ViewProvider will use `token` to
207    /// create its internal View representation.  The caller is expected to use
208    /// its half to create corresponding ViewHolder object.
209    ///
210    /// `view_ref_control` and `view_ref` are two typed handles to each half of the
211    /// same event pair. The `view_ref` can be cloned before passing it to this method,
212    /// which will allow clients to track the view (e.g., in a focus chain update).
213    ///
214    /// `view_ref_control` must not have the ZX_RIGHT_DUPLICATE set, or view creation
215    /// will fail.
216    pub fn r#create_view_with_view_ref(
217        &self,
218        mut token: fidl::EventPair,
219        mut view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
220        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
221    ) -> Result<(), fidl::Error> {
222        ViewProviderProxyInterface::r#create_view_with_view_ref(
223            self,
224            token,
225            view_ref_control,
226            view_ref,
227        )
228    }
229
230    /// Creates a new View under the control of the ViewProvider.
231    ///
232    /// The args are provided as a table, for forward compatibility.  See documentation on the
233    /// individual table fields.
234    pub fn r#create_view2(&self, mut args: CreateView2Args) -> Result<(), fidl::Error> {
235        ViewProviderProxyInterface::r#create_view2(self, args)
236    }
237}
238
239impl ViewProviderProxyInterface for ViewProviderProxy {
240    fn r#create_view_with_view_ref(
241        &self,
242        mut token: fidl::EventPair,
243        mut view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
244        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
245    ) -> Result<(), fidl::Error> {
246        self.client.send::<ViewProviderCreateViewWithViewRefRequest>(
247            (token, &mut view_ref_control, &mut view_ref),
248            0x586d23a5e4f69a86,
249            fidl::encoding::DynamicFlags::empty(),
250        )
251    }
252
253    fn r#create_view2(&self, mut args: CreateView2Args) -> Result<(), fidl::Error> {
254        self.client.send::<ViewProviderCreateView2Request>(
255            (&mut args,),
256            0x78b4a51b5e630482,
257            fidl::encoding::DynamicFlags::empty(),
258        )
259    }
260}
261
262pub struct ViewProviderEventStream {
263    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
264}
265
266impl std::marker::Unpin for ViewProviderEventStream {}
267
268impl futures::stream::FusedStream for ViewProviderEventStream {
269    fn is_terminated(&self) -> bool {
270        self.event_receiver.is_terminated()
271    }
272}
273
274impl futures::Stream for ViewProviderEventStream {
275    type Item = Result<ViewProviderEvent, fidl::Error>;
276
277    fn poll_next(
278        mut self: std::pin::Pin<&mut Self>,
279        cx: &mut std::task::Context<'_>,
280    ) -> std::task::Poll<Option<Self::Item>> {
281        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
282            &mut self.event_receiver,
283            cx
284        )?) {
285            Some(buf) => std::task::Poll::Ready(Some(ViewProviderEvent::decode(buf))),
286            None => std::task::Poll::Ready(None),
287        }
288    }
289}
290
291#[derive(Debug)]
292pub enum ViewProviderEvent {}
293
294impl ViewProviderEvent {
295    /// Decodes a message buffer as a [`ViewProviderEvent`].
296    fn decode(
297        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
298    ) -> Result<ViewProviderEvent, fidl::Error> {
299        let (bytes, _handles) = buf.split_mut();
300        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
301        debug_assert_eq!(tx_header.tx_id, 0);
302        match tx_header.ordinal {
303            _ => Err(fidl::Error::UnknownOrdinal {
304                ordinal: tx_header.ordinal,
305                protocol_name: <ViewProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
306            }),
307        }
308    }
309}
310
311/// A Stream of incoming requests for fuchsia.ui.app/ViewProvider.
312pub struct ViewProviderRequestStream {
313    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
314    is_terminated: bool,
315}
316
317impl std::marker::Unpin for ViewProviderRequestStream {}
318
319impl futures::stream::FusedStream for ViewProviderRequestStream {
320    fn is_terminated(&self) -> bool {
321        self.is_terminated
322    }
323}
324
325impl fidl::endpoints::RequestStream for ViewProviderRequestStream {
326    type Protocol = ViewProviderMarker;
327    type ControlHandle = ViewProviderControlHandle;
328
329    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
330        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
331    }
332
333    fn control_handle(&self) -> Self::ControlHandle {
334        ViewProviderControlHandle { inner: self.inner.clone() }
335    }
336
337    fn into_inner(
338        self,
339    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
340    {
341        (self.inner, self.is_terminated)
342    }
343
344    fn from_inner(
345        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
346        is_terminated: bool,
347    ) -> Self {
348        Self { inner, is_terminated }
349    }
350}
351
352impl futures::Stream for ViewProviderRequestStream {
353    type Item = Result<ViewProviderRequest, fidl::Error>;
354
355    fn poll_next(
356        mut self: std::pin::Pin<&mut Self>,
357        cx: &mut std::task::Context<'_>,
358    ) -> std::task::Poll<Option<Self::Item>> {
359        let this = &mut *self;
360        if this.inner.check_shutdown(cx) {
361            this.is_terminated = true;
362            return std::task::Poll::Ready(None);
363        }
364        if this.is_terminated {
365            panic!("polled ViewProviderRequestStream after completion");
366        }
367        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
368            |bytes, handles| {
369                match this.inner.channel().read_etc(cx, bytes, handles) {
370                    std::task::Poll::Ready(Ok(())) => {}
371                    std::task::Poll::Pending => return std::task::Poll::Pending,
372                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
373                        this.is_terminated = true;
374                        return std::task::Poll::Ready(None);
375                    }
376                    std::task::Poll::Ready(Err(e)) => {
377                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
378                            e.into(),
379                        ))))
380                    }
381                }
382
383                // A message has been received from the channel
384                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
385
386                std::task::Poll::Ready(Some(match header.ordinal {
387                    0x586d23a5e4f69a86 => {
388                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
389                        let mut req = fidl::new_empty!(
390                            ViewProviderCreateViewWithViewRefRequest,
391                            fidl::encoding::DefaultFuchsiaResourceDialect
392                        );
393                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewProviderCreateViewWithViewRefRequest>(&header, _body_bytes, handles, &mut req)?;
394                        let control_handle =
395                            ViewProviderControlHandle { inner: this.inner.clone() };
396                        Ok(ViewProviderRequest::CreateViewWithViewRef {
397                            token: req.token,
398                            view_ref_control: req.view_ref_control,
399                            view_ref: req.view_ref,
400
401                            control_handle,
402                        })
403                    }
404                    0x78b4a51b5e630482 => {
405                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
406                        let mut req = fidl::new_empty!(
407                            ViewProviderCreateView2Request,
408                            fidl::encoding::DefaultFuchsiaResourceDialect
409                        );
410                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewProviderCreateView2Request>(&header, _body_bytes, handles, &mut req)?;
411                        let control_handle =
412                            ViewProviderControlHandle { inner: this.inner.clone() };
413                        Ok(ViewProviderRequest::CreateView2 { args: req.args, control_handle })
414                    }
415                    _ => Err(fidl::Error::UnknownOrdinal {
416                        ordinal: header.ordinal,
417                        protocol_name:
418                            <ViewProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
419                    }),
420                }))
421            },
422        )
423    }
424}
425
426/// ViewProvider is the standard mechanism for two modules to each obtain half
427/// of a shared eventpair token.  The shared token is a capability allowing the
428/// modules to ask Scenic to create a ViewHolder/View pair.  The resulting
429/// View and ViewHolder are linked together until either one is destroyed.
430///
431/// Modules are free to use any other mechanism to agree upon the shared
432/// eventpair token, and use this to create the linked ViewHolder/View.
433/// ViewProvider is given for the convenience of clients that don't require
434/// a more complex implementation.
435#[derive(Debug)]
436pub enum ViewProviderRequest {
437    /// Creates a new View under the control of the ViewProvider.
438    ///
439    /// `token` is one half of the shared eventpair which will bind the new View
440    /// to its associated ViewHolder.  The ViewProvider will use `token` to
441    /// create its internal View representation.  The caller is expected to use
442    /// its half to create corresponding ViewHolder object.
443    ///
444    /// `view_ref_control` and `view_ref` are two typed handles to each half of the
445    /// same event pair. The `view_ref` can be cloned before passing it to this method,
446    /// which will allow clients to track the view (e.g., in a focus chain update).
447    ///
448    /// `view_ref_control` must not have the ZX_RIGHT_DUPLICATE set, or view creation
449    /// will fail.
450    CreateViewWithViewRef {
451        token: fidl::EventPair,
452        view_ref_control: fidl_fuchsia_ui_views::ViewRefControl,
453        view_ref: fidl_fuchsia_ui_views::ViewRef,
454        control_handle: ViewProviderControlHandle,
455    },
456    /// Creates a new View under the control of the ViewProvider.
457    ///
458    /// The args are provided as a table, for forward compatibility.  See documentation on the
459    /// individual table fields.
460    CreateView2 { args: CreateView2Args, control_handle: ViewProviderControlHandle },
461}
462
463impl ViewProviderRequest {
464    #[allow(irrefutable_let_patterns)]
465    pub fn into_create_view_with_view_ref(
466        self,
467    ) -> Option<(
468        fidl::EventPair,
469        fidl_fuchsia_ui_views::ViewRefControl,
470        fidl_fuchsia_ui_views::ViewRef,
471        ViewProviderControlHandle,
472    )> {
473        if let ViewProviderRequest::CreateViewWithViewRef {
474            token,
475            view_ref_control,
476            view_ref,
477            control_handle,
478        } = self
479        {
480            Some((token, view_ref_control, view_ref, control_handle))
481        } else {
482            None
483        }
484    }
485
486    #[allow(irrefutable_let_patterns)]
487    pub fn into_create_view2(self) -> Option<(CreateView2Args, ViewProviderControlHandle)> {
488        if let ViewProviderRequest::CreateView2 { args, control_handle } = self {
489            Some((args, control_handle))
490        } else {
491            None
492        }
493    }
494
495    /// Name of the method defined in FIDL
496    pub fn method_name(&self) -> &'static str {
497        match *self {
498            ViewProviderRequest::CreateViewWithViewRef { .. } => "create_view_with_view_ref",
499            ViewProviderRequest::CreateView2 { .. } => "create_view2",
500        }
501    }
502}
503
504#[derive(Debug, Clone)]
505pub struct ViewProviderControlHandle {
506    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
507}
508
509impl fidl::endpoints::ControlHandle for ViewProviderControlHandle {
510    fn shutdown(&self) {
511        self.inner.shutdown()
512    }
513    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
514        self.inner.shutdown_with_epitaph(status)
515    }
516
517    fn is_closed(&self) -> bool {
518        self.inner.channel().is_closed()
519    }
520    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
521        self.inner.channel().on_closed()
522    }
523
524    #[cfg(target_os = "fuchsia")]
525    fn signal_peer(
526        &self,
527        clear_mask: zx::Signals,
528        set_mask: zx::Signals,
529    ) -> Result<(), zx_status::Status> {
530        use fidl::Peered;
531        self.inner.channel().signal_peer(clear_mask, set_mask)
532    }
533}
534
535impl ViewProviderControlHandle {}
536
537mod internal {
538    use super::*;
539
540    impl fidl::encoding::ResourceTypeMarker for ViewProviderCreateView2Request {
541        type Borrowed<'a> = &'a mut Self;
542        fn take_or_borrow<'a>(
543            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
544        ) -> Self::Borrowed<'a> {
545            value
546        }
547    }
548
549    unsafe impl fidl::encoding::TypeMarker for ViewProviderCreateView2Request {
550        type Owned = Self;
551
552        #[inline(always)]
553        fn inline_align(_context: fidl::encoding::Context) -> usize {
554            8
555        }
556
557        #[inline(always)]
558        fn inline_size(_context: fidl::encoding::Context) -> usize {
559            16
560        }
561    }
562
563    unsafe impl
564        fidl::encoding::Encode<
565            ViewProviderCreateView2Request,
566            fidl::encoding::DefaultFuchsiaResourceDialect,
567        > for &mut ViewProviderCreateView2Request
568    {
569        #[inline]
570        unsafe fn encode(
571            self,
572            encoder: &mut fidl::encoding::Encoder<
573                '_,
574                fidl::encoding::DefaultFuchsiaResourceDialect,
575            >,
576            offset: usize,
577            _depth: fidl::encoding::Depth,
578        ) -> fidl::Result<()> {
579            encoder.debug_check_bounds::<ViewProviderCreateView2Request>(offset);
580            // Delegate to tuple encoding.
581            fidl::encoding::Encode::<
582                ViewProviderCreateView2Request,
583                fidl::encoding::DefaultFuchsiaResourceDialect,
584            >::encode(
585                (<CreateView2Args as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
586                    &mut self.args,
587                ),),
588                encoder,
589                offset,
590                _depth,
591            )
592        }
593    }
594    unsafe impl<
595            T0: fidl::encoding::Encode<CreateView2Args, fidl::encoding::DefaultFuchsiaResourceDialect>,
596        >
597        fidl::encoding::Encode<
598            ViewProviderCreateView2Request,
599            fidl::encoding::DefaultFuchsiaResourceDialect,
600        > for (T0,)
601    {
602        #[inline]
603        unsafe fn encode(
604            self,
605            encoder: &mut fidl::encoding::Encoder<
606                '_,
607                fidl::encoding::DefaultFuchsiaResourceDialect,
608            >,
609            offset: usize,
610            depth: fidl::encoding::Depth,
611        ) -> fidl::Result<()> {
612            encoder.debug_check_bounds::<ViewProviderCreateView2Request>(offset);
613            // Zero out padding regions. There's no need to apply masks
614            // because the unmasked parts will be overwritten by fields.
615            // Write the fields.
616            self.0.encode(encoder, offset + 0, depth)?;
617            Ok(())
618        }
619    }
620
621    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
622        for ViewProviderCreateView2Request
623    {
624        #[inline(always)]
625        fn new_empty() -> Self {
626            Self {
627                args: fidl::new_empty!(
628                    CreateView2Args,
629                    fidl::encoding::DefaultFuchsiaResourceDialect
630                ),
631            }
632        }
633
634        #[inline]
635        unsafe fn decode(
636            &mut self,
637            decoder: &mut fidl::encoding::Decoder<
638                '_,
639                fidl::encoding::DefaultFuchsiaResourceDialect,
640            >,
641            offset: usize,
642            _depth: fidl::encoding::Depth,
643        ) -> fidl::Result<()> {
644            decoder.debug_check_bounds::<Self>(offset);
645            // Verify that padding bytes are zero.
646            fidl::decode!(
647                CreateView2Args,
648                fidl::encoding::DefaultFuchsiaResourceDialect,
649                &mut self.args,
650                decoder,
651                offset + 0,
652                _depth
653            )?;
654            Ok(())
655        }
656    }
657
658    impl fidl::encoding::ResourceTypeMarker for ViewProviderCreateViewWithViewRefRequest {
659        type Borrowed<'a> = &'a mut Self;
660        fn take_or_borrow<'a>(
661            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
662        ) -> Self::Borrowed<'a> {
663            value
664        }
665    }
666
667    unsafe impl fidl::encoding::TypeMarker for ViewProviderCreateViewWithViewRefRequest {
668        type Owned = Self;
669
670        #[inline(always)]
671        fn inline_align(_context: fidl::encoding::Context) -> usize {
672            4
673        }
674
675        #[inline(always)]
676        fn inline_size(_context: fidl::encoding::Context) -> usize {
677            12
678        }
679    }
680
681    unsafe impl
682        fidl::encoding::Encode<
683            ViewProviderCreateViewWithViewRefRequest,
684            fidl::encoding::DefaultFuchsiaResourceDialect,
685        > for &mut ViewProviderCreateViewWithViewRefRequest
686    {
687        #[inline]
688        unsafe fn encode(
689            self,
690            encoder: &mut fidl::encoding::Encoder<
691                '_,
692                fidl::encoding::DefaultFuchsiaResourceDialect,
693            >,
694            offset: usize,
695            _depth: fidl::encoding::Depth,
696        ) -> fidl::Result<()> {
697            encoder.debug_check_bounds::<ViewProviderCreateViewWithViewRefRequest>(offset);
698            // Delegate to tuple encoding.
699            fidl::encoding::Encode::<ViewProviderCreateViewWithViewRefRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
700                (
701                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
702                    <fidl_fuchsia_ui_views::ViewRefControl as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref_control),
703                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
704                ),
705                encoder, offset, _depth
706            )
707        }
708    }
709    unsafe impl<
710            T0: fidl::encoding::Encode<
711                fidl::encoding::HandleType<
712                    fidl::EventPair,
713                    { fidl::ObjectType::EVENTPAIR.into_raw() },
714                    2147483648,
715                >,
716                fidl::encoding::DefaultFuchsiaResourceDialect,
717            >,
718            T1: fidl::encoding::Encode<
719                fidl_fuchsia_ui_views::ViewRefControl,
720                fidl::encoding::DefaultFuchsiaResourceDialect,
721            >,
722            T2: fidl::encoding::Encode<
723                fidl_fuchsia_ui_views::ViewRef,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725            >,
726        >
727        fidl::encoding::Encode<
728            ViewProviderCreateViewWithViewRefRequest,
729            fidl::encoding::DefaultFuchsiaResourceDialect,
730        > for (T0, T1, T2)
731    {
732        #[inline]
733        unsafe fn encode(
734            self,
735            encoder: &mut fidl::encoding::Encoder<
736                '_,
737                fidl::encoding::DefaultFuchsiaResourceDialect,
738            >,
739            offset: usize,
740            depth: fidl::encoding::Depth,
741        ) -> fidl::Result<()> {
742            encoder.debug_check_bounds::<ViewProviderCreateViewWithViewRefRequest>(offset);
743            // Zero out padding regions. There's no need to apply masks
744            // because the unmasked parts will be overwritten by fields.
745            // Write the fields.
746            self.0.encode(encoder, offset + 0, depth)?;
747            self.1.encode(encoder, offset + 4, depth)?;
748            self.2.encode(encoder, offset + 8, depth)?;
749            Ok(())
750        }
751    }
752
753    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
754        for ViewProviderCreateViewWithViewRefRequest
755    {
756        #[inline(always)]
757        fn new_empty() -> Self {
758            Self {
759                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
760                view_ref_control: fidl::new_empty!(
761                    fidl_fuchsia_ui_views::ViewRefControl,
762                    fidl::encoding::DefaultFuchsiaResourceDialect
763                ),
764                view_ref: fidl::new_empty!(
765                    fidl_fuchsia_ui_views::ViewRef,
766                    fidl::encoding::DefaultFuchsiaResourceDialect
767                ),
768            }
769        }
770
771        #[inline]
772        unsafe fn decode(
773            &mut self,
774            decoder: &mut fidl::encoding::Decoder<
775                '_,
776                fidl::encoding::DefaultFuchsiaResourceDialect,
777            >,
778            offset: usize,
779            _depth: fidl::encoding::Depth,
780        ) -> fidl::Result<()> {
781            decoder.debug_check_bounds::<Self>(offset);
782            // Verify that padding bytes are zero.
783            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
784            fidl::decode!(
785                fidl_fuchsia_ui_views::ViewRefControl,
786                fidl::encoding::DefaultFuchsiaResourceDialect,
787                &mut self.view_ref_control,
788                decoder,
789                offset + 4,
790                _depth
791            )?;
792            fidl::decode!(
793                fidl_fuchsia_ui_views::ViewRef,
794                fidl::encoding::DefaultFuchsiaResourceDialect,
795                &mut self.view_ref,
796                decoder,
797                offset + 8,
798                _depth
799            )?;
800            Ok(())
801        }
802    }
803
804    impl CreateView2Args {
805        #[inline(always)]
806        fn max_ordinal_present(&self) -> u64 {
807            if let Some(_) = self.view_creation_token {
808                return 1;
809            }
810            0
811        }
812    }
813
814    impl fidl::encoding::ResourceTypeMarker for CreateView2Args {
815        type Borrowed<'a> = &'a mut Self;
816        fn take_or_borrow<'a>(
817            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
818        ) -> Self::Borrowed<'a> {
819            value
820        }
821    }
822
823    unsafe impl fidl::encoding::TypeMarker for CreateView2Args {
824        type Owned = Self;
825
826        #[inline(always)]
827        fn inline_align(_context: fidl::encoding::Context) -> usize {
828            8
829        }
830
831        #[inline(always)]
832        fn inline_size(_context: fidl::encoding::Context) -> usize {
833            16
834        }
835    }
836
837    unsafe impl
838        fidl::encoding::Encode<CreateView2Args, fidl::encoding::DefaultFuchsiaResourceDialect>
839        for &mut CreateView2Args
840    {
841        unsafe fn encode(
842            self,
843            encoder: &mut fidl::encoding::Encoder<
844                '_,
845                fidl::encoding::DefaultFuchsiaResourceDialect,
846            >,
847            offset: usize,
848            mut depth: fidl::encoding::Depth,
849        ) -> fidl::Result<()> {
850            encoder.debug_check_bounds::<CreateView2Args>(offset);
851            // Vector header
852            let max_ordinal: u64 = self.max_ordinal_present();
853            encoder.write_num(max_ordinal, offset);
854            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
855            // Calling encoder.out_of_line_offset(0) is not allowed.
856            if max_ordinal == 0 {
857                return Ok(());
858            }
859            depth.increment()?;
860            let envelope_size = 8;
861            let bytes_len = max_ordinal as usize * envelope_size;
862            #[allow(unused_variables)]
863            let offset = encoder.out_of_line_offset(bytes_len);
864            let mut _prev_end_offset: usize = 0;
865            if 1 > max_ordinal {
866                return Ok(());
867            }
868
869            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
870            // are envelope_size bytes.
871            let cur_offset: usize = (1 - 1) * envelope_size;
872
873            // Zero reserved fields.
874            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
875
876            // Safety:
877            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
878            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
879            //   envelope_size bytes, there is always sufficient room.
880            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_views::ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
881            self.view_creation_token.as_mut().map(<fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
882            encoder, offset + cur_offset, depth
883        )?;
884
885            _prev_end_offset = cur_offset + envelope_size;
886
887            Ok(())
888        }
889    }
890
891    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
892        for CreateView2Args
893    {
894        #[inline(always)]
895        fn new_empty() -> Self {
896            Self::default()
897        }
898
899        unsafe fn decode(
900            &mut self,
901            decoder: &mut fidl::encoding::Decoder<
902                '_,
903                fidl::encoding::DefaultFuchsiaResourceDialect,
904            >,
905            offset: usize,
906            mut depth: fidl::encoding::Depth,
907        ) -> fidl::Result<()> {
908            decoder.debug_check_bounds::<Self>(offset);
909            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
910                None => return Err(fidl::Error::NotNullable),
911                Some(len) => len,
912            };
913            // Calling decoder.out_of_line_offset(0) is not allowed.
914            if len == 0 {
915                return Ok(());
916            };
917            depth.increment()?;
918            let envelope_size = 8;
919            let bytes_len = len * envelope_size;
920            let offset = decoder.out_of_line_offset(bytes_len)?;
921            // Decode the envelope for each type.
922            let mut _next_ordinal_to_read = 0;
923            let mut next_offset = offset;
924            let end_offset = offset + bytes_len;
925            _next_ordinal_to_read += 1;
926            if next_offset >= end_offset {
927                return Ok(());
928            }
929
930            // Decode unknown envelopes for gaps in ordinals.
931            while _next_ordinal_to_read < 1 {
932                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
933                _next_ordinal_to_read += 1;
934                next_offset += envelope_size;
935            }
936
937            let next_out_of_line = decoder.next_out_of_line();
938            let handles_before = decoder.remaining_handles();
939            if let Some((inlined, num_bytes, num_handles)) =
940                fidl::encoding::decode_envelope_header(decoder, next_offset)?
941            {
942                let member_inline_size = <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
943                if inlined != (member_inline_size <= 4) {
944                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
945                }
946                let inner_offset;
947                let mut inner_depth = depth.clone();
948                if inlined {
949                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
950                    inner_offset = next_offset;
951                } else {
952                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
953                    inner_depth.increment()?;
954                }
955                let val_ref = self.view_creation_token.get_or_insert_with(|| {
956                    fidl::new_empty!(
957                        fidl_fuchsia_ui_views::ViewCreationToken,
958                        fidl::encoding::DefaultFuchsiaResourceDialect
959                    )
960                });
961                fidl::decode!(
962                    fidl_fuchsia_ui_views::ViewCreationToken,
963                    fidl::encoding::DefaultFuchsiaResourceDialect,
964                    val_ref,
965                    decoder,
966                    inner_offset,
967                    inner_depth
968                )?;
969                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
970                {
971                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
972                }
973                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
974                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
975                }
976            }
977
978            next_offset += envelope_size;
979
980            // Decode the remaining unknown envelopes.
981            while next_offset < end_offset {
982                _next_ordinal_to_read += 1;
983                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
984                next_offset += envelope_size;
985            }
986
987            Ok(())
988        }
989    }
990}