Skip to main content

fidl_fuchsia_element/
fidl_fuchsia_element.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_element__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// A list of annotations on an element.
15pub type Annotations = Vec<Annotation>;
16
17/// An annotation defined dynamically by key/value pair.
18///
19/// The Session Framework does not constrain the contents of `key` and `value`
20/// in any way. Cooperating components that exchange annotations must define
21/// and validate annotation entries based on their own conventions.
22#[derive(Debug, PartialEq)]
23pub struct Annotation {
24    /// An identfier for this annotation.
25    pub key: AnnotationKey,
26    /// The content of this annotation.
27    pub value: AnnotationValue,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Annotation {}
31
32#[derive(Debug, PartialEq)]
33pub struct AnnotationControllerUpdateAnnotationsRequest {
34    pub annotations_to_set: Vec<Annotation>,
35    pub annotations_to_delete: Vec<AnnotationKey>,
36}
37
38impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
39    for AnnotationControllerUpdateAnnotationsRequest
40{
41}
42
43#[derive(Debug, PartialEq)]
44pub struct AnnotationControllerGetAnnotationsResponse {
45    pub annotations: Vec<Annotation>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
49    for AnnotationControllerGetAnnotationsResponse
50{
51}
52
53#[derive(Debug, PartialEq)]
54pub struct AnnotationControllerWatchAnnotationsResponse {
55    pub annotations: Vec<Annotation>,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
59    for AnnotationControllerWatchAnnotationsResponse
60{
61}
62
63#[derive(Debug, PartialEq)]
64pub struct GraphicalPresenterPresentViewRequest {
65    pub view_spec: ViewSpec,
66    pub annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
67    pub view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
71    for GraphicalPresenterPresentViewRequest
72{
73}
74
75#[derive(Debug, PartialEq)]
76pub struct ManagerProposeElementRequest {
77    pub spec: Spec,
78    pub controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
82    for ManagerProposeElementRequest
83{
84}
85
86/// Description of an element to be added to a session.
87#[derive(Debug, Default, PartialEq)]
88pub struct Spec {
89    /// The component URL of the element. Required.
90    pub component_url: Option<String>,
91    /// Initial annotations on the element. Required, but can be an empty vector. If the element
92    /// manager URL annotation is included (which is allowed, but not necessary), then it *must*
93    /// match `component_url`.
94    pub annotations: Option<Vec<Annotation>>,
95    #[doc(hidden)]
96    pub __source_breaking: fidl::marker::SourceBreaking,
97}
98
99impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Spec {}
100
101/// A description of a view that can be presented by a `GraphicalPresenter`.
102#[derive(Debug, Default, PartialEq)]
103pub struct ViewSpec {
104    /// The view holder token for the presented Gfx view. Must be unset for
105    /// Flatland views. One of `view_holder_token` or `viewport_creation_token`
106    /// must be set.
107    pub view_holder_token: Option<fidl_fuchsia_ui_views::ViewHolderToken>,
108    /// The `ViewRef` of the presented Gfx view. Must be unset for Flatland
109    /// views.
110    pub view_ref: Option<fidl_fuchsia_ui_views::ViewRef>,
111    /// The initial annotations associated with the presented view. Updates to
112    /// annotations are observed through the `AnnotationController` passed
113    /// to `PresentView()`.
114    ///
115    /// Optional.
116    pub annotations: Option<Vec<Annotation>>,
117    /// The viewport creation token for the presented Flatland view. Must be
118    /// unset for Gfx views. One of `view_holder_token` or `viewport_creation_token`
119    /// must be set.
120    pub viewport_creation_token: Option<fidl_fuchsia_ui_views::ViewportCreationToken>,
121    #[doc(hidden)]
122    pub __source_breaking: fidl::marker::SourceBreaking,
123}
124
125impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewSpec {}
126
127/// The value of an [`fuchsia.element/Annotation`].
128///
129/// The actual field used depends on the type of annotation.
130#[derive(Debug, PartialEq)]
131pub enum AnnotationValue {
132    Text(String),
133    Buffer(fidl_fuchsia_mem::Buffer),
134}
135
136impl AnnotationValue {
137    #[inline]
138    pub fn ordinal(&self) -> u64 {
139        match *self {
140            Self::Text(_) => 1,
141            Self::Buffer(_) => 2,
142        }
143    }
144}
145
146impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for AnnotationValue {}
147
148#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
149pub struct AnnotationControllerMarker;
150
151impl fidl::endpoints::ProtocolMarker for AnnotationControllerMarker {
152    type Proxy = AnnotationControllerProxy;
153    type RequestStream = AnnotationControllerRequestStream;
154    #[cfg(target_os = "fuchsia")]
155    type SynchronousProxy = AnnotationControllerSynchronousProxy;
156
157    const DEBUG_NAME: &'static str = "(anonymous) AnnotationController";
158}
159pub type AnnotationControllerUpdateAnnotationsResult = Result<(), UpdateAnnotationsError>;
160pub type AnnotationControllerGetAnnotationsResult = Result<Vec<Annotation>, GetAnnotationsError>;
161pub type AnnotationControllerWatchAnnotationsResult =
162    Result<Vec<Annotation>, WatchAnnotationsError>;
163
164pub trait AnnotationControllerProxyInterface: Send + Sync {
165    type UpdateAnnotationsResponseFut: std::future::Future<
166            Output = Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error>,
167        > + Send;
168    fn r#update_annotations(
169        &self,
170        annotations_to_set: Vec<Annotation>,
171        annotations_to_delete: &[AnnotationKey],
172    ) -> Self::UpdateAnnotationsResponseFut;
173    type GetAnnotationsResponseFut: std::future::Future<Output = Result<AnnotationControllerGetAnnotationsResult, fidl::Error>>
174        + Send;
175    fn r#get_annotations(&self) -> Self::GetAnnotationsResponseFut;
176    type WatchAnnotationsResponseFut: std::future::Future<
177            Output = Result<AnnotationControllerWatchAnnotationsResult, fidl::Error>,
178        > + Send;
179    fn r#watch_annotations(&self) -> Self::WatchAnnotationsResponseFut;
180}
181#[derive(Debug)]
182#[cfg(target_os = "fuchsia")]
183pub struct AnnotationControllerSynchronousProxy {
184    client: fidl::client::sync::Client,
185}
186
187#[cfg(target_os = "fuchsia")]
188impl fidl::endpoints::SynchronousProxy for AnnotationControllerSynchronousProxy {
189    type Proxy = AnnotationControllerProxy;
190    type Protocol = AnnotationControllerMarker;
191
192    fn from_channel(inner: fidl::Channel) -> Self {
193        Self::new(inner)
194    }
195
196    fn into_channel(self) -> fidl::Channel {
197        self.client.into_channel()
198    }
199
200    fn as_channel(&self) -> &fidl::Channel {
201        self.client.as_channel()
202    }
203}
204
205#[cfg(target_os = "fuchsia")]
206impl AnnotationControllerSynchronousProxy {
207    pub fn new(channel: fidl::Channel) -> Self {
208        Self { client: fidl::client::sync::Client::new(channel) }
209    }
210
211    pub fn into_channel(self) -> fidl::Channel {
212        self.client.into_channel()
213    }
214
215    /// Waits until an event arrives and returns it. It is safe for other
216    /// threads to make concurrent requests while waiting for an event.
217    pub fn wait_for_event(
218        &self,
219        deadline: zx::MonotonicInstant,
220    ) -> Result<AnnotationControllerEvent, fidl::Error> {
221        AnnotationControllerEvent::decode(
222            self.client.wait_for_event::<AnnotationControllerMarker>(deadline)?,
223        )
224    }
225
226    /// Adds, updates, and removes annotations.
227    ///
228    /// The server is expected to adhere to the following conventions:
229    ///
230    /// * If a key in `annotations_to_set` is new, a new annotation is added
231    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
232    /// * If a key in `annotations_to_delete` does not exist, it is ignored
233    ///
234    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
235    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
236    /// Annotation and also delete it.
237    ///
238    /// If the operation results in an error, the annotations remain unchanged,
239    /// and will not be partially updated.
240    ///
241    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
242    ///   both `annotations_to_set` and `annotations_to_delete`.
243    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
244    ///   `annotations_to_delete` has an empty namespace.
245    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
246    ///   `annotations_to_set` could not be read.
247    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
248    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
249    pub fn r#update_annotations(
250        &self,
251        mut annotations_to_set: Vec<Annotation>,
252        mut annotations_to_delete: &[AnnotationKey],
253        ___deadline: zx::MonotonicInstant,
254    ) -> Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error> {
255        let _response = self.client.send_query::<
256            AnnotationControllerUpdateAnnotationsRequest,
257            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, UpdateAnnotationsError>,
258            AnnotationControllerMarker,
259        >(
260            (annotations_to_set.as_mut(), annotations_to_delete,),
261            0x5718e51a2774c686,
262            fidl::encoding::DynamicFlags::empty(),
263            ___deadline,
264        )?;
265        Ok(_response.map(|x| x))
266    }
267
268    /// Returns the current `Annotations` for the element.
269    ///
270    /// * error `GetAnnotationsError` if the annotations could not be returned.
271    pub fn r#get_annotations(
272        &self,
273        ___deadline: zx::MonotonicInstant,
274    ) -> Result<AnnotationControllerGetAnnotationsResult, fidl::Error> {
275        let _response =
276            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
277                AnnotationControllerGetAnnotationsResponse,
278                GetAnnotationsError,
279            >, AnnotationControllerMarker>(
280                (),
281                0xae78b17381824fa,
282                fidl::encoding::DynamicFlags::empty(),
283                ___deadline,
284            )?;
285        Ok(_response.map(|x| x.annotations))
286    }
287
288    /// Returns the full set of `Annotations` when one or more of them have changed, or
289    /// when this method is called by the client for the first time.
290    ///
291    /// This operation does not block other requests from the client, but only one
292    /// `WatchAnnotations` request at a time can be made on a connection. If the
293    /// client makes a second `WatchAnnotations` request before waiting for the
294    /// previous request to complete, the connection will be closed.
295    ///
296    /// * error `WatchAnnotationsError` if the annotations could not be returned.
297    pub fn r#watch_annotations(
298        &self,
299        ___deadline: zx::MonotonicInstant,
300    ) -> Result<AnnotationControllerWatchAnnotationsResult, fidl::Error> {
301        let _response =
302            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
303                AnnotationControllerWatchAnnotationsResponse,
304                WatchAnnotationsError,
305            >, AnnotationControllerMarker>(
306                (),
307                0x253b196cae31356f,
308                fidl::encoding::DynamicFlags::empty(),
309                ___deadline,
310            )?;
311        Ok(_response.map(|x| x.annotations))
312    }
313}
314
315#[cfg(target_os = "fuchsia")]
316impl From<AnnotationControllerSynchronousProxy> for zx::NullableHandle {
317    fn from(value: AnnotationControllerSynchronousProxy) -> Self {
318        value.into_channel().into()
319    }
320}
321
322#[cfg(target_os = "fuchsia")]
323impl From<fidl::Channel> for AnnotationControllerSynchronousProxy {
324    fn from(value: fidl::Channel) -> Self {
325        Self::new(value)
326    }
327}
328
329#[cfg(target_os = "fuchsia")]
330impl fidl::endpoints::FromClient for AnnotationControllerSynchronousProxy {
331    type Protocol = AnnotationControllerMarker;
332
333    fn from_client(value: fidl::endpoints::ClientEnd<AnnotationControllerMarker>) -> Self {
334        Self::new(value.into_channel())
335    }
336}
337
338#[derive(Debug, Clone)]
339pub struct AnnotationControllerProxy {
340    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
341}
342
343impl fidl::endpoints::Proxy for AnnotationControllerProxy {
344    type Protocol = AnnotationControllerMarker;
345
346    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
347        Self::new(inner)
348    }
349
350    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
351        self.client.into_channel().map_err(|client| Self { client })
352    }
353
354    fn as_channel(&self) -> &::fidl::AsyncChannel {
355        self.client.as_channel()
356    }
357}
358
359impl AnnotationControllerProxy {
360    /// Create a new Proxy for fuchsia.element/AnnotationController.
361    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
362        let protocol_name =
363            <AnnotationControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
364        Self { client: fidl::client::Client::new(channel, protocol_name) }
365    }
366
367    /// Get a Stream of events from the remote end of the protocol.
368    ///
369    /// # Panics
370    ///
371    /// Panics if the event stream was already taken.
372    pub fn take_event_stream(&self) -> AnnotationControllerEventStream {
373        AnnotationControllerEventStream { event_receiver: self.client.take_event_receiver() }
374    }
375
376    /// Adds, updates, and removes annotations.
377    ///
378    /// The server is expected to adhere to the following conventions:
379    ///
380    /// * If a key in `annotations_to_set` is new, a new annotation is added
381    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
382    /// * If a key in `annotations_to_delete` does not exist, it is ignored
383    ///
384    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
385    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
386    /// Annotation and also delete it.
387    ///
388    /// If the operation results in an error, the annotations remain unchanged,
389    /// and will not be partially updated.
390    ///
391    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
392    ///   both `annotations_to_set` and `annotations_to_delete`.
393    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
394    ///   `annotations_to_delete` has an empty namespace.
395    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
396    ///   `annotations_to_set` could not be read.
397    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
398    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
399    pub fn r#update_annotations(
400        &self,
401        mut annotations_to_set: Vec<Annotation>,
402        mut annotations_to_delete: &[AnnotationKey],
403    ) -> fidl::client::QueryResponseFut<
404        AnnotationControllerUpdateAnnotationsResult,
405        fidl::encoding::DefaultFuchsiaResourceDialect,
406    > {
407        AnnotationControllerProxyInterface::r#update_annotations(
408            self,
409            annotations_to_set,
410            annotations_to_delete,
411        )
412    }
413
414    /// Returns the current `Annotations` for the element.
415    ///
416    /// * error `GetAnnotationsError` if the annotations could not be returned.
417    pub fn r#get_annotations(
418        &self,
419    ) -> fidl::client::QueryResponseFut<
420        AnnotationControllerGetAnnotationsResult,
421        fidl::encoding::DefaultFuchsiaResourceDialect,
422    > {
423        AnnotationControllerProxyInterface::r#get_annotations(self)
424    }
425
426    /// Returns the full set of `Annotations` when one or more of them have changed, or
427    /// when this method is called by the client for the first time.
428    ///
429    /// This operation does not block other requests from the client, but only one
430    /// `WatchAnnotations` request at a time can be made on a connection. If the
431    /// client makes a second `WatchAnnotations` request before waiting for the
432    /// previous request to complete, the connection will be closed.
433    ///
434    /// * error `WatchAnnotationsError` if the annotations could not be returned.
435    pub fn r#watch_annotations(
436        &self,
437    ) -> fidl::client::QueryResponseFut<
438        AnnotationControllerWatchAnnotationsResult,
439        fidl::encoding::DefaultFuchsiaResourceDialect,
440    > {
441        AnnotationControllerProxyInterface::r#watch_annotations(self)
442    }
443}
444
445impl AnnotationControllerProxyInterface for AnnotationControllerProxy {
446    type UpdateAnnotationsResponseFut = fidl::client::QueryResponseFut<
447        AnnotationControllerUpdateAnnotationsResult,
448        fidl::encoding::DefaultFuchsiaResourceDialect,
449    >;
450    fn r#update_annotations(
451        &self,
452        mut annotations_to_set: Vec<Annotation>,
453        mut annotations_to_delete: &[AnnotationKey],
454    ) -> Self::UpdateAnnotationsResponseFut {
455        fn _decode(
456            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
457        ) -> Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error> {
458            let _response = fidl::client::decode_transaction_body::<
459                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, UpdateAnnotationsError>,
460                fidl::encoding::DefaultFuchsiaResourceDialect,
461                0x5718e51a2774c686,
462            >(_buf?)?;
463            Ok(_response.map(|x| x))
464        }
465        self.client.send_query_and_decode::<
466            AnnotationControllerUpdateAnnotationsRequest,
467            AnnotationControllerUpdateAnnotationsResult,
468        >(
469            (annotations_to_set.as_mut(), annotations_to_delete,),
470            0x5718e51a2774c686,
471            fidl::encoding::DynamicFlags::empty(),
472            _decode,
473        )
474    }
475
476    type GetAnnotationsResponseFut = fidl::client::QueryResponseFut<
477        AnnotationControllerGetAnnotationsResult,
478        fidl::encoding::DefaultFuchsiaResourceDialect,
479    >;
480    fn r#get_annotations(&self) -> Self::GetAnnotationsResponseFut {
481        fn _decode(
482            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
483        ) -> Result<AnnotationControllerGetAnnotationsResult, fidl::Error> {
484            let _response = fidl::client::decode_transaction_body::<
485                fidl::encoding::ResultType<
486                    AnnotationControllerGetAnnotationsResponse,
487                    GetAnnotationsError,
488                >,
489                fidl::encoding::DefaultFuchsiaResourceDialect,
490                0xae78b17381824fa,
491            >(_buf?)?;
492            Ok(_response.map(|x| x.annotations))
493        }
494        self.client.send_query_and_decode::<
495            fidl::encoding::EmptyPayload,
496            AnnotationControllerGetAnnotationsResult,
497        >(
498            (),
499            0xae78b17381824fa,
500            fidl::encoding::DynamicFlags::empty(),
501            _decode,
502        )
503    }
504
505    type WatchAnnotationsResponseFut = fidl::client::QueryResponseFut<
506        AnnotationControllerWatchAnnotationsResult,
507        fidl::encoding::DefaultFuchsiaResourceDialect,
508    >;
509    fn r#watch_annotations(&self) -> Self::WatchAnnotationsResponseFut {
510        fn _decode(
511            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
512        ) -> Result<AnnotationControllerWatchAnnotationsResult, fidl::Error> {
513            let _response = fidl::client::decode_transaction_body::<
514                fidl::encoding::ResultType<
515                    AnnotationControllerWatchAnnotationsResponse,
516                    WatchAnnotationsError,
517                >,
518                fidl::encoding::DefaultFuchsiaResourceDialect,
519                0x253b196cae31356f,
520            >(_buf?)?;
521            Ok(_response.map(|x| x.annotations))
522        }
523        self.client.send_query_and_decode::<
524            fidl::encoding::EmptyPayload,
525            AnnotationControllerWatchAnnotationsResult,
526        >(
527            (),
528            0x253b196cae31356f,
529            fidl::encoding::DynamicFlags::empty(),
530            _decode,
531        )
532    }
533}
534
535pub struct AnnotationControllerEventStream {
536    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
537}
538
539impl std::marker::Unpin for AnnotationControllerEventStream {}
540
541impl futures::stream::FusedStream for AnnotationControllerEventStream {
542    fn is_terminated(&self) -> bool {
543        self.event_receiver.is_terminated()
544    }
545}
546
547impl futures::Stream for AnnotationControllerEventStream {
548    type Item = Result<AnnotationControllerEvent, fidl::Error>;
549
550    fn poll_next(
551        mut self: std::pin::Pin<&mut Self>,
552        cx: &mut std::task::Context<'_>,
553    ) -> std::task::Poll<Option<Self::Item>> {
554        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
555            &mut self.event_receiver,
556            cx
557        )?) {
558            Some(buf) => std::task::Poll::Ready(Some(AnnotationControllerEvent::decode(buf))),
559            None => std::task::Poll::Ready(None),
560        }
561    }
562}
563
564#[derive(Debug)]
565pub enum AnnotationControllerEvent {}
566
567impl AnnotationControllerEvent {
568    /// Decodes a message buffer as a [`AnnotationControllerEvent`].
569    fn decode(
570        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
571    ) -> Result<AnnotationControllerEvent, fidl::Error> {
572        let (bytes, _handles) = buf.split_mut();
573        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
574        debug_assert_eq!(tx_header.tx_id, 0);
575        match tx_header.ordinal {
576            _ => Err(fidl::Error::UnknownOrdinal {
577                ordinal: tx_header.ordinal,
578                protocol_name:
579                    <AnnotationControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
580            }),
581        }
582    }
583}
584
585/// A Stream of incoming requests for fuchsia.element/AnnotationController.
586pub struct AnnotationControllerRequestStream {
587    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
588    is_terminated: bool,
589}
590
591impl std::marker::Unpin for AnnotationControllerRequestStream {}
592
593impl futures::stream::FusedStream for AnnotationControllerRequestStream {
594    fn is_terminated(&self) -> bool {
595        self.is_terminated
596    }
597}
598
599impl fidl::endpoints::RequestStream for AnnotationControllerRequestStream {
600    type Protocol = AnnotationControllerMarker;
601    type ControlHandle = AnnotationControllerControlHandle;
602
603    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
604        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
605    }
606
607    fn control_handle(&self) -> Self::ControlHandle {
608        AnnotationControllerControlHandle { inner: self.inner.clone() }
609    }
610
611    fn into_inner(
612        self,
613    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
614    {
615        (self.inner, self.is_terminated)
616    }
617
618    fn from_inner(
619        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
620        is_terminated: bool,
621    ) -> Self {
622        Self { inner, is_terminated }
623    }
624}
625
626impl futures::Stream for AnnotationControllerRequestStream {
627    type Item = Result<AnnotationControllerRequest, fidl::Error>;
628
629    fn poll_next(
630        mut self: std::pin::Pin<&mut Self>,
631        cx: &mut std::task::Context<'_>,
632    ) -> std::task::Poll<Option<Self::Item>> {
633        let this = &mut *self;
634        if this.inner.check_shutdown(cx) {
635            this.is_terminated = true;
636            return std::task::Poll::Ready(None);
637        }
638        if this.is_terminated {
639            panic!("polled AnnotationControllerRequestStream after completion");
640        }
641        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
642            |bytes, handles| {
643                match this.inner.channel().read_etc(cx, bytes, handles) {
644                    std::task::Poll::Ready(Ok(())) => {}
645                    std::task::Poll::Pending => return std::task::Poll::Pending,
646                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
647                        this.is_terminated = true;
648                        return std::task::Poll::Ready(None);
649                    }
650                    std::task::Poll::Ready(Err(e)) => {
651                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
652                            e.into(),
653                        ))));
654                    }
655                }
656
657                // A message has been received from the channel
658                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
659
660                std::task::Poll::Ready(Some(match header.ordinal {
661                0x5718e51a2774c686 => {
662                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
663                    let mut req = fidl::new_empty!(AnnotationControllerUpdateAnnotationsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
664                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AnnotationControllerUpdateAnnotationsRequest>(&header, _body_bytes, handles, &mut req)?;
665                    let control_handle = AnnotationControllerControlHandle {
666                        inner: this.inner.clone(),
667                    };
668                    Ok(AnnotationControllerRequest::UpdateAnnotations {annotations_to_set: req.annotations_to_set,
669annotations_to_delete: req.annotations_to_delete,
670
671                        responder: AnnotationControllerUpdateAnnotationsResponder {
672                            control_handle: std::mem::ManuallyDrop::new(control_handle),
673                            tx_id: header.tx_id,
674                        },
675                    })
676                }
677                0xae78b17381824fa => {
678                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
679                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
680                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
681                    let control_handle = AnnotationControllerControlHandle {
682                        inner: this.inner.clone(),
683                    };
684                    Ok(AnnotationControllerRequest::GetAnnotations {
685                        responder: AnnotationControllerGetAnnotationsResponder {
686                            control_handle: std::mem::ManuallyDrop::new(control_handle),
687                            tx_id: header.tx_id,
688                        },
689                    })
690                }
691                0x253b196cae31356f => {
692                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
693                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
694                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
695                    let control_handle = AnnotationControllerControlHandle {
696                        inner: this.inner.clone(),
697                    };
698                    Ok(AnnotationControllerRequest::WatchAnnotations {
699                        responder: AnnotationControllerWatchAnnotationsResponder {
700                            control_handle: std::mem::ManuallyDrop::new(control_handle),
701                            tx_id: header.tx_id,
702                        },
703                    })
704                }
705                _ => Err(fidl::Error::UnknownOrdinal {
706                    ordinal: header.ordinal,
707                    protocol_name: <AnnotationControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
708                }),
709            }))
710            },
711        )
712    }
713}
714
715/// An interface to create, read, update, and delete annotations,
716/// typically on an element or its view.
717#[derive(Debug)]
718pub enum AnnotationControllerRequest {
719    /// Adds, updates, and removes annotations.
720    ///
721    /// The server is expected to adhere to the following conventions:
722    ///
723    /// * If a key in `annotations_to_set` is new, a new annotation is added
724    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
725    /// * If a key in `annotations_to_delete` does not exist, it is ignored
726    ///
727    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
728    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
729    /// Annotation and also delete it.
730    ///
731    /// If the operation results in an error, the annotations remain unchanged,
732    /// and will not be partially updated.
733    ///
734    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
735    ///   both `annotations_to_set` and `annotations_to_delete`.
736    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
737    ///   `annotations_to_delete` has an empty namespace.
738    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
739    ///   `annotations_to_set` could not be read.
740    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
741    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
742    UpdateAnnotations {
743        annotations_to_set: Vec<Annotation>,
744        annotations_to_delete: Vec<AnnotationKey>,
745        responder: AnnotationControllerUpdateAnnotationsResponder,
746    },
747    /// Returns the current `Annotations` for the element.
748    ///
749    /// * error `GetAnnotationsError` if the annotations could not be returned.
750    GetAnnotations { responder: AnnotationControllerGetAnnotationsResponder },
751    /// Returns the full set of `Annotations` when one or more of them have changed, or
752    /// when this method is called by the client for the first time.
753    ///
754    /// This operation does not block other requests from the client, but only one
755    /// `WatchAnnotations` request at a time can be made on a connection. If the
756    /// client makes a second `WatchAnnotations` request before waiting for the
757    /// previous request to complete, the connection will be closed.
758    ///
759    /// * error `WatchAnnotationsError` if the annotations could not be returned.
760    WatchAnnotations { responder: AnnotationControllerWatchAnnotationsResponder },
761}
762
763impl AnnotationControllerRequest {
764    #[allow(irrefutable_let_patterns)]
765    pub fn into_update_annotations(
766        self,
767    ) -> Option<(Vec<Annotation>, Vec<AnnotationKey>, AnnotationControllerUpdateAnnotationsResponder)>
768    {
769        if let AnnotationControllerRequest::UpdateAnnotations {
770            annotations_to_set,
771            annotations_to_delete,
772            responder,
773        } = self
774        {
775            Some((annotations_to_set, annotations_to_delete, responder))
776        } else {
777            None
778        }
779    }
780
781    #[allow(irrefutable_let_patterns)]
782    pub fn into_get_annotations(self) -> Option<(AnnotationControllerGetAnnotationsResponder)> {
783        if let AnnotationControllerRequest::GetAnnotations { responder } = self {
784            Some((responder))
785        } else {
786            None
787        }
788    }
789
790    #[allow(irrefutable_let_patterns)]
791    pub fn into_watch_annotations(self) -> Option<(AnnotationControllerWatchAnnotationsResponder)> {
792        if let AnnotationControllerRequest::WatchAnnotations { responder } = self {
793            Some((responder))
794        } else {
795            None
796        }
797    }
798
799    /// Name of the method defined in FIDL
800    pub fn method_name(&self) -> &'static str {
801        match *self {
802            AnnotationControllerRequest::UpdateAnnotations { .. } => "update_annotations",
803            AnnotationControllerRequest::GetAnnotations { .. } => "get_annotations",
804            AnnotationControllerRequest::WatchAnnotations { .. } => "watch_annotations",
805        }
806    }
807}
808
809#[derive(Debug, Clone)]
810pub struct AnnotationControllerControlHandle {
811    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
812}
813
814impl fidl::endpoints::ControlHandle for AnnotationControllerControlHandle {
815    fn shutdown(&self) {
816        self.inner.shutdown()
817    }
818
819    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
820        self.inner.shutdown_with_epitaph(status)
821    }
822
823    fn is_closed(&self) -> bool {
824        self.inner.channel().is_closed()
825    }
826    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
827        self.inner.channel().on_closed()
828    }
829
830    #[cfg(target_os = "fuchsia")]
831    fn signal_peer(
832        &self,
833        clear_mask: zx::Signals,
834        set_mask: zx::Signals,
835    ) -> Result<(), zx_status::Status> {
836        use fidl::Peered;
837        self.inner.channel().signal_peer(clear_mask, set_mask)
838    }
839}
840
841impl AnnotationControllerControlHandle {}
842
843#[must_use = "FIDL methods require a response to be sent"]
844#[derive(Debug)]
845pub struct AnnotationControllerUpdateAnnotationsResponder {
846    control_handle: std::mem::ManuallyDrop<AnnotationControllerControlHandle>,
847    tx_id: u32,
848}
849
850/// Set the the channel to be shutdown (see [`AnnotationControllerControlHandle::shutdown`])
851/// if the responder is dropped without sending a response, so that the client
852/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
853impl std::ops::Drop for AnnotationControllerUpdateAnnotationsResponder {
854    fn drop(&mut self) {
855        self.control_handle.shutdown();
856        // Safety: drops once, never accessed again
857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
858    }
859}
860
861impl fidl::endpoints::Responder for AnnotationControllerUpdateAnnotationsResponder {
862    type ControlHandle = AnnotationControllerControlHandle;
863
864    fn control_handle(&self) -> &AnnotationControllerControlHandle {
865        &self.control_handle
866    }
867
868    fn drop_without_shutdown(mut self) {
869        // Safety: drops once, never accessed again due to mem::forget
870        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
871        // Prevent Drop from running (which would shut down the channel)
872        std::mem::forget(self);
873    }
874}
875
876impl AnnotationControllerUpdateAnnotationsResponder {
877    /// Sends a response to the FIDL transaction.
878    ///
879    /// Sets the channel to shutdown if an error occurs.
880    pub fn send(self, mut result: Result<(), UpdateAnnotationsError>) -> Result<(), fidl::Error> {
881        let _result = self.send_raw(result);
882        if _result.is_err() {
883            self.control_handle.shutdown();
884        }
885        self.drop_without_shutdown();
886        _result
887    }
888
889    /// Similar to "send" but does not shutdown the channel if an error occurs.
890    pub fn send_no_shutdown_on_err(
891        self,
892        mut result: Result<(), UpdateAnnotationsError>,
893    ) -> Result<(), fidl::Error> {
894        let _result = self.send_raw(result);
895        self.drop_without_shutdown();
896        _result
897    }
898
899    fn send_raw(&self, mut result: Result<(), UpdateAnnotationsError>) -> Result<(), fidl::Error> {
900        self.control_handle.inner.send::<fidl::encoding::ResultType<
901            fidl::encoding::EmptyStruct,
902            UpdateAnnotationsError,
903        >>(
904            result,
905            self.tx_id,
906            0x5718e51a2774c686,
907            fidl::encoding::DynamicFlags::empty(),
908        )
909    }
910}
911
912#[must_use = "FIDL methods require a response to be sent"]
913#[derive(Debug)]
914pub struct AnnotationControllerGetAnnotationsResponder {
915    control_handle: std::mem::ManuallyDrop<AnnotationControllerControlHandle>,
916    tx_id: u32,
917}
918
919/// Set the the channel to be shutdown (see [`AnnotationControllerControlHandle::shutdown`])
920/// if the responder is dropped without sending a response, so that the client
921/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
922impl std::ops::Drop for AnnotationControllerGetAnnotationsResponder {
923    fn drop(&mut self) {
924        self.control_handle.shutdown();
925        // Safety: drops once, never accessed again
926        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
927    }
928}
929
930impl fidl::endpoints::Responder for AnnotationControllerGetAnnotationsResponder {
931    type ControlHandle = AnnotationControllerControlHandle;
932
933    fn control_handle(&self) -> &AnnotationControllerControlHandle {
934        &self.control_handle
935    }
936
937    fn drop_without_shutdown(mut self) {
938        // Safety: drops once, never accessed again due to mem::forget
939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
940        // Prevent Drop from running (which would shut down the channel)
941        std::mem::forget(self);
942    }
943}
944
945impl AnnotationControllerGetAnnotationsResponder {
946    /// Sends a response to the FIDL transaction.
947    ///
948    /// Sets the channel to shutdown if an error occurs.
949    pub fn send(
950        self,
951        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
952    ) -> Result<(), fidl::Error> {
953        let _result = self.send_raw(result);
954        if _result.is_err() {
955            self.control_handle.shutdown();
956        }
957        self.drop_without_shutdown();
958        _result
959    }
960
961    /// Similar to "send" but does not shutdown the channel if an error occurs.
962    pub fn send_no_shutdown_on_err(
963        self,
964        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
965    ) -> Result<(), fidl::Error> {
966        let _result = self.send_raw(result);
967        self.drop_without_shutdown();
968        _result
969    }
970
971    fn send_raw(
972        &self,
973        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
974    ) -> Result<(), fidl::Error> {
975        self.control_handle.inner.send::<fidl::encoding::ResultType<
976            AnnotationControllerGetAnnotationsResponse,
977            GetAnnotationsError,
978        >>(
979            result.as_mut().map_err(|e| *e).map(|annotations| (annotations.as_mut_slice(),)),
980            self.tx_id,
981            0xae78b17381824fa,
982            fidl::encoding::DynamicFlags::empty(),
983        )
984    }
985}
986
987#[must_use = "FIDL methods require a response to be sent"]
988#[derive(Debug)]
989pub struct AnnotationControllerWatchAnnotationsResponder {
990    control_handle: std::mem::ManuallyDrop<AnnotationControllerControlHandle>,
991    tx_id: u32,
992}
993
994/// Set the the channel to be shutdown (see [`AnnotationControllerControlHandle::shutdown`])
995/// if the responder is dropped without sending a response, so that the client
996/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
997impl std::ops::Drop for AnnotationControllerWatchAnnotationsResponder {
998    fn drop(&mut self) {
999        self.control_handle.shutdown();
1000        // Safety: drops once, never accessed again
1001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1002    }
1003}
1004
1005impl fidl::endpoints::Responder for AnnotationControllerWatchAnnotationsResponder {
1006    type ControlHandle = AnnotationControllerControlHandle;
1007
1008    fn control_handle(&self) -> &AnnotationControllerControlHandle {
1009        &self.control_handle
1010    }
1011
1012    fn drop_without_shutdown(mut self) {
1013        // Safety: drops once, never accessed again due to mem::forget
1014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1015        // Prevent Drop from running (which would shut down the channel)
1016        std::mem::forget(self);
1017    }
1018}
1019
1020impl AnnotationControllerWatchAnnotationsResponder {
1021    /// Sends a response to the FIDL transaction.
1022    ///
1023    /// Sets the channel to shutdown if an error occurs.
1024    pub fn send(
1025        self,
1026        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1027    ) -> Result<(), fidl::Error> {
1028        let _result = self.send_raw(result);
1029        if _result.is_err() {
1030            self.control_handle.shutdown();
1031        }
1032        self.drop_without_shutdown();
1033        _result
1034    }
1035
1036    /// Similar to "send" but does not shutdown the channel if an error occurs.
1037    pub fn send_no_shutdown_on_err(
1038        self,
1039        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1040    ) -> Result<(), fidl::Error> {
1041        let _result = self.send_raw(result);
1042        self.drop_without_shutdown();
1043        _result
1044    }
1045
1046    fn send_raw(
1047        &self,
1048        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1049    ) -> Result<(), fidl::Error> {
1050        self.control_handle.inner.send::<fidl::encoding::ResultType<
1051            AnnotationControllerWatchAnnotationsResponse,
1052            WatchAnnotationsError,
1053        >>(
1054            result.as_mut().map_err(|e| *e).map(|annotations| (annotations.as_mut_slice(),)),
1055            self.tx_id,
1056            0x253b196cae31356f,
1057            fidl::encoding::DynamicFlags::empty(),
1058        )
1059    }
1060}
1061
1062#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1063pub struct ControllerMarker;
1064
1065impl fidl::endpoints::ProtocolMarker for ControllerMarker {
1066    type Proxy = ControllerProxy;
1067    type RequestStream = ControllerRequestStream;
1068    #[cfg(target_os = "fuchsia")]
1069    type SynchronousProxy = ControllerSynchronousProxy;
1070
1071    const DEBUG_NAME: &'static str = "(anonymous) Controller";
1072}
1073
1074pub trait ControllerProxyInterface: Send + Sync {
1075    type UpdateAnnotationsResponseFut: std::future::Future<
1076            Output = Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error>,
1077        > + Send;
1078    fn r#update_annotations(
1079        &self,
1080        annotations_to_set: Vec<Annotation>,
1081        annotations_to_delete: &[AnnotationKey],
1082    ) -> Self::UpdateAnnotationsResponseFut;
1083    type GetAnnotationsResponseFut: std::future::Future<Output = Result<AnnotationControllerGetAnnotationsResult, fidl::Error>>
1084        + Send;
1085    fn r#get_annotations(&self) -> Self::GetAnnotationsResponseFut;
1086    type WatchAnnotationsResponseFut: std::future::Future<
1087            Output = Result<AnnotationControllerWatchAnnotationsResult, fidl::Error>,
1088        > + Send;
1089    fn r#watch_annotations(&self) -> Self::WatchAnnotationsResponseFut;
1090}
1091#[derive(Debug)]
1092#[cfg(target_os = "fuchsia")]
1093pub struct ControllerSynchronousProxy {
1094    client: fidl::client::sync::Client,
1095}
1096
1097#[cfg(target_os = "fuchsia")]
1098impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
1099    type Proxy = ControllerProxy;
1100    type Protocol = ControllerMarker;
1101
1102    fn from_channel(inner: fidl::Channel) -> Self {
1103        Self::new(inner)
1104    }
1105
1106    fn into_channel(self) -> fidl::Channel {
1107        self.client.into_channel()
1108    }
1109
1110    fn as_channel(&self) -> &fidl::Channel {
1111        self.client.as_channel()
1112    }
1113}
1114
1115#[cfg(target_os = "fuchsia")]
1116impl ControllerSynchronousProxy {
1117    pub fn new(channel: fidl::Channel) -> Self {
1118        Self { client: fidl::client::sync::Client::new(channel) }
1119    }
1120
1121    pub fn into_channel(self) -> fidl::Channel {
1122        self.client.into_channel()
1123    }
1124
1125    /// Waits until an event arrives and returns it. It is safe for other
1126    /// threads to make concurrent requests while waiting for an event.
1127    pub fn wait_for_event(
1128        &self,
1129        deadline: zx::MonotonicInstant,
1130    ) -> Result<ControllerEvent, fidl::Error> {
1131        ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
1132    }
1133
1134    /// Adds, updates, and removes annotations.
1135    ///
1136    /// The server is expected to adhere to the following conventions:
1137    ///
1138    /// * If a key in `annotations_to_set` is new, a new annotation is added
1139    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
1140    /// * If a key in `annotations_to_delete` does not exist, it is ignored
1141    ///
1142    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
1143    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
1144    /// Annotation and also delete it.
1145    ///
1146    /// If the operation results in an error, the annotations remain unchanged,
1147    /// and will not be partially updated.
1148    ///
1149    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
1150    ///   both `annotations_to_set` and `annotations_to_delete`.
1151    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
1152    ///   `annotations_to_delete` has an empty namespace.
1153    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
1154    ///   `annotations_to_set` could not be read.
1155    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
1156    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
1157    pub fn r#update_annotations(
1158        &self,
1159        mut annotations_to_set: Vec<Annotation>,
1160        mut annotations_to_delete: &[AnnotationKey],
1161        ___deadline: zx::MonotonicInstant,
1162    ) -> Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error> {
1163        let _response = self.client.send_query::<
1164            AnnotationControllerUpdateAnnotationsRequest,
1165            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, UpdateAnnotationsError>,
1166            ControllerMarker,
1167        >(
1168            (annotations_to_set.as_mut(), annotations_to_delete,),
1169            0x5718e51a2774c686,
1170            fidl::encoding::DynamicFlags::empty(),
1171            ___deadline,
1172        )?;
1173        Ok(_response.map(|x| x))
1174    }
1175
1176    /// Returns the current `Annotations` for the element.
1177    ///
1178    /// * error `GetAnnotationsError` if the annotations could not be returned.
1179    pub fn r#get_annotations(
1180        &self,
1181        ___deadline: zx::MonotonicInstant,
1182    ) -> Result<AnnotationControllerGetAnnotationsResult, fidl::Error> {
1183        let _response =
1184            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1185                AnnotationControllerGetAnnotationsResponse,
1186                GetAnnotationsError,
1187            >, ControllerMarker>(
1188                (),
1189                0xae78b17381824fa,
1190                fidl::encoding::DynamicFlags::empty(),
1191                ___deadline,
1192            )?;
1193        Ok(_response.map(|x| x.annotations))
1194    }
1195
1196    /// Returns the full set of `Annotations` when one or more of them have changed, or
1197    /// when this method is called by the client for the first time.
1198    ///
1199    /// This operation does not block other requests from the client, but only one
1200    /// `WatchAnnotations` request at a time can be made on a connection. If the
1201    /// client makes a second `WatchAnnotations` request before waiting for the
1202    /// previous request to complete, the connection will be closed.
1203    ///
1204    /// * error `WatchAnnotationsError` if the annotations could not be returned.
1205    pub fn r#watch_annotations(
1206        &self,
1207        ___deadline: zx::MonotonicInstant,
1208    ) -> Result<AnnotationControllerWatchAnnotationsResult, fidl::Error> {
1209        let _response =
1210            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1211                AnnotationControllerWatchAnnotationsResponse,
1212                WatchAnnotationsError,
1213            >, ControllerMarker>(
1214                (),
1215                0x253b196cae31356f,
1216                fidl::encoding::DynamicFlags::empty(),
1217                ___deadline,
1218            )?;
1219        Ok(_response.map(|x| x.annotations))
1220    }
1221}
1222
1223#[cfg(target_os = "fuchsia")]
1224impl From<ControllerSynchronousProxy> for zx::NullableHandle {
1225    fn from(value: ControllerSynchronousProxy) -> Self {
1226        value.into_channel().into()
1227    }
1228}
1229
1230#[cfg(target_os = "fuchsia")]
1231impl From<fidl::Channel> for ControllerSynchronousProxy {
1232    fn from(value: fidl::Channel) -> Self {
1233        Self::new(value)
1234    }
1235}
1236
1237#[cfg(target_os = "fuchsia")]
1238impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
1239    type Protocol = ControllerMarker;
1240
1241    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
1242        Self::new(value.into_channel())
1243    }
1244}
1245
1246#[derive(Debug, Clone)]
1247pub struct ControllerProxy {
1248    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1249}
1250
1251impl fidl::endpoints::Proxy for ControllerProxy {
1252    type Protocol = ControllerMarker;
1253
1254    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1255        Self::new(inner)
1256    }
1257
1258    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1259        self.client.into_channel().map_err(|client| Self { client })
1260    }
1261
1262    fn as_channel(&self) -> &::fidl::AsyncChannel {
1263        self.client.as_channel()
1264    }
1265}
1266
1267impl ControllerProxy {
1268    /// Create a new Proxy for fuchsia.element/Controller.
1269    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1270        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1271        Self { client: fidl::client::Client::new(channel, protocol_name) }
1272    }
1273
1274    /// Get a Stream of events from the remote end of the protocol.
1275    ///
1276    /// # Panics
1277    ///
1278    /// Panics if the event stream was already taken.
1279    pub fn take_event_stream(&self) -> ControllerEventStream {
1280        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
1281    }
1282
1283    /// Adds, updates, and removes annotations.
1284    ///
1285    /// The server is expected to adhere to the following conventions:
1286    ///
1287    /// * If a key in `annotations_to_set` is new, a new annotation is added
1288    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
1289    /// * If a key in `annotations_to_delete` does not exist, it is ignored
1290    ///
1291    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
1292    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
1293    /// Annotation and also delete it.
1294    ///
1295    /// If the operation results in an error, the annotations remain unchanged,
1296    /// and will not be partially updated.
1297    ///
1298    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
1299    ///   both `annotations_to_set` and `annotations_to_delete`.
1300    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
1301    ///   `annotations_to_delete` has an empty namespace.
1302    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
1303    ///   `annotations_to_set` could not be read.
1304    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
1305    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
1306    pub fn r#update_annotations(
1307        &self,
1308        mut annotations_to_set: Vec<Annotation>,
1309        mut annotations_to_delete: &[AnnotationKey],
1310    ) -> fidl::client::QueryResponseFut<
1311        AnnotationControllerUpdateAnnotationsResult,
1312        fidl::encoding::DefaultFuchsiaResourceDialect,
1313    > {
1314        ControllerProxyInterface::r#update_annotations(
1315            self,
1316            annotations_to_set,
1317            annotations_to_delete,
1318        )
1319    }
1320
1321    /// Returns the current `Annotations` for the element.
1322    ///
1323    /// * error `GetAnnotationsError` if the annotations could not be returned.
1324    pub fn r#get_annotations(
1325        &self,
1326    ) -> fidl::client::QueryResponseFut<
1327        AnnotationControllerGetAnnotationsResult,
1328        fidl::encoding::DefaultFuchsiaResourceDialect,
1329    > {
1330        ControllerProxyInterface::r#get_annotations(self)
1331    }
1332
1333    /// Returns the full set of `Annotations` when one or more of them have changed, or
1334    /// when this method is called by the client for the first time.
1335    ///
1336    /// This operation does not block other requests from the client, but only one
1337    /// `WatchAnnotations` request at a time can be made on a connection. If the
1338    /// client makes a second `WatchAnnotations` request before waiting for the
1339    /// previous request to complete, the connection will be closed.
1340    ///
1341    /// * error `WatchAnnotationsError` if the annotations could not be returned.
1342    pub fn r#watch_annotations(
1343        &self,
1344    ) -> fidl::client::QueryResponseFut<
1345        AnnotationControllerWatchAnnotationsResult,
1346        fidl::encoding::DefaultFuchsiaResourceDialect,
1347    > {
1348        ControllerProxyInterface::r#watch_annotations(self)
1349    }
1350}
1351
1352impl ControllerProxyInterface for ControllerProxy {
1353    type UpdateAnnotationsResponseFut = fidl::client::QueryResponseFut<
1354        AnnotationControllerUpdateAnnotationsResult,
1355        fidl::encoding::DefaultFuchsiaResourceDialect,
1356    >;
1357    fn r#update_annotations(
1358        &self,
1359        mut annotations_to_set: Vec<Annotation>,
1360        mut annotations_to_delete: &[AnnotationKey],
1361    ) -> Self::UpdateAnnotationsResponseFut {
1362        fn _decode(
1363            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1364        ) -> Result<AnnotationControllerUpdateAnnotationsResult, fidl::Error> {
1365            let _response = fidl::client::decode_transaction_body::<
1366                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, UpdateAnnotationsError>,
1367                fidl::encoding::DefaultFuchsiaResourceDialect,
1368                0x5718e51a2774c686,
1369            >(_buf?)?;
1370            Ok(_response.map(|x| x))
1371        }
1372        self.client.send_query_and_decode::<
1373            AnnotationControllerUpdateAnnotationsRequest,
1374            AnnotationControllerUpdateAnnotationsResult,
1375        >(
1376            (annotations_to_set.as_mut(), annotations_to_delete,),
1377            0x5718e51a2774c686,
1378            fidl::encoding::DynamicFlags::empty(),
1379            _decode,
1380        )
1381    }
1382
1383    type GetAnnotationsResponseFut = fidl::client::QueryResponseFut<
1384        AnnotationControllerGetAnnotationsResult,
1385        fidl::encoding::DefaultFuchsiaResourceDialect,
1386    >;
1387    fn r#get_annotations(&self) -> Self::GetAnnotationsResponseFut {
1388        fn _decode(
1389            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1390        ) -> Result<AnnotationControllerGetAnnotationsResult, fidl::Error> {
1391            let _response = fidl::client::decode_transaction_body::<
1392                fidl::encoding::ResultType<
1393                    AnnotationControllerGetAnnotationsResponse,
1394                    GetAnnotationsError,
1395                >,
1396                fidl::encoding::DefaultFuchsiaResourceDialect,
1397                0xae78b17381824fa,
1398            >(_buf?)?;
1399            Ok(_response.map(|x| x.annotations))
1400        }
1401        self.client.send_query_and_decode::<
1402            fidl::encoding::EmptyPayload,
1403            AnnotationControllerGetAnnotationsResult,
1404        >(
1405            (),
1406            0xae78b17381824fa,
1407            fidl::encoding::DynamicFlags::empty(),
1408            _decode,
1409        )
1410    }
1411
1412    type WatchAnnotationsResponseFut = fidl::client::QueryResponseFut<
1413        AnnotationControllerWatchAnnotationsResult,
1414        fidl::encoding::DefaultFuchsiaResourceDialect,
1415    >;
1416    fn r#watch_annotations(&self) -> Self::WatchAnnotationsResponseFut {
1417        fn _decode(
1418            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1419        ) -> Result<AnnotationControllerWatchAnnotationsResult, fidl::Error> {
1420            let _response = fidl::client::decode_transaction_body::<
1421                fidl::encoding::ResultType<
1422                    AnnotationControllerWatchAnnotationsResponse,
1423                    WatchAnnotationsError,
1424                >,
1425                fidl::encoding::DefaultFuchsiaResourceDialect,
1426                0x253b196cae31356f,
1427            >(_buf?)?;
1428            Ok(_response.map(|x| x.annotations))
1429        }
1430        self.client.send_query_and_decode::<
1431            fidl::encoding::EmptyPayload,
1432            AnnotationControllerWatchAnnotationsResult,
1433        >(
1434            (),
1435            0x253b196cae31356f,
1436            fidl::encoding::DynamicFlags::empty(),
1437            _decode,
1438        )
1439    }
1440}
1441
1442pub struct ControllerEventStream {
1443    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1444}
1445
1446impl std::marker::Unpin for ControllerEventStream {}
1447
1448impl futures::stream::FusedStream for ControllerEventStream {
1449    fn is_terminated(&self) -> bool {
1450        self.event_receiver.is_terminated()
1451    }
1452}
1453
1454impl futures::Stream for ControllerEventStream {
1455    type Item = Result<ControllerEvent, fidl::Error>;
1456
1457    fn poll_next(
1458        mut self: std::pin::Pin<&mut Self>,
1459        cx: &mut std::task::Context<'_>,
1460    ) -> std::task::Poll<Option<Self::Item>> {
1461        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1462            &mut self.event_receiver,
1463            cx
1464        )?) {
1465            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
1466            None => std::task::Poll::Ready(None),
1467        }
1468    }
1469}
1470
1471#[derive(Debug)]
1472pub enum ControllerEvent {}
1473
1474impl ControllerEvent {
1475    /// Decodes a message buffer as a [`ControllerEvent`].
1476    fn decode(
1477        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1478    ) -> Result<ControllerEvent, fidl::Error> {
1479        let (bytes, _handles) = buf.split_mut();
1480        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1481        debug_assert_eq!(tx_header.tx_id, 0);
1482        match tx_header.ordinal {
1483            _ => Err(fidl::Error::UnknownOrdinal {
1484                ordinal: tx_header.ordinal,
1485                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1486            }),
1487        }
1488    }
1489}
1490
1491/// A Stream of incoming requests for fuchsia.element/Controller.
1492pub struct ControllerRequestStream {
1493    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1494    is_terminated: bool,
1495}
1496
1497impl std::marker::Unpin for ControllerRequestStream {}
1498
1499impl futures::stream::FusedStream for ControllerRequestStream {
1500    fn is_terminated(&self) -> bool {
1501        self.is_terminated
1502    }
1503}
1504
1505impl fidl::endpoints::RequestStream for ControllerRequestStream {
1506    type Protocol = ControllerMarker;
1507    type ControlHandle = ControllerControlHandle;
1508
1509    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1510        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1511    }
1512
1513    fn control_handle(&self) -> Self::ControlHandle {
1514        ControllerControlHandle { inner: self.inner.clone() }
1515    }
1516
1517    fn into_inner(
1518        self,
1519    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1520    {
1521        (self.inner, self.is_terminated)
1522    }
1523
1524    fn from_inner(
1525        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1526        is_terminated: bool,
1527    ) -> Self {
1528        Self { inner, is_terminated }
1529    }
1530}
1531
1532impl futures::Stream for ControllerRequestStream {
1533    type Item = Result<ControllerRequest, fidl::Error>;
1534
1535    fn poll_next(
1536        mut self: std::pin::Pin<&mut Self>,
1537        cx: &mut std::task::Context<'_>,
1538    ) -> std::task::Poll<Option<Self::Item>> {
1539        let this = &mut *self;
1540        if this.inner.check_shutdown(cx) {
1541            this.is_terminated = true;
1542            return std::task::Poll::Ready(None);
1543        }
1544        if this.is_terminated {
1545            panic!("polled ControllerRequestStream after completion");
1546        }
1547        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1548            |bytes, handles| {
1549                match this.inner.channel().read_etc(cx, bytes, handles) {
1550                    std::task::Poll::Ready(Ok(())) => {}
1551                    std::task::Poll::Pending => return std::task::Poll::Pending,
1552                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1553                        this.is_terminated = true;
1554                        return std::task::Poll::Ready(None);
1555                    }
1556                    std::task::Poll::Ready(Err(e)) => {
1557                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1558                            e.into(),
1559                        ))));
1560                    }
1561                }
1562
1563                // A message has been received from the channel
1564                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1565
1566                std::task::Poll::Ready(Some(match header.ordinal {
1567                    0x5718e51a2774c686 => {
1568                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1569                        let mut req = fidl::new_empty!(
1570                            AnnotationControllerUpdateAnnotationsRequest,
1571                            fidl::encoding::DefaultFuchsiaResourceDialect
1572                        );
1573                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AnnotationControllerUpdateAnnotationsRequest>(&header, _body_bytes, handles, &mut req)?;
1574                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
1575                        Ok(ControllerRequest::UpdateAnnotations {
1576                            annotations_to_set: req.annotations_to_set,
1577                            annotations_to_delete: req.annotations_to_delete,
1578
1579                            responder: ControllerUpdateAnnotationsResponder {
1580                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1581                                tx_id: header.tx_id,
1582                            },
1583                        })
1584                    }
1585                    0xae78b17381824fa => {
1586                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1587                        let mut req = fidl::new_empty!(
1588                            fidl::encoding::EmptyPayload,
1589                            fidl::encoding::DefaultFuchsiaResourceDialect
1590                        );
1591                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1592                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
1593                        Ok(ControllerRequest::GetAnnotations {
1594                            responder: ControllerGetAnnotationsResponder {
1595                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1596                                tx_id: header.tx_id,
1597                            },
1598                        })
1599                    }
1600                    0x253b196cae31356f => {
1601                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1602                        let mut req = fidl::new_empty!(
1603                            fidl::encoding::EmptyPayload,
1604                            fidl::encoding::DefaultFuchsiaResourceDialect
1605                        );
1606                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1607                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
1608                        Ok(ControllerRequest::WatchAnnotations {
1609                            responder: ControllerWatchAnnotationsResponder {
1610                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1611                                tx_id: header.tx_id,
1612                            },
1613                        })
1614                    }
1615                    _ => Err(fidl::Error::UnknownOrdinal {
1616                        ordinal: header.ordinal,
1617                        protocol_name:
1618                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1619                    }),
1620                }))
1621            },
1622        )
1623    }
1624}
1625
1626/// An interface that gives clients of `Manager` (element proposers) control
1627/// over the proposed element's lifecycle and annotations.
1628///
1629/// ## Lifecycle
1630///
1631/// The client must keep `Controller` connected to ensure the element
1632/// remains in the session and is not destroyed. Once `Controller` is closed,
1633/// the element and its component will be terminated. The element may also terminate
1634/// itself, which will cause `Controller` to close.
1635#[derive(Debug)]
1636pub enum ControllerRequest {
1637    /// Adds, updates, and removes annotations.
1638    ///
1639    /// The server is expected to adhere to the following conventions:
1640    ///
1641    /// * If a key in `annotations_to_set` is new, a new annotation is added
1642    /// * If a key in `annotations_to_set` already exists, the annotation value is updated
1643    /// * If a key in `annotations_to_delete` does not exist, it is ignored
1644    ///
1645    /// The same key cannot appear twice in a call to UpdateAnnotations().  In other words,
1646    /// to set two Annotations with matching keys is illegal, as is an attempt to set an
1647    /// Annotation and also delete it.
1648    ///
1649    /// If the operation results in an error, the annotations remain unchanged,
1650    /// and will not be partially updated.
1651    ///
1652    /// * error `UpdateAnnotationsError.INVALID_ARGS` if the same key exists in
1653    ///   both `annotations_to_set` and `annotations_to_delete`.
1654    /// * error `UpdateAnnotationsError.INVALID_ARGS` if a key in `annotations_to_set` or
1655    ///   `annotations_to_delete` has an empty namespace.
1656    /// * error `UpdateAnnotationsError.INVALID_ARGS` if an `AnnotationValue.buffer` in
1657    ///   `annotations_to_set` could not be read.
1658    /// * error `UpdateAnnotationsError.TOO_MANY_ANNOTATIONS` if the operation results
1659    ///   in more than `MAX_ANNOTATIONS_PER_ELEMENT` annotations existing.
1660    UpdateAnnotations {
1661        annotations_to_set: Vec<Annotation>,
1662        annotations_to_delete: Vec<AnnotationKey>,
1663        responder: ControllerUpdateAnnotationsResponder,
1664    },
1665    /// Returns the current `Annotations` for the element.
1666    ///
1667    /// * error `GetAnnotationsError` if the annotations could not be returned.
1668    GetAnnotations { responder: ControllerGetAnnotationsResponder },
1669    /// Returns the full set of `Annotations` when one or more of them have changed, or
1670    /// when this method is called by the client for the first time.
1671    ///
1672    /// This operation does not block other requests from the client, but only one
1673    /// `WatchAnnotations` request at a time can be made on a connection. If the
1674    /// client makes a second `WatchAnnotations` request before waiting for the
1675    /// previous request to complete, the connection will be closed.
1676    ///
1677    /// * error `WatchAnnotationsError` if the annotations could not be returned.
1678    WatchAnnotations { responder: ControllerWatchAnnotationsResponder },
1679}
1680
1681impl ControllerRequest {
1682    #[allow(irrefutable_let_patterns)]
1683    pub fn into_update_annotations(
1684        self,
1685    ) -> Option<(Vec<Annotation>, Vec<AnnotationKey>, ControllerUpdateAnnotationsResponder)> {
1686        if let ControllerRequest::UpdateAnnotations {
1687            annotations_to_set,
1688            annotations_to_delete,
1689            responder,
1690        } = self
1691        {
1692            Some((annotations_to_set, annotations_to_delete, responder))
1693        } else {
1694            None
1695        }
1696    }
1697
1698    #[allow(irrefutable_let_patterns)]
1699    pub fn into_get_annotations(self) -> Option<(ControllerGetAnnotationsResponder)> {
1700        if let ControllerRequest::GetAnnotations { responder } = self {
1701            Some((responder))
1702        } else {
1703            None
1704        }
1705    }
1706
1707    #[allow(irrefutable_let_patterns)]
1708    pub fn into_watch_annotations(self) -> Option<(ControllerWatchAnnotationsResponder)> {
1709        if let ControllerRequest::WatchAnnotations { responder } = self {
1710            Some((responder))
1711        } else {
1712            None
1713        }
1714    }
1715
1716    /// Name of the method defined in FIDL
1717    pub fn method_name(&self) -> &'static str {
1718        match *self {
1719            ControllerRequest::UpdateAnnotations { .. } => "update_annotations",
1720            ControllerRequest::GetAnnotations { .. } => "get_annotations",
1721            ControllerRequest::WatchAnnotations { .. } => "watch_annotations",
1722        }
1723    }
1724}
1725
1726#[derive(Debug, Clone)]
1727pub struct ControllerControlHandle {
1728    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1729}
1730
1731impl fidl::endpoints::ControlHandle for ControllerControlHandle {
1732    fn shutdown(&self) {
1733        self.inner.shutdown()
1734    }
1735
1736    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1737        self.inner.shutdown_with_epitaph(status)
1738    }
1739
1740    fn is_closed(&self) -> bool {
1741        self.inner.channel().is_closed()
1742    }
1743    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1744        self.inner.channel().on_closed()
1745    }
1746
1747    #[cfg(target_os = "fuchsia")]
1748    fn signal_peer(
1749        &self,
1750        clear_mask: zx::Signals,
1751        set_mask: zx::Signals,
1752    ) -> Result<(), zx_status::Status> {
1753        use fidl::Peered;
1754        self.inner.channel().signal_peer(clear_mask, set_mask)
1755    }
1756}
1757
1758impl ControllerControlHandle {}
1759
1760#[must_use = "FIDL methods require a response to be sent"]
1761#[derive(Debug)]
1762pub struct ControllerUpdateAnnotationsResponder {
1763    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1764    tx_id: u32,
1765}
1766
1767/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1768/// if the responder is dropped without sending a response, so that the client
1769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1770impl std::ops::Drop for ControllerUpdateAnnotationsResponder {
1771    fn drop(&mut self) {
1772        self.control_handle.shutdown();
1773        // Safety: drops once, never accessed again
1774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1775    }
1776}
1777
1778impl fidl::endpoints::Responder for ControllerUpdateAnnotationsResponder {
1779    type ControlHandle = ControllerControlHandle;
1780
1781    fn control_handle(&self) -> &ControllerControlHandle {
1782        &self.control_handle
1783    }
1784
1785    fn drop_without_shutdown(mut self) {
1786        // Safety: drops once, never accessed again due to mem::forget
1787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1788        // Prevent Drop from running (which would shut down the channel)
1789        std::mem::forget(self);
1790    }
1791}
1792
1793impl ControllerUpdateAnnotationsResponder {
1794    /// Sends a response to the FIDL transaction.
1795    ///
1796    /// Sets the channel to shutdown if an error occurs.
1797    pub fn send(self, mut result: Result<(), UpdateAnnotationsError>) -> Result<(), fidl::Error> {
1798        let _result = self.send_raw(result);
1799        if _result.is_err() {
1800            self.control_handle.shutdown();
1801        }
1802        self.drop_without_shutdown();
1803        _result
1804    }
1805
1806    /// Similar to "send" but does not shutdown the channel if an error occurs.
1807    pub fn send_no_shutdown_on_err(
1808        self,
1809        mut result: Result<(), UpdateAnnotationsError>,
1810    ) -> Result<(), fidl::Error> {
1811        let _result = self.send_raw(result);
1812        self.drop_without_shutdown();
1813        _result
1814    }
1815
1816    fn send_raw(&self, mut result: Result<(), UpdateAnnotationsError>) -> Result<(), fidl::Error> {
1817        self.control_handle.inner.send::<fidl::encoding::ResultType<
1818            fidl::encoding::EmptyStruct,
1819            UpdateAnnotationsError,
1820        >>(
1821            result,
1822            self.tx_id,
1823            0x5718e51a2774c686,
1824            fidl::encoding::DynamicFlags::empty(),
1825        )
1826    }
1827}
1828
1829#[must_use = "FIDL methods require a response to be sent"]
1830#[derive(Debug)]
1831pub struct ControllerGetAnnotationsResponder {
1832    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1833    tx_id: u32,
1834}
1835
1836/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1837/// if the responder is dropped without sending a response, so that the client
1838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1839impl std::ops::Drop for ControllerGetAnnotationsResponder {
1840    fn drop(&mut self) {
1841        self.control_handle.shutdown();
1842        // Safety: drops once, never accessed again
1843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1844    }
1845}
1846
1847impl fidl::endpoints::Responder for ControllerGetAnnotationsResponder {
1848    type ControlHandle = ControllerControlHandle;
1849
1850    fn control_handle(&self) -> &ControllerControlHandle {
1851        &self.control_handle
1852    }
1853
1854    fn drop_without_shutdown(mut self) {
1855        // Safety: drops once, never accessed again due to mem::forget
1856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1857        // Prevent Drop from running (which would shut down the channel)
1858        std::mem::forget(self);
1859    }
1860}
1861
1862impl ControllerGetAnnotationsResponder {
1863    /// Sends a response to the FIDL transaction.
1864    ///
1865    /// Sets the channel to shutdown if an error occurs.
1866    pub fn send(
1867        self,
1868        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
1869    ) -> Result<(), fidl::Error> {
1870        let _result = self.send_raw(result);
1871        if _result.is_err() {
1872            self.control_handle.shutdown();
1873        }
1874        self.drop_without_shutdown();
1875        _result
1876    }
1877
1878    /// Similar to "send" but does not shutdown the channel if an error occurs.
1879    pub fn send_no_shutdown_on_err(
1880        self,
1881        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
1882    ) -> Result<(), fidl::Error> {
1883        let _result = self.send_raw(result);
1884        self.drop_without_shutdown();
1885        _result
1886    }
1887
1888    fn send_raw(
1889        &self,
1890        mut result: Result<Vec<Annotation>, GetAnnotationsError>,
1891    ) -> Result<(), fidl::Error> {
1892        self.control_handle.inner.send::<fidl::encoding::ResultType<
1893            AnnotationControllerGetAnnotationsResponse,
1894            GetAnnotationsError,
1895        >>(
1896            result.as_mut().map_err(|e| *e).map(|annotations| (annotations.as_mut_slice(),)),
1897            self.tx_id,
1898            0xae78b17381824fa,
1899            fidl::encoding::DynamicFlags::empty(),
1900        )
1901    }
1902}
1903
1904#[must_use = "FIDL methods require a response to be sent"]
1905#[derive(Debug)]
1906pub struct ControllerWatchAnnotationsResponder {
1907    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1908    tx_id: u32,
1909}
1910
1911/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1912/// if the responder is dropped without sending a response, so that the client
1913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1914impl std::ops::Drop for ControllerWatchAnnotationsResponder {
1915    fn drop(&mut self) {
1916        self.control_handle.shutdown();
1917        // Safety: drops once, never accessed again
1918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1919    }
1920}
1921
1922impl fidl::endpoints::Responder for ControllerWatchAnnotationsResponder {
1923    type ControlHandle = ControllerControlHandle;
1924
1925    fn control_handle(&self) -> &ControllerControlHandle {
1926        &self.control_handle
1927    }
1928
1929    fn drop_without_shutdown(mut self) {
1930        // Safety: drops once, never accessed again due to mem::forget
1931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1932        // Prevent Drop from running (which would shut down the channel)
1933        std::mem::forget(self);
1934    }
1935}
1936
1937impl ControllerWatchAnnotationsResponder {
1938    /// Sends a response to the FIDL transaction.
1939    ///
1940    /// Sets the channel to shutdown if an error occurs.
1941    pub fn send(
1942        self,
1943        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1944    ) -> Result<(), fidl::Error> {
1945        let _result = self.send_raw(result);
1946        if _result.is_err() {
1947            self.control_handle.shutdown();
1948        }
1949        self.drop_without_shutdown();
1950        _result
1951    }
1952
1953    /// Similar to "send" but does not shutdown the channel if an error occurs.
1954    pub fn send_no_shutdown_on_err(
1955        self,
1956        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1957    ) -> Result<(), fidl::Error> {
1958        let _result = self.send_raw(result);
1959        self.drop_without_shutdown();
1960        _result
1961    }
1962
1963    fn send_raw(
1964        &self,
1965        mut result: Result<Vec<Annotation>, WatchAnnotationsError>,
1966    ) -> Result<(), fidl::Error> {
1967        self.control_handle.inner.send::<fidl::encoding::ResultType<
1968            AnnotationControllerWatchAnnotationsResponse,
1969            WatchAnnotationsError,
1970        >>(
1971            result.as_mut().map_err(|e| *e).map(|annotations| (annotations.as_mut_slice(),)),
1972            self.tx_id,
1973            0x253b196cae31356f,
1974            fidl::encoding::DynamicFlags::empty(),
1975        )
1976    }
1977}
1978
1979#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1980pub struct GraphicalPresenterMarker;
1981
1982impl fidl::endpoints::ProtocolMarker for GraphicalPresenterMarker {
1983    type Proxy = GraphicalPresenterProxy;
1984    type RequestStream = GraphicalPresenterRequestStream;
1985    #[cfg(target_os = "fuchsia")]
1986    type SynchronousProxy = GraphicalPresenterSynchronousProxy;
1987
1988    const DEBUG_NAME: &'static str = "fuchsia.element.GraphicalPresenter";
1989}
1990impl fidl::endpoints::DiscoverableProtocolMarker for GraphicalPresenterMarker {}
1991pub type GraphicalPresenterPresentViewResult = Result<(), PresentViewError>;
1992
1993pub trait GraphicalPresenterProxyInterface: Send + Sync {
1994    type PresentViewResponseFut: std::future::Future<Output = Result<GraphicalPresenterPresentViewResult, fidl::Error>>
1995        + Send;
1996    fn r#present_view(
1997        &self,
1998        view_spec: ViewSpec,
1999        annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2000        view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2001    ) -> Self::PresentViewResponseFut;
2002}
2003#[derive(Debug)]
2004#[cfg(target_os = "fuchsia")]
2005pub struct GraphicalPresenterSynchronousProxy {
2006    client: fidl::client::sync::Client,
2007}
2008
2009#[cfg(target_os = "fuchsia")]
2010impl fidl::endpoints::SynchronousProxy for GraphicalPresenterSynchronousProxy {
2011    type Proxy = GraphicalPresenterProxy;
2012    type Protocol = GraphicalPresenterMarker;
2013
2014    fn from_channel(inner: fidl::Channel) -> Self {
2015        Self::new(inner)
2016    }
2017
2018    fn into_channel(self) -> fidl::Channel {
2019        self.client.into_channel()
2020    }
2021
2022    fn as_channel(&self) -> &fidl::Channel {
2023        self.client.as_channel()
2024    }
2025}
2026
2027#[cfg(target_os = "fuchsia")]
2028impl GraphicalPresenterSynchronousProxy {
2029    pub fn new(channel: fidl::Channel) -> Self {
2030        Self { client: fidl::client::sync::Client::new(channel) }
2031    }
2032
2033    pub fn into_channel(self) -> fidl::Channel {
2034        self.client.into_channel()
2035    }
2036
2037    /// Waits until an event arrives and returns it. It is safe for other
2038    /// threads to make concurrent requests while waiting for an event.
2039    pub fn wait_for_event(
2040        &self,
2041        deadline: zx::MonotonicInstant,
2042    ) -> Result<GraphicalPresenterEvent, fidl::Error> {
2043        GraphicalPresenterEvent::decode(
2044            self.client.wait_for_event::<GraphicalPresenterMarker>(deadline)?,
2045        )
2046    }
2047
2048    /// Presents the view described by `view_spec`.
2049    ///
2050    /// If `view_controller_request` is provided, it will be connected to a `ViewController`
2051    /// implemented by the `GraphicalPresenter` server. When the view is dismissed,
2052    /// the `ViewController` channel is closed with a `ZX_OK`, at which point it is safe
2053    /// to clean up resources backing the view. To dismiss the view, the client should
2054    /// call `ViewController.Dismiss()` and wait for the `ZX_OK` epitaph.
2055    /// Not providing a `view_controller_request` handle will make it impossible for the
2056    /// client to observe the view's lifecycle.
2057    ///
2058    /// + `view_spec` describes the view to present
2059    /// + `annotation_controller` a handle to an `AnnotationController`, allowing the
2060    ///    `GraphicalPresenter` server to observe and update the view's annotations.
2061    /// + `view_controller_request` an optional request for a controller for the view
2062    /// * error `view_spec`  must contain `view_holder_token` and `view_ref` for Gfx views,
2063    ///   OR `viewport_creation_token` for Flatland views, but never both. If both are
2064    ///   set, error `PresentViewError.INVALID_ARGS` is returned.
2065    /// * error `PresentViewError.INVALID_ARGS` if `spec.view_holder_token` or
2066    ///   `spec.view_ref` are missing or invalid.
2067    pub fn r#present_view(
2068        &self,
2069        mut view_spec: ViewSpec,
2070        mut annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2071        mut view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2072        ___deadline: zx::MonotonicInstant,
2073    ) -> Result<GraphicalPresenterPresentViewResult, fidl::Error> {
2074        let _response = self.client.send_query::<
2075            GraphicalPresenterPresentViewRequest,
2076            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PresentViewError>,
2077            GraphicalPresenterMarker,
2078        >(
2079            (&mut view_spec, annotation_controller, view_controller_request,),
2080            0x396042dd1422ac7a,
2081            fidl::encoding::DynamicFlags::empty(),
2082            ___deadline,
2083        )?;
2084        Ok(_response.map(|x| x))
2085    }
2086}
2087
2088#[cfg(target_os = "fuchsia")]
2089impl From<GraphicalPresenterSynchronousProxy> for zx::NullableHandle {
2090    fn from(value: GraphicalPresenterSynchronousProxy) -> Self {
2091        value.into_channel().into()
2092    }
2093}
2094
2095#[cfg(target_os = "fuchsia")]
2096impl From<fidl::Channel> for GraphicalPresenterSynchronousProxy {
2097    fn from(value: fidl::Channel) -> Self {
2098        Self::new(value)
2099    }
2100}
2101
2102#[cfg(target_os = "fuchsia")]
2103impl fidl::endpoints::FromClient for GraphicalPresenterSynchronousProxy {
2104    type Protocol = GraphicalPresenterMarker;
2105
2106    fn from_client(value: fidl::endpoints::ClientEnd<GraphicalPresenterMarker>) -> Self {
2107        Self::new(value.into_channel())
2108    }
2109}
2110
2111#[derive(Debug, Clone)]
2112pub struct GraphicalPresenterProxy {
2113    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2114}
2115
2116impl fidl::endpoints::Proxy for GraphicalPresenterProxy {
2117    type Protocol = GraphicalPresenterMarker;
2118
2119    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2120        Self::new(inner)
2121    }
2122
2123    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2124        self.client.into_channel().map_err(|client| Self { client })
2125    }
2126
2127    fn as_channel(&self) -> &::fidl::AsyncChannel {
2128        self.client.as_channel()
2129    }
2130}
2131
2132impl GraphicalPresenterProxy {
2133    /// Create a new Proxy for fuchsia.element/GraphicalPresenter.
2134    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2135        let protocol_name =
2136            <GraphicalPresenterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2137        Self { client: fidl::client::Client::new(channel, protocol_name) }
2138    }
2139
2140    /// Get a Stream of events from the remote end of the protocol.
2141    ///
2142    /// # Panics
2143    ///
2144    /// Panics if the event stream was already taken.
2145    pub fn take_event_stream(&self) -> GraphicalPresenterEventStream {
2146        GraphicalPresenterEventStream { event_receiver: self.client.take_event_receiver() }
2147    }
2148
2149    /// Presents the view described by `view_spec`.
2150    ///
2151    /// If `view_controller_request` is provided, it will be connected to a `ViewController`
2152    /// implemented by the `GraphicalPresenter` server. When the view is dismissed,
2153    /// the `ViewController` channel is closed with a `ZX_OK`, at which point it is safe
2154    /// to clean up resources backing the view. To dismiss the view, the client should
2155    /// call `ViewController.Dismiss()` and wait for the `ZX_OK` epitaph.
2156    /// Not providing a `view_controller_request` handle will make it impossible for the
2157    /// client to observe the view's lifecycle.
2158    ///
2159    /// + `view_spec` describes the view to present
2160    /// + `annotation_controller` a handle to an `AnnotationController`, allowing the
2161    ///    `GraphicalPresenter` server to observe and update the view's annotations.
2162    /// + `view_controller_request` an optional request for a controller for the view
2163    /// * error `view_spec`  must contain `view_holder_token` and `view_ref` for Gfx views,
2164    ///   OR `viewport_creation_token` for Flatland views, but never both. If both are
2165    ///   set, error `PresentViewError.INVALID_ARGS` is returned.
2166    /// * error `PresentViewError.INVALID_ARGS` if `spec.view_holder_token` or
2167    ///   `spec.view_ref` are missing or invalid.
2168    pub fn r#present_view(
2169        &self,
2170        mut view_spec: ViewSpec,
2171        mut annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2172        mut view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2173    ) -> fidl::client::QueryResponseFut<
2174        GraphicalPresenterPresentViewResult,
2175        fidl::encoding::DefaultFuchsiaResourceDialect,
2176    > {
2177        GraphicalPresenterProxyInterface::r#present_view(
2178            self,
2179            view_spec,
2180            annotation_controller,
2181            view_controller_request,
2182        )
2183    }
2184}
2185
2186impl GraphicalPresenterProxyInterface for GraphicalPresenterProxy {
2187    type PresentViewResponseFut = fidl::client::QueryResponseFut<
2188        GraphicalPresenterPresentViewResult,
2189        fidl::encoding::DefaultFuchsiaResourceDialect,
2190    >;
2191    fn r#present_view(
2192        &self,
2193        mut view_spec: ViewSpec,
2194        mut annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2195        mut view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2196    ) -> Self::PresentViewResponseFut {
2197        fn _decode(
2198            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2199        ) -> Result<GraphicalPresenterPresentViewResult, fidl::Error> {
2200            let _response = fidl::client::decode_transaction_body::<
2201                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PresentViewError>,
2202                fidl::encoding::DefaultFuchsiaResourceDialect,
2203                0x396042dd1422ac7a,
2204            >(_buf?)?;
2205            Ok(_response.map(|x| x))
2206        }
2207        self.client.send_query_and_decode::<
2208            GraphicalPresenterPresentViewRequest,
2209            GraphicalPresenterPresentViewResult,
2210        >(
2211            (&mut view_spec, annotation_controller, view_controller_request,),
2212            0x396042dd1422ac7a,
2213            fidl::encoding::DynamicFlags::empty(),
2214            _decode,
2215        )
2216    }
2217}
2218
2219pub struct GraphicalPresenterEventStream {
2220    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2221}
2222
2223impl std::marker::Unpin for GraphicalPresenterEventStream {}
2224
2225impl futures::stream::FusedStream for GraphicalPresenterEventStream {
2226    fn is_terminated(&self) -> bool {
2227        self.event_receiver.is_terminated()
2228    }
2229}
2230
2231impl futures::Stream for GraphicalPresenterEventStream {
2232    type Item = Result<GraphicalPresenterEvent, fidl::Error>;
2233
2234    fn poll_next(
2235        mut self: std::pin::Pin<&mut Self>,
2236        cx: &mut std::task::Context<'_>,
2237    ) -> std::task::Poll<Option<Self::Item>> {
2238        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2239            &mut self.event_receiver,
2240            cx
2241        )?) {
2242            Some(buf) => std::task::Poll::Ready(Some(GraphicalPresenterEvent::decode(buf))),
2243            None => std::task::Poll::Ready(None),
2244        }
2245    }
2246}
2247
2248#[derive(Debug)]
2249pub enum GraphicalPresenterEvent {}
2250
2251impl GraphicalPresenterEvent {
2252    /// Decodes a message buffer as a [`GraphicalPresenterEvent`].
2253    fn decode(
2254        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2255    ) -> Result<GraphicalPresenterEvent, fidl::Error> {
2256        let (bytes, _handles) = buf.split_mut();
2257        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2258        debug_assert_eq!(tx_header.tx_id, 0);
2259        match tx_header.ordinal {
2260            _ => Err(fidl::Error::UnknownOrdinal {
2261                ordinal: tx_header.ordinal,
2262                protocol_name:
2263                    <GraphicalPresenterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2264            }),
2265        }
2266    }
2267}
2268
2269/// A Stream of incoming requests for fuchsia.element/GraphicalPresenter.
2270pub struct GraphicalPresenterRequestStream {
2271    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2272    is_terminated: bool,
2273}
2274
2275impl std::marker::Unpin for GraphicalPresenterRequestStream {}
2276
2277impl futures::stream::FusedStream for GraphicalPresenterRequestStream {
2278    fn is_terminated(&self) -> bool {
2279        self.is_terminated
2280    }
2281}
2282
2283impl fidl::endpoints::RequestStream for GraphicalPresenterRequestStream {
2284    type Protocol = GraphicalPresenterMarker;
2285    type ControlHandle = GraphicalPresenterControlHandle;
2286
2287    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2288        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2289    }
2290
2291    fn control_handle(&self) -> Self::ControlHandle {
2292        GraphicalPresenterControlHandle { inner: self.inner.clone() }
2293    }
2294
2295    fn into_inner(
2296        self,
2297    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2298    {
2299        (self.inner, self.is_terminated)
2300    }
2301
2302    fn from_inner(
2303        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2304        is_terminated: bool,
2305    ) -> Self {
2306        Self { inner, is_terminated }
2307    }
2308}
2309
2310impl futures::Stream for GraphicalPresenterRequestStream {
2311    type Item = Result<GraphicalPresenterRequest, fidl::Error>;
2312
2313    fn poll_next(
2314        mut self: std::pin::Pin<&mut Self>,
2315        cx: &mut std::task::Context<'_>,
2316    ) -> std::task::Poll<Option<Self::Item>> {
2317        let this = &mut *self;
2318        if this.inner.check_shutdown(cx) {
2319            this.is_terminated = true;
2320            return std::task::Poll::Ready(None);
2321        }
2322        if this.is_terminated {
2323            panic!("polled GraphicalPresenterRequestStream after completion");
2324        }
2325        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2326            |bytes, handles| {
2327                match this.inner.channel().read_etc(cx, bytes, handles) {
2328                    std::task::Poll::Ready(Ok(())) => {}
2329                    std::task::Poll::Pending => return std::task::Poll::Pending,
2330                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2331                        this.is_terminated = true;
2332                        return std::task::Poll::Ready(None);
2333                    }
2334                    std::task::Poll::Ready(Err(e)) => {
2335                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2336                            e.into(),
2337                        ))));
2338                    }
2339                }
2340
2341                // A message has been received from the channel
2342                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2343
2344                std::task::Poll::Ready(Some(match header.ordinal {
2345                0x396042dd1422ac7a => {
2346                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2347                    let mut req = fidl::new_empty!(GraphicalPresenterPresentViewRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2348                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GraphicalPresenterPresentViewRequest>(&header, _body_bytes, handles, &mut req)?;
2349                    let control_handle = GraphicalPresenterControlHandle {
2350                        inner: this.inner.clone(),
2351                    };
2352                    Ok(GraphicalPresenterRequest::PresentView {view_spec: req.view_spec,
2353annotation_controller: req.annotation_controller,
2354view_controller_request: req.view_controller_request,
2355
2356                        responder: GraphicalPresenterPresentViewResponder {
2357                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2358                            tx_id: header.tx_id,
2359                        },
2360                    })
2361                }
2362                _ => Err(fidl::Error::UnknownOrdinal {
2363                    ordinal: header.ordinal,
2364                    protocol_name: <GraphicalPresenterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2365                }),
2366            }))
2367            },
2368        )
2369    }
2370}
2371
2372/// An interface used to instruct a server to present graphical views, and observe
2373/// and control the view's lifecycle.
2374#[derive(Debug)]
2375pub enum GraphicalPresenterRequest {
2376    /// Presents the view described by `view_spec`.
2377    ///
2378    /// If `view_controller_request` is provided, it will be connected to a `ViewController`
2379    /// implemented by the `GraphicalPresenter` server. When the view is dismissed,
2380    /// the `ViewController` channel is closed with a `ZX_OK`, at which point it is safe
2381    /// to clean up resources backing the view. To dismiss the view, the client should
2382    /// call `ViewController.Dismiss()` and wait for the `ZX_OK` epitaph.
2383    /// Not providing a `view_controller_request` handle will make it impossible for the
2384    /// client to observe the view's lifecycle.
2385    ///
2386    /// + `view_spec` describes the view to present
2387    /// + `annotation_controller` a handle to an `AnnotationController`, allowing the
2388    ///    `GraphicalPresenter` server to observe and update the view's annotations.
2389    /// + `view_controller_request` an optional request for a controller for the view
2390    /// * error `view_spec`  must contain `view_holder_token` and `view_ref` for Gfx views,
2391    ///   OR `viewport_creation_token` for Flatland views, but never both. If both are
2392    ///   set, error `PresentViewError.INVALID_ARGS` is returned.
2393    /// * error `PresentViewError.INVALID_ARGS` if `spec.view_holder_token` or
2394    ///   `spec.view_ref` are missing or invalid.
2395    PresentView {
2396        view_spec: ViewSpec,
2397        annotation_controller: Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2398        view_controller_request: Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2399        responder: GraphicalPresenterPresentViewResponder,
2400    },
2401}
2402
2403impl GraphicalPresenterRequest {
2404    #[allow(irrefutable_let_patterns)]
2405    pub fn into_present_view(
2406        self,
2407    ) -> Option<(
2408        ViewSpec,
2409        Option<fidl::endpoints::ClientEnd<AnnotationControllerMarker>>,
2410        Option<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
2411        GraphicalPresenterPresentViewResponder,
2412    )> {
2413        if let GraphicalPresenterRequest::PresentView {
2414            view_spec,
2415            annotation_controller,
2416            view_controller_request,
2417            responder,
2418        } = self
2419        {
2420            Some((view_spec, annotation_controller, view_controller_request, responder))
2421        } else {
2422            None
2423        }
2424    }
2425
2426    /// Name of the method defined in FIDL
2427    pub fn method_name(&self) -> &'static str {
2428        match *self {
2429            GraphicalPresenterRequest::PresentView { .. } => "present_view",
2430        }
2431    }
2432}
2433
2434#[derive(Debug, Clone)]
2435pub struct GraphicalPresenterControlHandle {
2436    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2437}
2438
2439impl fidl::endpoints::ControlHandle for GraphicalPresenterControlHandle {
2440    fn shutdown(&self) {
2441        self.inner.shutdown()
2442    }
2443
2444    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2445        self.inner.shutdown_with_epitaph(status)
2446    }
2447
2448    fn is_closed(&self) -> bool {
2449        self.inner.channel().is_closed()
2450    }
2451    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2452        self.inner.channel().on_closed()
2453    }
2454
2455    #[cfg(target_os = "fuchsia")]
2456    fn signal_peer(
2457        &self,
2458        clear_mask: zx::Signals,
2459        set_mask: zx::Signals,
2460    ) -> Result<(), zx_status::Status> {
2461        use fidl::Peered;
2462        self.inner.channel().signal_peer(clear_mask, set_mask)
2463    }
2464}
2465
2466impl GraphicalPresenterControlHandle {}
2467
2468#[must_use = "FIDL methods require a response to be sent"]
2469#[derive(Debug)]
2470pub struct GraphicalPresenterPresentViewResponder {
2471    control_handle: std::mem::ManuallyDrop<GraphicalPresenterControlHandle>,
2472    tx_id: u32,
2473}
2474
2475/// Set the the channel to be shutdown (see [`GraphicalPresenterControlHandle::shutdown`])
2476/// if the responder is dropped without sending a response, so that the client
2477/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2478impl std::ops::Drop for GraphicalPresenterPresentViewResponder {
2479    fn drop(&mut self) {
2480        self.control_handle.shutdown();
2481        // Safety: drops once, never accessed again
2482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2483    }
2484}
2485
2486impl fidl::endpoints::Responder for GraphicalPresenterPresentViewResponder {
2487    type ControlHandle = GraphicalPresenterControlHandle;
2488
2489    fn control_handle(&self) -> &GraphicalPresenterControlHandle {
2490        &self.control_handle
2491    }
2492
2493    fn drop_without_shutdown(mut self) {
2494        // Safety: drops once, never accessed again due to mem::forget
2495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2496        // Prevent Drop from running (which would shut down the channel)
2497        std::mem::forget(self);
2498    }
2499}
2500
2501impl GraphicalPresenterPresentViewResponder {
2502    /// Sends a response to the FIDL transaction.
2503    ///
2504    /// Sets the channel to shutdown if an error occurs.
2505    pub fn send(self, mut result: Result<(), PresentViewError>) -> Result<(), fidl::Error> {
2506        let _result = self.send_raw(result);
2507        if _result.is_err() {
2508            self.control_handle.shutdown();
2509        }
2510        self.drop_without_shutdown();
2511        _result
2512    }
2513
2514    /// Similar to "send" but does not shutdown the channel if an error occurs.
2515    pub fn send_no_shutdown_on_err(
2516        self,
2517        mut result: Result<(), PresentViewError>,
2518    ) -> Result<(), fidl::Error> {
2519        let _result = self.send_raw(result);
2520        self.drop_without_shutdown();
2521        _result
2522    }
2523
2524    fn send_raw(&self, mut result: Result<(), PresentViewError>) -> Result<(), fidl::Error> {
2525        self.control_handle.inner.send::<fidl::encoding::ResultType<
2526            fidl::encoding::EmptyStruct,
2527            PresentViewError,
2528        >>(
2529            result,
2530            self.tx_id,
2531            0x396042dd1422ac7a,
2532            fidl::encoding::DynamicFlags::empty(),
2533        )
2534    }
2535}
2536
2537#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2538pub struct ManagerMarker;
2539
2540impl fidl::endpoints::ProtocolMarker for ManagerMarker {
2541    type Proxy = ManagerProxy;
2542    type RequestStream = ManagerRequestStream;
2543    #[cfg(target_os = "fuchsia")]
2544    type SynchronousProxy = ManagerSynchronousProxy;
2545
2546    const DEBUG_NAME: &'static str = "fuchsia.element.Manager";
2547}
2548impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
2549pub type ManagerProposeElementResult = Result<(), ManagerError>;
2550pub type ManagerRemoveElementResult = Result<(), ManagerError>;
2551
2552pub trait ManagerProxyInterface: Send + Sync {
2553    type ProposeElementResponseFut: std::future::Future<Output = Result<ManagerProposeElementResult, fidl::Error>>
2554        + Send;
2555    fn r#propose_element(
2556        &self,
2557        spec: Spec,
2558        controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2559    ) -> Self::ProposeElementResponseFut;
2560    type RemoveElementResponseFut: std::future::Future<Output = Result<ManagerRemoveElementResult, fidl::Error>>
2561        + Send;
2562    fn r#remove_element(&self, name: &str) -> Self::RemoveElementResponseFut;
2563}
2564#[derive(Debug)]
2565#[cfg(target_os = "fuchsia")]
2566pub struct ManagerSynchronousProxy {
2567    client: fidl::client::sync::Client,
2568}
2569
2570#[cfg(target_os = "fuchsia")]
2571impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
2572    type Proxy = ManagerProxy;
2573    type Protocol = ManagerMarker;
2574
2575    fn from_channel(inner: fidl::Channel) -> Self {
2576        Self::new(inner)
2577    }
2578
2579    fn into_channel(self) -> fidl::Channel {
2580        self.client.into_channel()
2581    }
2582
2583    fn as_channel(&self) -> &fidl::Channel {
2584        self.client.as_channel()
2585    }
2586}
2587
2588#[cfg(target_os = "fuchsia")]
2589impl ManagerSynchronousProxy {
2590    pub fn new(channel: fidl::Channel) -> Self {
2591        Self { client: fidl::client::sync::Client::new(channel) }
2592    }
2593
2594    pub fn into_channel(self) -> fidl::Channel {
2595        self.client.into_channel()
2596    }
2597
2598    /// Waits until an event arrives and returns it. It is safe for other
2599    /// threads to make concurrent requests while waiting for an event.
2600    pub fn wait_for_event(
2601        &self,
2602        deadline: zx::MonotonicInstant,
2603    ) -> Result<ManagerEvent, fidl::Error> {
2604        ManagerEvent::decode(self.client.wait_for_event::<ManagerMarker>(deadline)?)
2605    }
2606
2607    pub fn r#propose_element(
2608        &self,
2609        mut spec: Spec,
2610        mut controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2611        ___deadline: zx::MonotonicInstant,
2612    ) -> Result<ManagerProposeElementResult, fidl::Error> {
2613        let _response = self.client.send_query::<
2614            ManagerProposeElementRequest,
2615            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ManagerError>,
2616            ManagerMarker,
2617        >(
2618            (&mut spec, controller,),
2619            0x2af76679cd73b902,
2620            fidl::encoding::DynamicFlags::empty(),
2621            ___deadline,
2622        )?;
2623        Ok(_response.map(|x| x))
2624    }
2625
2626    /// Removes the element identified by `name` from the session. If the element is a persistent
2627    /// element, it is removed permanently. Any persistent storage that the element might have used
2628    /// is left untouched.
2629    pub fn r#remove_element(
2630        &self,
2631        mut name: &str,
2632        ___deadline: zx::MonotonicInstant,
2633    ) -> Result<ManagerRemoveElementResult, fidl::Error> {
2634        let _response = self.client.send_query::<
2635            ManagerRemoveElementRequest,
2636            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ManagerError>,
2637            ManagerMarker,
2638        >(
2639            (name,),
2640            0x1e65d66515e64b52,
2641            fidl::encoding::DynamicFlags::empty(),
2642            ___deadline,
2643        )?;
2644        Ok(_response.map(|x| x))
2645    }
2646}
2647
2648#[cfg(target_os = "fuchsia")]
2649impl From<ManagerSynchronousProxy> for zx::NullableHandle {
2650    fn from(value: ManagerSynchronousProxy) -> Self {
2651        value.into_channel().into()
2652    }
2653}
2654
2655#[cfg(target_os = "fuchsia")]
2656impl From<fidl::Channel> for ManagerSynchronousProxy {
2657    fn from(value: fidl::Channel) -> Self {
2658        Self::new(value)
2659    }
2660}
2661
2662#[cfg(target_os = "fuchsia")]
2663impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
2664    type Protocol = ManagerMarker;
2665
2666    fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
2667        Self::new(value.into_channel())
2668    }
2669}
2670
2671#[derive(Debug, Clone)]
2672pub struct ManagerProxy {
2673    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2674}
2675
2676impl fidl::endpoints::Proxy for ManagerProxy {
2677    type Protocol = ManagerMarker;
2678
2679    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2680        Self::new(inner)
2681    }
2682
2683    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2684        self.client.into_channel().map_err(|client| Self { client })
2685    }
2686
2687    fn as_channel(&self) -> &::fidl::AsyncChannel {
2688        self.client.as_channel()
2689    }
2690}
2691
2692impl ManagerProxy {
2693    /// Create a new Proxy for fuchsia.element/Manager.
2694    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2695        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2696        Self { client: fidl::client::Client::new(channel, protocol_name) }
2697    }
2698
2699    /// Get a Stream of events from the remote end of the protocol.
2700    ///
2701    /// # Panics
2702    ///
2703    /// Panics if the event stream was already taken.
2704    pub fn take_event_stream(&self) -> ManagerEventStream {
2705        ManagerEventStream { event_receiver: self.client.take_event_receiver() }
2706    }
2707
2708    pub fn r#propose_element(
2709        &self,
2710        mut spec: Spec,
2711        mut controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2712    ) -> fidl::client::QueryResponseFut<
2713        ManagerProposeElementResult,
2714        fidl::encoding::DefaultFuchsiaResourceDialect,
2715    > {
2716        ManagerProxyInterface::r#propose_element(self, spec, controller)
2717    }
2718
2719    /// Removes the element identified by `name` from the session. If the element is a persistent
2720    /// element, it is removed permanently. Any persistent storage that the element might have used
2721    /// is left untouched.
2722    pub fn r#remove_element(
2723        &self,
2724        mut name: &str,
2725    ) -> fidl::client::QueryResponseFut<
2726        ManagerRemoveElementResult,
2727        fidl::encoding::DefaultFuchsiaResourceDialect,
2728    > {
2729        ManagerProxyInterface::r#remove_element(self, name)
2730    }
2731}
2732
2733impl ManagerProxyInterface for ManagerProxy {
2734    type ProposeElementResponseFut = fidl::client::QueryResponseFut<
2735        ManagerProposeElementResult,
2736        fidl::encoding::DefaultFuchsiaResourceDialect,
2737    >;
2738    fn r#propose_element(
2739        &self,
2740        mut spec: Spec,
2741        mut controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2742    ) -> Self::ProposeElementResponseFut {
2743        fn _decode(
2744            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2745        ) -> Result<ManagerProposeElementResult, fidl::Error> {
2746            let _response = fidl::client::decode_transaction_body::<
2747                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ManagerError>,
2748                fidl::encoding::DefaultFuchsiaResourceDialect,
2749                0x2af76679cd73b902,
2750            >(_buf?)?;
2751            Ok(_response.map(|x| x))
2752        }
2753        self.client
2754            .send_query_and_decode::<ManagerProposeElementRequest, ManagerProposeElementResult>(
2755                (&mut spec, controller),
2756                0x2af76679cd73b902,
2757                fidl::encoding::DynamicFlags::empty(),
2758                _decode,
2759            )
2760    }
2761
2762    type RemoveElementResponseFut = fidl::client::QueryResponseFut<
2763        ManagerRemoveElementResult,
2764        fidl::encoding::DefaultFuchsiaResourceDialect,
2765    >;
2766    fn r#remove_element(&self, mut name: &str) -> Self::RemoveElementResponseFut {
2767        fn _decode(
2768            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2769        ) -> Result<ManagerRemoveElementResult, fidl::Error> {
2770            let _response = fidl::client::decode_transaction_body::<
2771                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ManagerError>,
2772                fidl::encoding::DefaultFuchsiaResourceDialect,
2773                0x1e65d66515e64b52,
2774            >(_buf?)?;
2775            Ok(_response.map(|x| x))
2776        }
2777        self.client
2778            .send_query_and_decode::<ManagerRemoveElementRequest, ManagerRemoveElementResult>(
2779                (name,),
2780                0x1e65d66515e64b52,
2781                fidl::encoding::DynamicFlags::empty(),
2782                _decode,
2783            )
2784    }
2785}
2786
2787pub struct ManagerEventStream {
2788    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2789}
2790
2791impl std::marker::Unpin for ManagerEventStream {}
2792
2793impl futures::stream::FusedStream for ManagerEventStream {
2794    fn is_terminated(&self) -> bool {
2795        self.event_receiver.is_terminated()
2796    }
2797}
2798
2799impl futures::Stream for ManagerEventStream {
2800    type Item = Result<ManagerEvent, fidl::Error>;
2801
2802    fn poll_next(
2803        mut self: std::pin::Pin<&mut Self>,
2804        cx: &mut std::task::Context<'_>,
2805    ) -> std::task::Poll<Option<Self::Item>> {
2806        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2807            &mut self.event_receiver,
2808            cx
2809        )?) {
2810            Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
2811            None => std::task::Poll::Ready(None),
2812        }
2813    }
2814}
2815
2816#[derive(Debug)]
2817pub enum ManagerEvent {}
2818
2819impl ManagerEvent {
2820    /// Decodes a message buffer as a [`ManagerEvent`].
2821    fn decode(
2822        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2823    ) -> Result<ManagerEvent, fidl::Error> {
2824        let (bytes, _handles) = buf.split_mut();
2825        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2826        debug_assert_eq!(tx_header.tx_id, 0);
2827        match tx_header.ordinal {
2828            _ => Err(fidl::Error::UnknownOrdinal {
2829                ordinal: tx_header.ordinal,
2830                protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2831            }),
2832        }
2833    }
2834}
2835
2836/// A Stream of incoming requests for fuchsia.element/Manager.
2837pub struct ManagerRequestStream {
2838    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2839    is_terminated: bool,
2840}
2841
2842impl std::marker::Unpin for ManagerRequestStream {}
2843
2844impl futures::stream::FusedStream for ManagerRequestStream {
2845    fn is_terminated(&self) -> bool {
2846        self.is_terminated
2847    }
2848}
2849
2850impl fidl::endpoints::RequestStream for ManagerRequestStream {
2851    type Protocol = ManagerMarker;
2852    type ControlHandle = ManagerControlHandle;
2853
2854    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2855        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2856    }
2857
2858    fn control_handle(&self) -> Self::ControlHandle {
2859        ManagerControlHandle { inner: self.inner.clone() }
2860    }
2861
2862    fn into_inner(
2863        self,
2864    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2865    {
2866        (self.inner, self.is_terminated)
2867    }
2868
2869    fn from_inner(
2870        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2871        is_terminated: bool,
2872    ) -> Self {
2873        Self { inner, is_terminated }
2874    }
2875}
2876
2877impl futures::Stream for ManagerRequestStream {
2878    type Item = Result<ManagerRequest, fidl::Error>;
2879
2880    fn poll_next(
2881        mut self: std::pin::Pin<&mut Self>,
2882        cx: &mut std::task::Context<'_>,
2883    ) -> std::task::Poll<Option<Self::Item>> {
2884        let this = &mut *self;
2885        if this.inner.check_shutdown(cx) {
2886            this.is_terminated = true;
2887            return std::task::Poll::Ready(None);
2888        }
2889        if this.is_terminated {
2890            panic!("polled ManagerRequestStream after completion");
2891        }
2892        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2893            |bytes, handles| {
2894                match this.inner.channel().read_etc(cx, bytes, handles) {
2895                    std::task::Poll::Ready(Ok(())) => {}
2896                    std::task::Poll::Pending => return std::task::Poll::Pending,
2897                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2898                        this.is_terminated = true;
2899                        return std::task::Poll::Ready(None);
2900                    }
2901                    std::task::Poll::Ready(Err(e)) => {
2902                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2903                            e.into(),
2904                        ))));
2905                    }
2906                }
2907
2908                // A message has been received from the channel
2909                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2910
2911                std::task::Poll::Ready(Some(match header.ordinal {
2912                    0x2af76679cd73b902 => {
2913                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2914                        let mut req = fidl::new_empty!(
2915                            ManagerProposeElementRequest,
2916                            fidl::encoding::DefaultFuchsiaResourceDialect
2917                        );
2918                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerProposeElementRequest>(&header, _body_bytes, handles, &mut req)?;
2919                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
2920                        Ok(ManagerRequest::ProposeElement {
2921                            spec: req.spec,
2922                            controller: req.controller,
2923
2924                            responder: ManagerProposeElementResponder {
2925                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2926                                tx_id: header.tx_id,
2927                            },
2928                        })
2929                    }
2930                    0x1e65d66515e64b52 => {
2931                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2932                        let mut req = fidl::new_empty!(
2933                            ManagerRemoveElementRequest,
2934                            fidl::encoding::DefaultFuchsiaResourceDialect
2935                        );
2936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerRemoveElementRequest>(&header, _body_bytes, handles, &mut req)?;
2937                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
2938                        Ok(ManagerRequest::RemoveElement {
2939                            name: req.name,
2940
2941                            responder: ManagerRemoveElementResponder {
2942                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2943                                tx_id: header.tx_id,
2944                            },
2945                        })
2946                    }
2947                    _ => Err(fidl::Error::UnknownOrdinal {
2948                        ordinal: header.ordinal,
2949                        protocol_name:
2950                            <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2951                    }),
2952                }))
2953            },
2954        )
2955    }
2956}
2957
2958/// An interface used to add elements to a session.
2959///
2960/// An *element* is a component that is expected to be instantiated as a child
2961/// of the session and (optionally) to interact with the user in some way.
2962///
2963/// The session will typically implement `Manager` and route it where needed.
2964/// For tools like `ffx session add` to work, the session must expose `Manager`
2965/// to its parent.
2966///
2967/// For example, a component in the session may be a non-interactive application that
2968/// listens to the network for a command to display an element to the user.
2969/// When it receives the command, the component calls `ProposeElement()`.
2970#[derive(Debug)]
2971pub enum ManagerRequest {
2972    ProposeElement {
2973        spec: Spec,
2974        controller: Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2975        responder: ManagerProposeElementResponder,
2976    },
2977    /// Removes the element identified by `name` from the session. If the element is a persistent
2978    /// element, it is removed permanently. Any persistent storage that the element might have used
2979    /// is left untouched.
2980    RemoveElement { name: String, responder: ManagerRemoveElementResponder },
2981}
2982
2983impl ManagerRequest {
2984    #[allow(irrefutable_let_patterns)]
2985    pub fn into_propose_element(
2986        self,
2987    ) -> Option<(
2988        Spec,
2989        Option<fidl::endpoints::ServerEnd<ControllerMarker>>,
2990        ManagerProposeElementResponder,
2991    )> {
2992        if let ManagerRequest::ProposeElement { spec, controller, responder } = self {
2993            Some((spec, controller, responder))
2994        } else {
2995            None
2996        }
2997    }
2998
2999    #[allow(irrefutable_let_patterns)]
3000    pub fn into_remove_element(self) -> Option<(String, ManagerRemoveElementResponder)> {
3001        if let ManagerRequest::RemoveElement { name, responder } = self {
3002            Some((name, responder))
3003        } else {
3004            None
3005        }
3006    }
3007
3008    /// Name of the method defined in FIDL
3009    pub fn method_name(&self) -> &'static str {
3010        match *self {
3011            ManagerRequest::ProposeElement { .. } => "propose_element",
3012            ManagerRequest::RemoveElement { .. } => "remove_element",
3013        }
3014    }
3015}
3016
3017#[derive(Debug, Clone)]
3018pub struct ManagerControlHandle {
3019    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3020}
3021
3022impl fidl::endpoints::ControlHandle for ManagerControlHandle {
3023    fn shutdown(&self) {
3024        self.inner.shutdown()
3025    }
3026
3027    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3028        self.inner.shutdown_with_epitaph(status)
3029    }
3030
3031    fn is_closed(&self) -> bool {
3032        self.inner.channel().is_closed()
3033    }
3034    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3035        self.inner.channel().on_closed()
3036    }
3037
3038    #[cfg(target_os = "fuchsia")]
3039    fn signal_peer(
3040        &self,
3041        clear_mask: zx::Signals,
3042        set_mask: zx::Signals,
3043    ) -> Result<(), zx_status::Status> {
3044        use fidl::Peered;
3045        self.inner.channel().signal_peer(clear_mask, set_mask)
3046    }
3047}
3048
3049impl ManagerControlHandle {}
3050
3051#[must_use = "FIDL methods require a response to be sent"]
3052#[derive(Debug)]
3053pub struct ManagerProposeElementResponder {
3054    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
3055    tx_id: u32,
3056}
3057
3058/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
3059/// if the responder is dropped without sending a response, so that the client
3060/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3061impl std::ops::Drop for ManagerProposeElementResponder {
3062    fn drop(&mut self) {
3063        self.control_handle.shutdown();
3064        // Safety: drops once, never accessed again
3065        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3066    }
3067}
3068
3069impl fidl::endpoints::Responder for ManagerProposeElementResponder {
3070    type ControlHandle = ManagerControlHandle;
3071
3072    fn control_handle(&self) -> &ManagerControlHandle {
3073        &self.control_handle
3074    }
3075
3076    fn drop_without_shutdown(mut self) {
3077        // Safety: drops once, never accessed again due to mem::forget
3078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3079        // Prevent Drop from running (which would shut down the channel)
3080        std::mem::forget(self);
3081    }
3082}
3083
3084impl ManagerProposeElementResponder {
3085    /// Sends a response to the FIDL transaction.
3086    ///
3087    /// Sets the channel to shutdown if an error occurs.
3088    pub fn send(self, mut result: Result<(), ManagerError>) -> Result<(), fidl::Error> {
3089        let _result = self.send_raw(result);
3090        if _result.is_err() {
3091            self.control_handle.shutdown();
3092        }
3093        self.drop_without_shutdown();
3094        _result
3095    }
3096
3097    /// Similar to "send" but does not shutdown the channel if an error occurs.
3098    pub fn send_no_shutdown_on_err(
3099        self,
3100        mut result: Result<(), ManagerError>,
3101    ) -> Result<(), fidl::Error> {
3102        let _result = self.send_raw(result);
3103        self.drop_without_shutdown();
3104        _result
3105    }
3106
3107    fn send_raw(&self, mut result: Result<(), ManagerError>) -> Result<(), fidl::Error> {
3108        self.control_handle.inner.send::<fidl::encoding::ResultType<
3109            fidl::encoding::EmptyStruct,
3110            ManagerError,
3111        >>(
3112            result,
3113            self.tx_id,
3114            0x2af76679cd73b902,
3115            fidl::encoding::DynamicFlags::empty(),
3116        )
3117    }
3118}
3119
3120#[must_use = "FIDL methods require a response to be sent"]
3121#[derive(Debug)]
3122pub struct ManagerRemoveElementResponder {
3123    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
3124    tx_id: u32,
3125}
3126
3127/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
3128/// if the responder is dropped without sending a response, so that the client
3129/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3130impl std::ops::Drop for ManagerRemoveElementResponder {
3131    fn drop(&mut self) {
3132        self.control_handle.shutdown();
3133        // Safety: drops once, never accessed again
3134        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3135    }
3136}
3137
3138impl fidl::endpoints::Responder for ManagerRemoveElementResponder {
3139    type ControlHandle = ManagerControlHandle;
3140
3141    fn control_handle(&self) -> &ManagerControlHandle {
3142        &self.control_handle
3143    }
3144
3145    fn drop_without_shutdown(mut self) {
3146        // Safety: drops once, never accessed again due to mem::forget
3147        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3148        // Prevent Drop from running (which would shut down the channel)
3149        std::mem::forget(self);
3150    }
3151}
3152
3153impl ManagerRemoveElementResponder {
3154    /// Sends a response to the FIDL transaction.
3155    ///
3156    /// Sets the channel to shutdown if an error occurs.
3157    pub fn send(self, mut result: Result<(), ManagerError>) -> Result<(), fidl::Error> {
3158        let _result = self.send_raw(result);
3159        if _result.is_err() {
3160            self.control_handle.shutdown();
3161        }
3162        self.drop_without_shutdown();
3163        _result
3164    }
3165
3166    /// Similar to "send" but does not shutdown the channel if an error occurs.
3167    pub fn send_no_shutdown_on_err(
3168        self,
3169        mut result: Result<(), ManagerError>,
3170    ) -> Result<(), fidl::Error> {
3171        let _result = self.send_raw(result);
3172        self.drop_without_shutdown();
3173        _result
3174    }
3175
3176    fn send_raw(&self, mut result: Result<(), ManagerError>) -> Result<(), fidl::Error> {
3177        self.control_handle.inner.send::<fidl::encoding::ResultType<
3178            fidl::encoding::EmptyStruct,
3179            ManagerError,
3180        >>(
3181            result,
3182            self.tx_id,
3183            0x1e65d66515e64b52,
3184            fidl::encoding::DynamicFlags::empty(),
3185        )
3186    }
3187}
3188
3189#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3190pub struct ViewControllerMarker;
3191
3192impl fidl::endpoints::ProtocolMarker for ViewControllerMarker {
3193    type Proxy = ViewControllerProxy;
3194    type RequestStream = ViewControllerRequestStream;
3195    #[cfg(target_os = "fuchsia")]
3196    type SynchronousProxy = ViewControllerSynchronousProxy;
3197
3198    const DEBUG_NAME: &'static str = "(anonymous) ViewController";
3199}
3200
3201pub trait ViewControllerProxyInterface: Send + Sync {
3202    fn r#dismiss(&self) -> Result<(), fidl::Error>;
3203}
3204#[derive(Debug)]
3205#[cfg(target_os = "fuchsia")]
3206pub struct ViewControllerSynchronousProxy {
3207    client: fidl::client::sync::Client,
3208}
3209
3210#[cfg(target_os = "fuchsia")]
3211impl fidl::endpoints::SynchronousProxy for ViewControllerSynchronousProxy {
3212    type Proxy = ViewControllerProxy;
3213    type Protocol = ViewControllerMarker;
3214
3215    fn from_channel(inner: fidl::Channel) -> Self {
3216        Self::new(inner)
3217    }
3218
3219    fn into_channel(self) -> fidl::Channel {
3220        self.client.into_channel()
3221    }
3222
3223    fn as_channel(&self) -> &fidl::Channel {
3224        self.client.as_channel()
3225    }
3226}
3227
3228#[cfg(target_os = "fuchsia")]
3229impl ViewControllerSynchronousProxy {
3230    pub fn new(channel: fidl::Channel) -> Self {
3231        Self { client: fidl::client::sync::Client::new(channel) }
3232    }
3233
3234    pub fn into_channel(self) -> fidl::Channel {
3235        self.client.into_channel()
3236    }
3237
3238    /// Waits until an event arrives and returns it. It is safe for other
3239    /// threads to make concurrent requests while waiting for an event.
3240    pub fn wait_for_event(
3241        &self,
3242        deadline: zx::MonotonicInstant,
3243    ) -> Result<ViewControllerEvent, fidl::Error> {
3244        ViewControllerEvent::decode(self.client.wait_for_event::<ViewControllerMarker>(deadline)?)
3245    }
3246
3247    /// Instructs the presenter to dismiss the associated view. Once dismissed,
3248    /// the `ViewController` channel is closed with a `ZX_OK` epitaph. At this
3249    /// point, it is safe to clean up any resources (such as terminating
3250    /// a component) backing the view.
3251    ///
3252    /// Clients should call `Dismiss()` prior to closing the `ViewController`
3253    /// channel themselves.
3254    pub fn r#dismiss(&self) -> Result<(), fidl::Error> {
3255        self.client.send::<fidl::encoding::EmptyPayload>(
3256            (),
3257            0x794061fcab05a3dc,
3258            fidl::encoding::DynamicFlags::empty(),
3259        )
3260    }
3261}
3262
3263#[cfg(target_os = "fuchsia")]
3264impl From<ViewControllerSynchronousProxy> for zx::NullableHandle {
3265    fn from(value: ViewControllerSynchronousProxy) -> Self {
3266        value.into_channel().into()
3267    }
3268}
3269
3270#[cfg(target_os = "fuchsia")]
3271impl From<fidl::Channel> for ViewControllerSynchronousProxy {
3272    fn from(value: fidl::Channel) -> Self {
3273        Self::new(value)
3274    }
3275}
3276
3277#[cfg(target_os = "fuchsia")]
3278impl fidl::endpoints::FromClient for ViewControllerSynchronousProxy {
3279    type Protocol = ViewControllerMarker;
3280
3281    fn from_client(value: fidl::endpoints::ClientEnd<ViewControllerMarker>) -> Self {
3282        Self::new(value.into_channel())
3283    }
3284}
3285
3286#[derive(Debug, Clone)]
3287pub struct ViewControllerProxy {
3288    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3289}
3290
3291impl fidl::endpoints::Proxy for ViewControllerProxy {
3292    type Protocol = ViewControllerMarker;
3293
3294    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3295        Self::new(inner)
3296    }
3297
3298    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3299        self.client.into_channel().map_err(|client| Self { client })
3300    }
3301
3302    fn as_channel(&self) -> &::fidl::AsyncChannel {
3303        self.client.as_channel()
3304    }
3305}
3306
3307impl ViewControllerProxy {
3308    /// Create a new Proxy for fuchsia.element/ViewController.
3309    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3310        let protocol_name = <ViewControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3311        Self { client: fidl::client::Client::new(channel, protocol_name) }
3312    }
3313
3314    /// Get a Stream of events from the remote end of the protocol.
3315    ///
3316    /// # Panics
3317    ///
3318    /// Panics if the event stream was already taken.
3319    pub fn take_event_stream(&self) -> ViewControllerEventStream {
3320        ViewControllerEventStream { event_receiver: self.client.take_event_receiver() }
3321    }
3322
3323    /// Instructs the presenter to dismiss the associated view. Once dismissed,
3324    /// the `ViewController` channel is closed with a `ZX_OK` epitaph. At this
3325    /// point, it is safe to clean up any resources (such as terminating
3326    /// a component) backing the view.
3327    ///
3328    /// Clients should call `Dismiss()` prior to closing the `ViewController`
3329    /// channel themselves.
3330    pub fn r#dismiss(&self) -> Result<(), fidl::Error> {
3331        ViewControllerProxyInterface::r#dismiss(self)
3332    }
3333}
3334
3335impl ViewControllerProxyInterface for ViewControllerProxy {
3336    fn r#dismiss(&self) -> Result<(), fidl::Error> {
3337        self.client.send::<fidl::encoding::EmptyPayload>(
3338            (),
3339            0x794061fcab05a3dc,
3340            fidl::encoding::DynamicFlags::empty(),
3341        )
3342    }
3343}
3344
3345pub struct ViewControllerEventStream {
3346    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3347}
3348
3349impl std::marker::Unpin for ViewControllerEventStream {}
3350
3351impl futures::stream::FusedStream for ViewControllerEventStream {
3352    fn is_terminated(&self) -> bool {
3353        self.event_receiver.is_terminated()
3354    }
3355}
3356
3357impl futures::Stream for ViewControllerEventStream {
3358    type Item = Result<ViewControllerEvent, fidl::Error>;
3359
3360    fn poll_next(
3361        mut self: std::pin::Pin<&mut Self>,
3362        cx: &mut std::task::Context<'_>,
3363    ) -> std::task::Poll<Option<Self::Item>> {
3364        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3365            &mut self.event_receiver,
3366            cx
3367        )?) {
3368            Some(buf) => std::task::Poll::Ready(Some(ViewControllerEvent::decode(buf))),
3369            None => std::task::Poll::Ready(None),
3370        }
3371    }
3372}
3373
3374#[derive(Debug)]
3375pub enum ViewControllerEvent {
3376    OnPresented {},
3377}
3378
3379impl ViewControllerEvent {
3380    #[allow(irrefutable_let_patterns)]
3381    pub fn into_on_presented(self) -> Option<()> {
3382        if let ViewControllerEvent::OnPresented {} = self { Some(()) } else { None }
3383    }
3384
3385    /// Decodes a message buffer as a [`ViewControllerEvent`].
3386    fn decode(
3387        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3388    ) -> Result<ViewControllerEvent, fidl::Error> {
3389        let (bytes, _handles) = buf.split_mut();
3390        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3391        debug_assert_eq!(tx_header.tx_id, 0);
3392        match tx_header.ordinal {
3393            0x26977e68369330b5 => {
3394                let mut out = fidl::new_empty!(
3395                    fidl::encoding::EmptyPayload,
3396                    fidl::encoding::DefaultFuchsiaResourceDialect
3397                );
3398                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3399                Ok((ViewControllerEvent::OnPresented {}))
3400            }
3401            _ => Err(fidl::Error::UnknownOrdinal {
3402                ordinal: tx_header.ordinal,
3403                protocol_name:
3404                    <ViewControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3405            }),
3406        }
3407    }
3408}
3409
3410/// A Stream of incoming requests for fuchsia.element/ViewController.
3411pub struct ViewControllerRequestStream {
3412    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3413    is_terminated: bool,
3414}
3415
3416impl std::marker::Unpin for ViewControllerRequestStream {}
3417
3418impl futures::stream::FusedStream for ViewControllerRequestStream {
3419    fn is_terminated(&self) -> bool {
3420        self.is_terminated
3421    }
3422}
3423
3424impl fidl::endpoints::RequestStream for ViewControllerRequestStream {
3425    type Protocol = ViewControllerMarker;
3426    type ControlHandle = ViewControllerControlHandle;
3427
3428    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3429        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3430    }
3431
3432    fn control_handle(&self) -> Self::ControlHandle {
3433        ViewControllerControlHandle { inner: self.inner.clone() }
3434    }
3435
3436    fn into_inner(
3437        self,
3438    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3439    {
3440        (self.inner, self.is_terminated)
3441    }
3442
3443    fn from_inner(
3444        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3445        is_terminated: bool,
3446    ) -> Self {
3447        Self { inner, is_terminated }
3448    }
3449}
3450
3451impl futures::Stream for ViewControllerRequestStream {
3452    type Item = Result<ViewControllerRequest, fidl::Error>;
3453
3454    fn poll_next(
3455        mut self: std::pin::Pin<&mut Self>,
3456        cx: &mut std::task::Context<'_>,
3457    ) -> std::task::Poll<Option<Self::Item>> {
3458        let this = &mut *self;
3459        if this.inner.check_shutdown(cx) {
3460            this.is_terminated = true;
3461            return std::task::Poll::Ready(None);
3462        }
3463        if this.is_terminated {
3464            panic!("polled ViewControllerRequestStream after completion");
3465        }
3466        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3467            |bytes, handles| {
3468                match this.inner.channel().read_etc(cx, bytes, handles) {
3469                    std::task::Poll::Ready(Ok(())) => {}
3470                    std::task::Poll::Pending => return std::task::Poll::Pending,
3471                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3472                        this.is_terminated = true;
3473                        return std::task::Poll::Ready(None);
3474                    }
3475                    std::task::Poll::Ready(Err(e)) => {
3476                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3477                            e.into(),
3478                        ))));
3479                    }
3480                }
3481
3482                // A message has been received from the channel
3483                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3484
3485                std::task::Poll::Ready(Some(match header.ordinal {
3486                    0x794061fcab05a3dc => {
3487                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3488                        let mut req = fidl::new_empty!(
3489                            fidl::encoding::EmptyPayload,
3490                            fidl::encoding::DefaultFuchsiaResourceDialect
3491                        );
3492                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3493                        let control_handle =
3494                            ViewControllerControlHandle { inner: this.inner.clone() };
3495                        Ok(ViewControllerRequest::Dismiss { control_handle })
3496                    }
3497                    _ => Err(fidl::Error::UnknownOrdinal {
3498                        ordinal: header.ordinal,
3499                        protocol_name:
3500                            <ViewControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3501                    }),
3502                }))
3503            },
3504        )
3505    }
3506}
3507
3508/// Gives clients of `GraphicalPresenter` control over an individual view
3509/// presented through `PresentView()`.
3510#[derive(Debug)]
3511pub enum ViewControllerRequest {
3512    /// Instructs the presenter to dismiss the associated view. Once dismissed,
3513    /// the `ViewController` channel is closed with a `ZX_OK` epitaph. At this
3514    /// point, it is safe to clean up any resources (such as terminating
3515    /// a component) backing the view.
3516    ///
3517    /// Clients should call `Dismiss()` prior to closing the `ViewController`
3518    /// channel themselves.
3519    Dismiss { control_handle: ViewControllerControlHandle },
3520}
3521
3522impl ViewControllerRequest {
3523    #[allow(irrefutable_let_patterns)]
3524    pub fn into_dismiss(self) -> Option<(ViewControllerControlHandle)> {
3525        if let ViewControllerRequest::Dismiss { control_handle } = self {
3526            Some((control_handle))
3527        } else {
3528            None
3529        }
3530    }
3531
3532    /// Name of the method defined in FIDL
3533    pub fn method_name(&self) -> &'static str {
3534        match *self {
3535            ViewControllerRequest::Dismiss { .. } => "dismiss",
3536        }
3537    }
3538}
3539
3540#[derive(Debug, Clone)]
3541pub struct ViewControllerControlHandle {
3542    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3543}
3544
3545impl fidl::endpoints::ControlHandle for ViewControllerControlHandle {
3546    fn shutdown(&self) {
3547        self.inner.shutdown()
3548    }
3549
3550    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3551        self.inner.shutdown_with_epitaph(status)
3552    }
3553
3554    fn is_closed(&self) -> bool {
3555        self.inner.channel().is_closed()
3556    }
3557    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3558        self.inner.channel().on_closed()
3559    }
3560
3561    #[cfg(target_os = "fuchsia")]
3562    fn signal_peer(
3563        &self,
3564        clear_mask: zx::Signals,
3565        set_mask: zx::Signals,
3566    ) -> Result<(), zx_status::Status> {
3567        use fidl::Peered;
3568        self.inner.channel().signal_peer(clear_mask, set_mask)
3569    }
3570}
3571
3572impl ViewControllerControlHandle {
3573    pub fn send_on_presented(&self) -> Result<(), fidl::Error> {
3574        self.inner.send::<fidl::encoding::EmptyPayload>(
3575            (),
3576            0,
3577            0x26977e68369330b5,
3578            fidl::encoding::DynamicFlags::empty(),
3579        )
3580    }
3581}
3582
3583mod internal {
3584    use super::*;
3585
3586    impl fidl::encoding::ResourceTypeMarker for Annotation {
3587        type Borrowed<'a> = &'a mut Self;
3588        fn take_or_borrow<'a>(
3589            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3590        ) -> Self::Borrowed<'a> {
3591            value
3592        }
3593    }
3594
3595    unsafe impl fidl::encoding::TypeMarker for Annotation {
3596        type Owned = Self;
3597
3598        #[inline(always)]
3599        fn inline_align(_context: fidl::encoding::Context) -> usize {
3600            8
3601        }
3602
3603        #[inline(always)]
3604        fn inline_size(_context: fidl::encoding::Context) -> usize {
3605            48
3606        }
3607    }
3608
3609    unsafe impl fidl::encoding::Encode<Annotation, fidl::encoding::DefaultFuchsiaResourceDialect>
3610        for &mut Annotation
3611    {
3612        #[inline]
3613        unsafe fn encode(
3614            self,
3615            encoder: &mut fidl::encoding::Encoder<
3616                '_,
3617                fidl::encoding::DefaultFuchsiaResourceDialect,
3618            >,
3619            offset: usize,
3620            _depth: fidl::encoding::Depth,
3621        ) -> fidl::Result<()> {
3622            encoder.debug_check_bounds::<Annotation>(offset);
3623            // Delegate to tuple encoding.
3624            fidl::encoding::Encode::<Annotation, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3625                (
3626                    <AnnotationKey as fidl::encoding::ValueTypeMarker>::borrow(&self.key),
3627                    <AnnotationValue as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
3628                ),
3629                encoder, offset, _depth
3630            )
3631        }
3632    }
3633    unsafe impl<
3634        T0: fidl::encoding::Encode<AnnotationKey, fidl::encoding::DefaultFuchsiaResourceDialect>,
3635        T1: fidl::encoding::Encode<AnnotationValue, fidl::encoding::DefaultFuchsiaResourceDialect>,
3636    > fidl::encoding::Encode<Annotation, fidl::encoding::DefaultFuchsiaResourceDialect>
3637        for (T0, T1)
3638    {
3639        #[inline]
3640        unsafe fn encode(
3641            self,
3642            encoder: &mut fidl::encoding::Encoder<
3643                '_,
3644                fidl::encoding::DefaultFuchsiaResourceDialect,
3645            >,
3646            offset: usize,
3647            depth: fidl::encoding::Depth,
3648        ) -> fidl::Result<()> {
3649            encoder.debug_check_bounds::<Annotation>(offset);
3650            // Zero out padding regions. There's no need to apply masks
3651            // because the unmasked parts will be overwritten by fields.
3652            // Write the fields.
3653            self.0.encode(encoder, offset + 0, depth)?;
3654            self.1.encode(encoder, offset + 32, depth)?;
3655            Ok(())
3656        }
3657    }
3658
3659    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Annotation {
3660        #[inline(always)]
3661        fn new_empty() -> Self {
3662            Self {
3663                key: fidl::new_empty!(AnnotationKey, fidl::encoding::DefaultFuchsiaResourceDialect),
3664                value: fidl::new_empty!(
3665                    AnnotationValue,
3666                    fidl::encoding::DefaultFuchsiaResourceDialect
3667                ),
3668            }
3669        }
3670
3671        #[inline]
3672        unsafe fn decode(
3673            &mut self,
3674            decoder: &mut fidl::encoding::Decoder<
3675                '_,
3676                fidl::encoding::DefaultFuchsiaResourceDialect,
3677            >,
3678            offset: usize,
3679            _depth: fidl::encoding::Depth,
3680        ) -> fidl::Result<()> {
3681            decoder.debug_check_bounds::<Self>(offset);
3682            // Verify that padding bytes are zero.
3683            fidl::decode!(
3684                AnnotationKey,
3685                fidl::encoding::DefaultFuchsiaResourceDialect,
3686                &mut self.key,
3687                decoder,
3688                offset + 0,
3689                _depth
3690            )?;
3691            fidl::decode!(
3692                AnnotationValue,
3693                fidl::encoding::DefaultFuchsiaResourceDialect,
3694                &mut self.value,
3695                decoder,
3696                offset + 32,
3697                _depth
3698            )?;
3699            Ok(())
3700        }
3701    }
3702
3703    impl fidl::encoding::ResourceTypeMarker for AnnotationControllerUpdateAnnotationsRequest {
3704        type Borrowed<'a> = &'a mut Self;
3705        fn take_or_borrow<'a>(
3706            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3707        ) -> Self::Borrowed<'a> {
3708            value
3709        }
3710    }
3711
3712    unsafe impl fidl::encoding::TypeMarker for AnnotationControllerUpdateAnnotationsRequest {
3713        type Owned = Self;
3714
3715        #[inline(always)]
3716        fn inline_align(_context: fidl::encoding::Context) -> usize {
3717            8
3718        }
3719
3720        #[inline(always)]
3721        fn inline_size(_context: fidl::encoding::Context) -> usize {
3722            32
3723        }
3724    }
3725
3726    unsafe impl
3727        fidl::encoding::Encode<
3728            AnnotationControllerUpdateAnnotationsRequest,
3729            fidl::encoding::DefaultFuchsiaResourceDialect,
3730        > for &mut AnnotationControllerUpdateAnnotationsRequest
3731    {
3732        #[inline]
3733        unsafe fn encode(
3734            self,
3735            encoder: &mut fidl::encoding::Encoder<
3736                '_,
3737                fidl::encoding::DefaultFuchsiaResourceDialect,
3738            >,
3739            offset: usize,
3740            _depth: fidl::encoding::Depth,
3741        ) -> fidl::Result<()> {
3742            encoder.debug_check_bounds::<AnnotationControllerUpdateAnnotationsRequest>(offset);
3743            // Delegate to tuple encoding.
3744            fidl::encoding::Encode::<AnnotationControllerUpdateAnnotationsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3745                (
3746                    <fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.annotations_to_set),
3747                    <fidl::encoding::Vector<AnnotationKey, 1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.annotations_to_delete),
3748                ),
3749                encoder, offset, _depth
3750            )
3751        }
3752    }
3753    unsafe impl<
3754        T0: fidl::encoding::Encode<
3755                fidl::encoding::Vector<Annotation, 1024>,
3756                fidl::encoding::DefaultFuchsiaResourceDialect,
3757            >,
3758        T1: fidl::encoding::Encode<
3759                fidl::encoding::Vector<AnnotationKey, 1024>,
3760                fidl::encoding::DefaultFuchsiaResourceDialect,
3761            >,
3762    >
3763        fidl::encoding::Encode<
3764            AnnotationControllerUpdateAnnotationsRequest,
3765            fidl::encoding::DefaultFuchsiaResourceDialect,
3766        > for (T0, T1)
3767    {
3768        #[inline]
3769        unsafe fn encode(
3770            self,
3771            encoder: &mut fidl::encoding::Encoder<
3772                '_,
3773                fidl::encoding::DefaultFuchsiaResourceDialect,
3774            >,
3775            offset: usize,
3776            depth: fidl::encoding::Depth,
3777        ) -> fidl::Result<()> {
3778            encoder.debug_check_bounds::<AnnotationControllerUpdateAnnotationsRequest>(offset);
3779            // Zero out padding regions. There's no need to apply masks
3780            // because the unmasked parts will be overwritten by fields.
3781            // Write the fields.
3782            self.0.encode(encoder, offset + 0, depth)?;
3783            self.1.encode(encoder, offset + 16, depth)?;
3784            Ok(())
3785        }
3786    }
3787
3788    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3789        for AnnotationControllerUpdateAnnotationsRequest
3790    {
3791        #[inline(always)]
3792        fn new_empty() -> Self {
3793            Self {
3794                annotations_to_set: fidl::new_empty!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect),
3795                annotations_to_delete: fidl::new_empty!(fidl::encoding::Vector<AnnotationKey, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect),
3796            }
3797        }
3798
3799        #[inline]
3800        unsafe fn decode(
3801            &mut self,
3802            decoder: &mut fidl::encoding::Decoder<
3803                '_,
3804                fidl::encoding::DefaultFuchsiaResourceDialect,
3805            >,
3806            offset: usize,
3807            _depth: fidl::encoding::Depth,
3808        ) -> fidl::Result<()> {
3809            decoder.debug_check_bounds::<Self>(offset);
3810            // Verify that padding bytes are zero.
3811            fidl::decode!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.annotations_to_set, decoder, offset + 0, _depth)?;
3812            fidl::decode!(fidl::encoding::Vector<AnnotationKey, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.annotations_to_delete, decoder, offset + 16, _depth)?;
3813            Ok(())
3814        }
3815    }
3816
3817    impl fidl::encoding::ResourceTypeMarker for AnnotationControllerGetAnnotationsResponse {
3818        type Borrowed<'a> = &'a mut Self;
3819        fn take_or_borrow<'a>(
3820            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3821        ) -> Self::Borrowed<'a> {
3822            value
3823        }
3824    }
3825
3826    unsafe impl fidl::encoding::TypeMarker for AnnotationControllerGetAnnotationsResponse {
3827        type Owned = Self;
3828
3829        #[inline(always)]
3830        fn inline_align(_context: fidl::encoding::Context) -> usize {
3831            8
3832        }
3833
3834        #[inline(always)]
3835        fn inline_size(_context: fidl::encoding::Context) -> usize {
3836            16
3837        }
3838    }
3839
3840    unsafe impl
3841        fidl::encoding::Encode<
3842            AnnotationControllerGetAnnotationsResponse,
3843            fidl::encoding::DefaultFuchsiaResourceDialect,
3844        > for &mut AnnotationControllerGetAnnotationsResponse
3845    {
3846        #[inline]
3847        unsafe fn encode(
3848            self,
3849            encoder: &mut fidl::encoding::Encoder<
3850                '_,
3851                fidl::encoding::DefaultFuchsiaResourceDialect,
3852            >,
3853            offset: usize,
3854            _depth: fidl::encoding::Depth,
3855        ) -> fidl::Result<()> {
3856            encoder.debug_check_bounds::<AnnotationControllerGetAnnotationsResponse>(offset);
3857            // Delegate to tuple encoding.
3858            fidl::encoding::Encode::<AnnotationControllerGetAnnotationsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3859                (
3860                    <fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.annotations),
3861                ),
3862                encoder, offset, _depth
3863            )
3864        }
3865    }
3866    unsafe impl<
3867        T0: fidl::encoding::Encode<
3868                fidl::encoding::Vector<Annotation, 1024>,
3869                fidl::encoding::DefaultFuchsiaResourceDialect,
3870            >,
3871    >
3872        fidl::encoding::Encode<
3873            AnnotationControllerGetAnnotationsResponse,
3874            fidl::encoding::DefaultFuchsiaResourceDialect,
3875        > for (T0,)
3876    {
3877        #[inline]
3878        unsafe fn encode(
3879            self,
3880            encoder: &mut fidl::encoding::Encoder<
3881                '_,
3882                fidl::encoding::DefaultFuchsiaResourceDialect,
3883            >,
3884            offset: usize,
3885            depth: fidl::encoding::Depth,
3886        ) -> fidl::Result<()> {
3887            encoder.debug_check_bounds::<AnnotationControllerGetAnnotationsResponse>(offset);
3888            // Zero out padding regions. There's no need to apply masks
3889            // because the unmasked parts will be overwritten by fields.
3890            // Write the fields.
3891            self.0.encode(encoder, offset + 0, depth)?;
3892            Ok(())
3893        }
3894    }
3895
3896    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3897        for AnnotationControllerGetAnnotationsResponse
3898    {
3899        #[inline(always)]
3900        fn new_empty() -> Self {
3901            Self {
3902                annotations: fidl::new_empty!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect),
3903            }
3904        }
3905
3906        #[inline]
3907        unsafe fn decode(
3908            &mut self,
3909            decoder: &mut fidl::encoding::Decoder<
3910                '_,
3911                fidl::encoding::DefaultFuchsiaResourceDialect,
3912            >,
3913            offset: usize,
3914            _depth: fidl::encoding::Depth,
3915        ) -> fidl::Result<()> {
3916            decoder.debug_check_bounds::<Self>(offset);
3917            // Verify that padding bytes are zero.
3918            fidl::decode!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.annotations, decoder, offset + 0, _depth)?;
3919            Ok(())
3920        }
3921    }
3922
3923    impl fidl::encoding::ResourceTypeMarker for AnnotationControllerWatchAnnotationsResponse {
3924        type Borrowed<'a> = &'a mut Self;
3925        fn take_or_borrow<'a>(
3926            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3927        ) -> Self::Borrowed<'a> {
3928            value
3929        }
3930    }
3931
3932    unsafe impl fidl::encoding::TypeMarker for AnnotationControllerWatchAnnotationsResponse {
3933        type Owned = Self;
3934
3935        #[inline(always)]
3936        fn inline_align(_context: fidl::encoding::Context) -> usize {
3937            8
3938        }
3939
3940        #[inline(always)]
3941        fn inline_size(_context: fidl::encoding::Context) -> usize {
3942            16
3943        }
3944    }
3945
3946    unsafe impl
3947        fidl::encoding::Encode<
3948            AnnotationControllerWatchAnnotationsResponse,
3949            fidl::encoding::DefaultFuchsiaResourceDialect,
3950        > for &mut AnnotationControllerWatchAnnotationsResponse
3951    {
3952        #[inline]
3953        unsafe fn encode(
3954            self,
3955            encoder: &mut fidl::encoding::Encoder<
3956                '_,
3957                fidl::encoding::DefaultFuchsiaResourceDialect,
3958            >,
3959            offset: usize,
3960            _depth: fidl::encoding::Depth,
3961        ) -> fidl::Result<()> {
3962            encoder.debug_check_bounds::<AnnotationControllerWatchAnnotationsResponse>(offset);
3963            // Delegate to tuple encoding.
3964            fidl::encoding::Encode::<AnnotationControllerWatchAnnotationsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3965                (
3966                    <fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.annotations),
3967                ),
3968                encoder, offset, _depth
3969            )
3970        }
3971    }
3972    unsafe impl<
3973        T0: fidl::encoding::Encode<
3974                fidl::encoding::Vector<Annotation, 1024>,
3975                fidl::encoding::DefaultFuchsiaResourceDialect,
3976            >,
3977    >
3978        fidl::encoding::Encode<
3979            AnnotationControllerWatchAnnotationsResponse,
3980            fidl::encoding::DefaultFuchsiaResourceDialect,
3981        > for (T0,)
3982    {
3983        #[inline]
3984        unsafe fn encode(
3985            self,
3986            encoder: &mut fidl::encoding::Encoder<
3987                '_,
3988                fidl::encoding::DefaultFuchsiaResourceDialect,
3989            >,
3990            offset: usize,
3991            depth: fidl::encoding::Depth,
3992        ) -> fidl::Result<()> {
3993            encoder.debug_check_bounds::<AnnotationControllerWatchAnnotationsResponse>(offset);
3994            // Zero out padding regions. There's no need to apply masks
3995            // because the unmasked parts will be overwritten by fields.
3996            // Write the fields.
3997            self.0.encode(encoder, offset + 0, depth)?;
3998            Ok(())
3999        }
4000    }
4001
4002    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4003        for AnnotationControllerWatchAnnotationsResponse
4004    {
4005        #[inline(always)]
4006        fn new_empty() -> Self {
4007            Self {
4008                annotations: fidl::new_empty!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect),
4009            }
4010        }
4011
4012        #[inline]
4013        unsafe fn decode(
4014            &mut self,
4015            decoder: &mut fidl::encoding::Decoder<
4016                '_,
4017                fidl::encoding::DefaultFuchsiaResourceDialect,
4018            >,
4019            offset: usize,
4020            _depth: fidl::encoding::Depth,
4021        ) -> fidl::Result<()> {
4022            decoder.debug_check_bounds::<Self>(offset);
4023            // Verify that padding bytes are zero.
4024            fidl::decode!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.annotations, decoder, offset + 0, _depth)?;
4025            Ok(())
4026        }
4027    }
4028
4029    impl fidl::encoding::ResourceTypeMarker for GraphicalPresenterPresentViewRequest {
4030        type Borrowed<'a> = &'a mut Self;
4031        fn take_or_borrow<'a>(
4032            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4033        ) -> Self::Borrowed<'a> {
4034            value
4035        }
4036    }
4037
4038    unsafe impl fidl::encoding::TypeMarker for GraphicalPresenterPresentViewRequest {
4039        type Owned = Self;
4040
4041        #[inline(always)]
4042        fn inline_align(_context: fidl::encoding::Context) -> usize {
4043            8
4044        }
4045
4046        #[inline(always)]
4047        fn inline_size(_context: fidl::encoding::Context) -> usize {
4048            24
4049        }
4050    }
4051
4052    unsafe impl
4053        fidl::encoding::Encode<
4054            GraphicalPresenterPresentViewRequest,
4055            fidl::encoding::DefaultFuchsiaResourceDialect,
4056        > for &mut GraphicalPresenterPresentViewRequest
4057    {
4058        #[inline]
4059        unsafe fn encode(
4060            self,
4061            encoder: &mut fidl::encoding::Encoder<
4062                '_,
4063                fidl::encoding::DefaultFuchsiaResourceDialect,
4064            >,
4065            offset: usize,
4066            _depth: fidl::encoding::Depth,
4067        ) -> fidl::Result<()> {
4068            encoder.debug_check_bounds::<GraphicalPresenterPresentViewRequest>(offset);
4069            // Delegate to tuple encoding.
4070            fidl::encoding::Encode::<
4071                GraphicalPresenterPresentViewRequest,
4072                fidl::encoding::DefaultFuchsiaResourceDialect,
4073            >::encode(
4074                (
4075                    <ViewSpec as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4076                        &mut self.view_spec,
4077                    ),
4078                    <fidl::encoding::Optional<
4079                        fidl::encoding::Endpoint<
4080                            fidl::endpoints::ClientEnd<AnnotationControllerMarker>,
4081                        >,
4082                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4083                        &mut self.annotation_controller,
4084                    ),
4085                    <fidl::encoding::Optional<
4086                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
4087                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4088                        &mut self.view_controller_request,
4089                    ),
4090                ),
4091                encoder,
4092                offset,
4093                _depth,
4094            )
4095        }
4096    }
4097    unsafe impl<
4098        T0: fidl::encoding::Encode<ViewSpec, fidl::encoding::DefaultFuchsiaResourceDialect>,
4099        T1: fidl::encoding::Encode<
4100                fidl::encoding::Optional<
4101                    fidl::encoding::Endpoint<
4102                        fidl::endpoints::ClientEnd<AnnotationControllerMarker>,
4103                    >,
4104                >,
4105                fidl::encoding::DefaultFuchsiaResourceDialect,
4106            >,
4107        T2: fidl::encoding::Encode<
4108                fidl::encoding::Optional<
4109                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
4110                >,
4111                fidl::encoding::DefaultFuchsiaResourceDialect,
4112            >,
4113    >
4114        fidl::encoding::Encode<
4115            GraphicalPresenterPresentViewRequest,
4116            fidl::encoding::DefaultFuchsiaResourceDialect,
4117        > for (T0, T1, T2)
4118    {
4119        #[inline]
4120        unsafe fn encode(
4121            self,
4122            encoder: &mut fidl::encoding::Encoder<
4123                '_,
4124                fidl::encoding::DefaultFuchsiaResourceDialect,
4125            >,
4126            offset: usize,
4127            depth: fidl::encoding::Depth,
4128        ) -> fidl::Result<()> {
4129            encoder.debug_check_bounds::<GraphicalPresenterPresentViewRequest>(offset);
4130            // Zero out padding regions. There's no need to apply masks
4131            // because the unmasked parts will be overwritten by fields.
4132            // Write the fields.
4133            self.0.encode(encoder, offset + 0, depth)?;
4134            self.1.encode(encoder, offset + 16, depth)?;
4135            self.2.encode(encoder, offset + 20, depth)?;
4136            Ok(())
4137        }
4138    }
4139
4140    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4141        for GraphicalPresenterPresentViewRequest
4142    {
4143        #[inline(always)]
4144        fn new_empty() -> Self {
4145            Self {
4146                view_spec: fidl::new_empty!(
4147                    ViewSpec,
4148                    fidl::encoding::DefaultFuchsiaResourceDialect
4149                ),
4150                annotation_controller: fidl::new_empty!(
4151                    fidl::encoding::Optional<
4152                        fidl::encoding::Endpoint<
4153                            fidl::endpoints::ClientEnd<AnnotationControllerMarker>,
4154                        >,
4155                    >,
4156                    fidl::encoding::DefaultFuchsiaResourceDialect
4157                ),
4158                view_controller_request: fidl::new_empty!(
4159                    fidl::encoding::Optional<
4160                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
4161                    >,
4162                    fidl::encoding::DefaultFuchsiaResourceDialect
4163                ),
4164            }
4165        }
4166
4167        #[inline]
4168        unsafe fn decode(
4169            &mut self,
4170            decoder: &mut fidl::encoding::Decoder<
4171                '_,
4172                fidl::encoding::DefaultFuchsiaResourceDialect,
4173            >,
4174            offset: usize,
4175            _depth: fidl::encoding::Depth,
4176        ) -> fidl::Result<()> {
4177            decoder.debug_check_bounds::<Self>(offset);
4178            // Verify that padding bytes are zero.
4179            fidl::decode!(
4180                ViewSpec,
4181                fidl::encoding::DefaultFuchsiaResourceDialect,
4182                &mut self.view_spec,
4183                decoder,
4184                offset + 0,
4185                _depth
4186            )?;
4187            fidl::decode!(
4188                fidl::encoding::Optional<
4189                    fidl::encoding::Endpoint<
4190                        fidl::endpoints::ClientEnd<AnnotationControllerMarker>,
4191                    >,
4192                >,
4193                fidl::encoding::DefaultFuchsiaResourceDialect,
4194                &mut self.annotation_controller,
4195                decoder,
4196                offset + 16,
4197                _depth
4198            )?;
4199            fidl::decode!(
4200                fidl::encoding::Optional<
4201                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ViewControllerMarker>>,
4202                >,
4203                fidl::encoding::DefaultFuchsiaResourceDialect,
4204                &mut self.view_controller_request,
4205                decoder,
4206                offset + 20,
4207                _depth
4208            )?;
4209            Ok(())
4210        }
4211    }
4212
4213    impl fidl::encoding::ResourceTypeMarker for ManagerProposeElementRequest {
4214        type Borrowed<'a> = &'a mut Self;
4215        fn take_or_borrow<'a>(
4216            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4217        ) -> Self::Borrowed<'a> {
4218            value
4219        }
4220    }
4221
4222    unsafe impl fidl::encoding::TypeMarker for ManagerProposeElementRequest {
4223        type Owned = Self;
4224
4225        #[inline(always)]
4226        fn inline_align(_context: fidl::encoding::Context) -> usize {
4227            8
4228        }
4229
4230        #[inline(always)]
4231        fn inline_size(_context: fidl::encoding::Context) -> usize {
4232            24
4233        }
4234    }
4235
4236    unsafe impl
4237        fidl::encoding::Encode<
4238            ManagerProposeElementRequest,
4239            fidl::encoding::DefaultFuchsiaResourceDialect,
4240        > for &mut ManagerProposeElementRequest
4241    {
4242        #[inline]
4243        unsafe fn encode(
4244            self,
4245            encoder: &mut fidl::encoding::Encoder<
4246                '_,
4247                fidl::encoding::DefaultFuchsiaResourceDialect,
4248            >,
4249            offset: usize,
4250            _depth: fidl::encoding::Depth,
4251        ) -> fidl::Result<()> {
4252            encoder.debug_check_bounds::<ManagerProposeElementRequest>(offset);
4253            // Delegate to tuple encoding.
4254            fidl::encoding::Encode::<
4255                ManagerProposeElementRequest,
4256                fidl::encoding::DefaultFuchsiaResourceDialect,
4257            >::encode(
4258                (
4259                    <Spec as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.spec),
4260                    <fidl::encoding::Optional<
4261                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerMarker>>,
4262                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4263                        &mut self.controller
4264                    ),
4265                ),
4266                encoder,
4267                offset,
4268                _depth,
4269            )
4270        }
4271    }
4272    unsafe impl<
4273        T0: fidl::encoding::Encode<Spec, fidl::encoding::DefaultFuchsiaResourceDialect>,
4274        T1: fidl::encoding::Encode<
4275                fidl::encoding::Optional<
4276                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerMarker>>,
4277                >,
4278                fidl::encoding::DefaultFuchsiaResourceDialect,
4279            >,
4280    >
4281        fidl::encoding::Encode<
4282            ManagerProposeElementRequest,
4283            fidl::encoding::DefaultFuchsiaResourceDialect,
4284        > for (T0, T1)
4285    {
4286        #[inline]
4287        unsafe fn encode(
4288            self,
4289            encoder: &mut fidl::encoding::Encoder<
4290                '_,
4291                fidl::encoding::DefaultFuchsiaResourceDialect,
4292            >,
4293            offset: usize,
4294            depth: fidl::encoding::Depth,
4295        ) -> fidl::Result<()> {
4296            encoder.debug_check_bounds::<ManagerProposeElementRequest>(offset);
4297            // Zero out padding regions. There's no need to apply masks
4298            // because the unmasked parts will be overwritten by fields.
4299            unsafe {
4300                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4301                (ptr as *mut u64).write_unaligned(0);
4302            }
4303            // Write the fields.
4304            self.0.encode(encoder, offset + 0, depth)?;
4305            self.1.encode(encoder, offset + 16, depth)?;
4306            Ok(())
4307        }
4308    }
4309
4310    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4311        for ManagerProposeElementRequest
4312    {
4313        #[inline(always)]
4314        fn new_empty() -> Self {
4315            Self {
4316                spec: fidl::new_empty!(Spec, fidl::encoding::DefaultFuchsiaResourceDialect),
4317                controller: fidl::new_empty!(
4318                    fidl::encoding::Optional<
4319                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerMarker>>,
4320                    >,
4321                    fidl::encoding::DefaultFuchsiaResourceDialect
4322                ),
4323            }
4324        }
4325
4326        #[inline]
4327        unsafe fn decode(
4328            &mut self,
4329            decoder: &mut fidl::encoding::Decoder<
4330                '_,
4331                fidl::encoding::DefaultFuchsiaResourceDialect,
4332            >,
4333            offset: usize,
4334            _depth: fidl::encoding::Depth,
4335        ) -> fidl::Result<()> {
4336            decoder.debug_check_bounds::<Self>(offset);
4337            // Verify that padding bytes are zero.
4338            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
4339            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4340            let mask = 0xffffffff00000000u64;
4341            let maskedval = padval & mask;
4342            if maskedval != 0 {
4343                return Err(fidl::Error::NonZeroPadding {
4344                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
4345                });
4346            }
4347            fidl::decode!(
4348                Spec,
4349                fidl::encoding::DefaultFuchsiaResourceDialect,
4350                &mut self.spec,
4351                decoder,
4352                offset + 0,
4353                _depth
4354            )?;
4355            fidl::decode!(
4356                fidl::encoding::Optional<
4357                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControllerMarker>>,
4358                >,
4359                fidl::encoding::DefaultFuchsiaResourceDialect,
4360                &mut self.controller,
4361                decoder,
4362                offset + 16,
4363                _depth
4364            )?;
4365            Ok(())
4366        }
4367    }
4368
4369    impl Spec {
4370        #[inline(always)]
4371        fn max_ordinal_present(&self) -> u64 {
4372            if let Some(_) = self.annotations {
4373                return 2;
4374            }
4375            if let Some(_) = self.component_url {
4376                return 1;
4377            }
4378            0
4379        }
4380    }
4381
4382    impl fidl::encoding::ResourceTypeMarker for Spec {
4383        type Borrowed<'a> = &'a mut Self;
4384        fn take_or_borrow<'a>(
4385            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4386        ) -> Self::Borrowed<'a> {
4387            value
4388        }
4389    }
4390
4391    unsafe impl fidl::encoding::TypeMarker for Spec {
4392        type Owned = Self;
4393
4394        #[inline(always)]
4395        fn inline_align(_context: fidl::encoding::Context) -> usize {
4396            8
4397        }
4398
4399        #[inline(always)]
4400        fn inline_size(_context: fidl::encoding::Context) -> usize {
4401            16
4402        }
4403    }
4404
4405    unsafe impl fidl::encoding::Encode<Spec, fidl::encoding::DefaultFuchsiaResourceDialect>
4406        for &mut Spec
4407    {
4408        unsafe fn encode(
4409            self,
4410            encoder: &mut fidl::encoding::Encoder<
4411                '_,
4412                fidl::encoding::DefaultFuchsiaResourceDialect,
4413            >,
4414            offset: usize,
4415            mut depth: fidl::encoding::Depth,
4416        ) -> fidl::Result<()> {
4417            encoder.debug_check_bounds::<Spec>(offset);
4418            // Vector header
4419            let max_ordinal: u64 = self.max_ordinal_present();
4420            encoder.write_num(max_ordinal, offset);
4421            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4422            // Calling encoder.out_of_line_offset(0) is not allowed.
4423            if max_ordinal == 0 {
4424                return Ok(());
4425            }
4426            depth.increment()?;
4427            let envelope_size = 8;
4428            let bytes_len = max_ordinal as usize * envelope_size;
4429            #[allow(unused_variables)]
4430            let offset = encoder.out_of_line_offset(bytes_len);
4431            let mut _prev_end_offset: usize = 0;
4432            if 1 > max_ordinal {
4433                return Ok(());
4434            }
4435
4436            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4437            // are envelope_size bytes.
4438            let cur_offset: usize = (1 - 1) * envelope_size;
4439
4440            // Zero reserved fields.
4441            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4442
4443            // Safety:
4444            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4445            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4446            //   envelope_size bytes, there is always sufficient room.
4447            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4448            self.component_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
4449            encoder, offset + cur_offset, depth
4450        )?;
4451
4452            _prev_end_offset = cur_offset + envelope_size;
4453            if 2 > max_ordinal {
4454                return Ok(());
4455            }
4456
4457            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4458            // are envelope_size bytes.
4459            let cur_offset: usize = (2 - 1) * envelope_size;
4460
4461            // Zero reserved fields.
4462            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4463
4464            // Safety:
4465            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4466            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4467            //   envelope_size bytes, there is always sufficient room.
4468            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4469            self.annotations.as_mut().map(<fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4470            encoder, offset + cur_offset, depth
4471        )?;
4472
4473            _prev_end_offset = cur_offset + envelope_size;
4474
4475            Ok(())
4476        }
4477    }
4478
4479    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Spec {
4480        #[inline(always)]
4481        fn new_empty() -> Self {
4482            Self::default()
4483        }
4484
4485        unsafe fn decode(
4486            &mut self,
4487            decoder: &mut fidl::encoding::Decoder<
4488                '_,
4489                fidl::encoding::DefaultFuchsiaResourceDialect,
4490            >,
4491            offset: usize,
4492            mut depth: fidl::encoding::Depth,
4493        ) -> fidl::Result<()> {
4494            decoder.debug_check_bounds::<Self>(offset);
4495            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4496                None => return Err(fidl::Error::NotNullable),
4497                Some(len) => len,
4498            };
4499            // Calling decoder.out_of_line_offset(0) is not allowed.
4500            if len == 0 {
4501                return Ok(());
4502            };
4503            depth.increment()?;
4504            let envelope_size = 8;
4505            let bytes_len = len * envelope_size;
4506            let offset = decoder.out_of_line_offset(bytes_len)?;
4507            // Decode the envelope for each type.
4508            let mut _next_ordinal_to_read = 0;
4509            let mut next_offset = offset;
4510            let end_offset = offset + bytes_len;
4511            _next_ordinal_to_read += 1;
4512            if next_offset >= end_offset {
4513                return Ok(());
4514            }
4515
4516            // Decode unknown envelopes for gaps in ordinals.
4517            while _next_ordinal_to_read < 1 {
4518                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4519                _next_ordinal_to_read += 1;
4520                next_offset += envelope_size;
4521            }
4522
4523            let next_out_of_line = decoder.next_out_of_line();
4524            let handles_before = decoder.remaining_handles();
4525            if let Some((inlined, num_bytes, num_handles)) =
4526                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4527            {
4528                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4529                if inlined != (member_inline_size <= 4) {
4530                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4531                }
4532                let inner_offset;
4533                let mut inner_depth = depth.clone();
4534                if inlined {
4535                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4536                    inner_offset = next_offset;
4537                } else {
4538                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4539                    inner_depth.increment()?;
4540                }
4541                let val_ref = self.component_url.get_or_insert_with(|| {
4542                    fidl::new_empty!(
4543                        fidl::encoding::BoundedString<4096>,
4544                        fidl::encoding::DefaultFuchsiaResourceDialect
4545                    )
4546                });
4547                fidl::decode!(
4548                    fidl::encoding::BoundedString<4096>,
4549                    fidl::encoding::DefaultFuchsiaResourceDialect,
4550                    val_ref,
4551                    decoder,
4552                    inner_offset,
4553                    inner_depth
4554                )?;
4555                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4556                {
4557                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4558                }
4559                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4560                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4561                }
4562            }
4563
4564            next_offset += envelope_size;
4565            _next_ordinal_to_read += 1;
4566            if next_offset >= end_offset {
4567                return Ok(());
4568            }
4569
4570            // Decode unknown envelopes for gaps in ordinals.
4571            while _next_ordinal_to_read < 2 {
4572                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4573                _next_ordinal_to_read += 1;
4574                next_offset += envelope_size;
4575            }
4576
4577            let next_out_of_line = decoder.next_out_of_line();
4578            let handles_before = decoder.remaining_handles();
4579            if let Some((inlined, num_bytes, num_handles)) =
4580                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4581            {
4582                let member_inline_size = <fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4583                if inlined != (member_inline_size <= 4) {
4584                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4585                }
4586                let inner_offset;
4587                let mut inner_depth = depth.clone();
4588                if inlined {
4589                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4590                    inner_offset = next_offset;
4591                } else {
4592                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4593                    inner_depth.increment()?;
4594                }
4595                let val_ref =
4596                self.annotations.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect));
4597                fidl::decode!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4598                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4599                {
4600                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4601                }
4602                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4603                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4604                }
4605            }
4606
4607            next_offset += envelope_size;
4608
4609            // Decode the remaining unknown envelopes.
4610            while next_offset < end_offset {
4611                _next_ordinal_to_read += 1;
4612                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4613                next_offset += envelope_size;
4614            }
4615
4616            Ok(())
4617        }
4618    }
4619
4620    impl ViewSpec {
4621        #[inline(always)]
4622        fn max_ordinal_present(&self) -> u64 {
4623            if let Some(_) = self.viewport_creation_token {
4624                return 4;
4625            }
4626            if let Some(_) = self.annotations {
4627                return 3;
4628            }
4629            if let Some(_) = self.view_ref {
4630                return 2;
4631            }
4632            if let Some(_) = self.view_holder_token {
4633                return 1;
4634            }
4635            0
4636        }
4637    }
4638
4639    impl fidl::encoding::ResourceTypeMarker for ViewSpec {
4640        type Borrowed<'a> = &'a mut Self;
4641        fn take_or_borrow<'a>(
4642            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4643        ) -> Self::Borrowed<'a> {
4644            value
4645        }
4646    }
4647
4648    unsafe impl fidl::encoding::TypeMarker for ViewSpec {
4649        type Owned = Self;
4650
4651        #[inline(always)]
4652        fn inline_align(_context: fidl::encoding::Context) -> usize {
4653            8
4654        }
4655
4656        #[inline(always)]
4657        fn inline_size(_context: fidl::encoding::Context) -> usize {
4658            16
4659        }
4660    }
4661
4662    unsafe impl fidl::encoding::Encode<ViewSpec, fidl::encoding::DefaultFuchsiaResourceDialect>
4663        for &mut ViewSpec
4664    {
4665        unsafe fn encode(
4666            self,
4667            encoder: &mut fidl::encoding::Encoder<
4668                '_,
4669                fidl::encoding::DefaultFuchsiaResourceDialect,
4670            >,
4671            offset: usize,
4672            mut depth: fidl::encoding::Depth,
4673        ) -> fidl::Result<()> {
4674            encoder.debug_check_bounds::<ViewSpec>(offset);
4675            // Vector header
4676            let max_ordinal: u64 = self.max_ordinal_present();
4677            encoder.write_num(max_ordinal, offset);
4678            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4679            // Calling encoder.out_of_line_offset(0) is not allowed.
4680            if max_ordinal == 0 {
4681                return Ok(());
4682            }
4683            depth.increment()?;
4684            let envelope_size = 8;
4685            let bytes_len = max_ordinal as usize * envelope_size;
4686            #[allow(unused_variables)]
4687            let offset = encoder.out_of_line_offset(bytes_len);
4688            let mut _prev_end_offset: usize = 0;
4689            if 1 > max_ordinal {
4690                return Ok(());
4691            }
4692
4693            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4694            // are envelope_size bytes.
4695            let cur_offset: usize = (1 - 1) * envelope_size;
4696
4697            // Zero reserved fields.
4698            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4699
4700            // Safety:
4701            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4702            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4703            //   envelope_size bytes, there is always sufficient room.
4704            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_views::ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
4705            self.view_holder_token.as_mut().map(<fidl_fuchsia_ui_views::ViewHolderToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4706            encoder, offset + cur_offset, depth
4707        )?;
4708
4709            _prev_end_offset = cur_offset + envelope_size;
4710            if 2 > max_ordinal {
4711                return Ok(());
4712            }
4713
4714            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4715            // are envelope_size bytes.
4716            let cur_offset: usize = (2 - 1) * envelope_size;
4717
4718            // Zero reserved fields.
4719            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4720
4721            // Safety:
4722            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4723            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4724            //   envelope_size bytes, there is always sufficient room.
4725            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_views::ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
4726            self.view_ref.as_mut().map(<fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4727            encoder, offset + cur_offset, depth
4728        )?;
4729
4730            _prev_end_offset = cur_offset + envelope_size;
4731            if 3 > max_ordinal {
4732                return Ok(());
4733            }
4734
4735            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4736            // are envelope_size bytes.
4737            let cur_offset: usize = (3 - 1) * envelope_size;
4738
4739            // Zero reserved fields.
4740            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4741
4742            // Safety:
4743            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4744            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4745            //   envelope_size bytes, there is always sufficient room.
4746            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4747            self.annotations.as_mut().map(<fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4748            encoder, offset + cur_offset, depth
4749        )?;
4750
4751            _prev_end_offset = cur_offset + envelope_size;
4752            if 4 > max_ordinal {
4753                return Ok(());
4754            }
4755
4756            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4757            // are envelope_size bytes.
4758            let cur_offset: usize = (4 - 1) * envelope_size;
4759
4760            // Zero reserved fields.
4761            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4762
4763            // Safety:
4764            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4765            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4766            //   envelope_size bytes, there is always sufficient room.
4767            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
4768            self.viewport_creation_token.as_mut().map(<fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4769            encoder, offset + cur_offset, depth
4770        )?;
4771
4772            _prev_end_offset = cur_offset + envelope_size;
4773
4774            Ok(())
4775        }
4776    }
4777
4778    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewSpec {
4779        #[inline(always)]
4780        fn new_empty() -> Self {
4781            Self::default()
4782        }
4783
4784        unsafe fn decode(
4785            &mut self,
4786            decoder: &mut fidl::encoding::Decoder<
4787                '_,
4788                fidl::encoding::DefaultFuchsiaResourceDialect,
4789            >,
4790            offset: usize,
4791            mut depth: fidl::encoding::Depth,
4792        ) -> fidl::Result<()> {
4793            decoder.debug_check_bounds::<Self>(offset);
4794            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4795                None => return Err(fidl::Error::NotNullable),
4796                Some(len) => len,
4797            };
4798            // Calling decoder.out_of_line_offset(0) is not allowed.
4799            if len == 0 {
4800                return Ok(());
4801            };
4802            depth.increment()?;
4803            let envelope_size = 8;
4804            let bytes_len = len * envelope_size;
4805            let offset = decoder.out_of_line_offset(bytes_len)?;
4806            // Decode the envelope for each type.
4807            let mut _next_ordinal_to_read = 0;
4808            let mut next_offset = offset;
4809            let end_offset = offset + bytes_len;
4810            _next_ordinal_to_read += 1;
4811            if next_offset >= end_offset {
4812                return Ok(());
4813            }
4814
4815            // Decode unknown envelopes for gaps in ordinals.
4816            while _next_ordinal_to_read < 1 {
4817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4818                _next_ordinal_to_read += 1;
4819                next_offset += envelope_size;
4820            }
4821
4822            let next_out_of_line = decoder.next_out_of_line();
4823            let handles_before = decoder.remaining_handles();
4824            if let Some((inlined, num_bytes, num_handles)) =
4825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4826            {
4827                let member_inline_size = <fidl_fuchsia_ui_views::ViewHolderToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4828                if inlined != (member_inline_size <= 4) {
4829                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4830                }
4831                let inner_offset;
4832                let mut inner_depth = depth.clone();
4833                if inlined {
4834                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4835                    inner_offset = next_offset;
4836                } else {
4837                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4838                    inner_depth.increment()?;
4839                }
4840                let val_ref = self.view_holder_token.get_or_insert_with(|| {
4841                    fidl::new_empty!(
4842                        fidl_fuchsia_ui_views::ViewHolderToken,
4843                        fidl::encoding::DefaultFuchsiaResourceDialect
4844                    )
4845                });
4846                fidl::decode!(
4847                    fidl_fuchsia_ui_views::ViewHolderToken,
4848                    fidl::encoding::DefaultFuchsiaResourceDialect,
4849                    val_ref,
4850                    decoder,
4851                    inner_offset,
4852                    inner_depth
4853                )?;
4854                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4855                {
4856                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4857                }
4858                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4859                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4860                }
4861            }
4862
4863            next_offset += envelope_size;
4864            _next_ordinal_to_read += 1;
4865            if next_offset >= end_offset {
4866                return Ok(());
4867            }
4868
4869            // Decode unknown envelopes for gaps in ordinals.
4870            while _next_ordinal_to_read < 2 {
4871                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4872                _next_ordinal_to_read += 1;
4873                next_offset += envelope_size;
4874            }
4875
4876            let next_out_of_line = decoder.next_out_of_line();
4877            let handles_before = decoder.remaining_handles();
4878            if let Some((inlined, num_bytes, num_handles)) =
4879                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4880            {
4881                let member_inline_size =
4882                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::TypeMarker>::inline_size(
4883                        decoder.context,
4884                    );
4885                if inlined != (member_inline_size <= 4) {
4886                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4887                }
4888                let inner_offset;
4889                let mut inner_depth = depth.clone();
4890                if inlined {
4891                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4892                    inner_offset = next_offset;
4893                } else {
4894                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4895                    inner_depth.increment()?;
4896                }
4897                let val_ref = self.view_ref.get_or_insert_with(|| {
4898                    fidl::new_empty!(
4899                        fidl_fuchsia_ui_views::ViewRef,
4900                        fidl::encoding::DefaultFuchsiaResourceDialect
4901                    )
4902                });
4903                fidl::decode!(
4904                    fidl_fuchsia_ui_views::ViewRef,
4905                    fidl::encoding::DefaultFuchsiaResourceDialect,
4906                    val_ref,
4907                    decoder,
4908                    inner_offset,
4909                    inner_depth
4910                )?;
4911                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4912                {
4913                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4914                }
4915                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4916                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4917                }
4918            }
4919
4920            next_offset += envelope_size;
4921            _next_ordinal_to_read += 1;
4922            if next_offset >= end_offset {
4923                return Ok(());
4924            }
4925
4926            // Decode unknown envelopes for gaps in ordinals.
4927            while _next_ordinal_to_read < 3 {
4928                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4929                _next_ordinal_to_read += 1;
4930                next_offset += envelope_size;
4931            }
4932
4933            let next_out_of_line = decoder.next_out_of_line();
4934            let handles_before = decoder.remaining_handles();
4935            if let Some((inlined, num_bytes, num_handles)) =
4936                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4937            {
4938                let member_inline_size = <fidl::encoding::Vector<Annotation, 1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4939                if inlined != (member_inline_size <= 4) {
4940                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4941                }
4942                let inner_offset;
4943                let mut inner_depth = depth.clone();
4944                if inlined {
4945                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4946                    inner_offset = next_offset;
4947                } else {
4948                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4949                    inner_depth.increment()?;
4950                }
4951                let val_ref =
4952                self.annotations.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect));
4953                fidl::decode!(fidl::encoding::Vector<Annotation, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4954                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4955                {
4956                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4957                }
4958                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4959                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4960                }
4961            }
4962
4963            next_offset += envelope_size;
4964            _next_ordinal_to_read += 1;
4965            if next_offset >= end_offset {
4966                return Ok(());
4967            }
4968
4969            // Decode unknown envelopes for gaps in ordinals.
4970            while _next_ordinal_to_read < 4 {
4971                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4972                _next_ordinal_to_read += 1;
4973                next_offset += envelope_size;
4974            }
4975
4976            let next_out_of_line = decoder.next_out_of_line();
4977            let handles_before = decoder.remaining_handles();
4978            if let Some((inlined, num_bytes, num_handles)) =
4979                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4980            {
4981                let member_inline_size = <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4982                if inlined != (member_inline_size <= 4) {
4983                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4984                }
4985                let inner_offset;
4986                let mut inner_depth = depth.clone();
4987                if inlined {
4988                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4989                    inner_offset = next_offset;
4990                } else {
4991                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4992                    inner_depth.increment()?;
4993                }
4994                let val_ref = self.viewport_creation_token.get_or_insert_with(|| {
4995                    fidl::new_empty!(
4996                        fidl_fuchsia_ui_views::ViewportCreationToken,
4997                        fidl::encoding::DefaultFuchsiaResourceDialect
4998                    )
4999                });
5000                fidl::decode!(
5001                    fidl_fuchsia_ui_views::ViewportCreationToken,
5002                    fidl::encoding::DefaultFuchsiaResourceDialect,
5003                    val_ref,
5004                    decoder,
5005                    inner_offset,
5006                    inner_depth
5007                )?;
5008                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5009                {
5010                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5011                }
5012                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5013                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5014                }
5015            }
5016
5017            next_offset += envelope_size;
5018
5019            // Decode the remaining unknown envelopes.
5020            while next_offset < end_offset {
5021                _next_ordinal_to_read += 1;
5022                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5023                next_offset += envelope_size;
5024            }
5025
5026            Ok(())
5027        }
5028    }
5029
5030    impl fidl::encoding::ResourceTypeMarker for AnnotationValue {
5031        type Borrowed<'a> = &'a mut Self;
5032        fn take_or_borrow<'a>(
5033            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5034        ) -> Self::Borrowed<'a> {
5035            value
5036        }
5037    }
5038
5039    unsafe impl fidl::encoding::TypeMarker for AnnotationValue {
5040        type Owned = Self;
5041
5042        #[inline(always)]
5043        fn inline_align(_context: fidl::encoding::Context) -> usize {
5044            8
5045        }
5046
5047        #[inline(always)]
5048        fn inline_size(_context: fidl::encoding::Context) -> usize {
5049            16
5050        }
5051    }
5052
5053    unsafe impl
5054        fidl::encoding::Encode<AnnotationValue, fidl::encoding::DefaultFuchsiaResourceDialect>
5055        for &mut AnnotationValue
5056    {
5057        #[inline]
5058        unsafe fn encode(
5059            self,
5060            encoder: &mut fidl::encoding::Encoder<
5061                '_,
5062                fidl::encoding::DefaultFuchsiaResourceDialect,
5063            >,
5064            offset: usize,
5065            _depth: fidl::encoding::Depth,
5066        ) -> fidl::Result<()> {
5067            encoder.debug_check_bounds::<AnnotationValue>(offset);
5068            encoder.write_num::<u64>(self.ordinal(), offset);
5069            match self {
5070            AnnotationValue::Text(ref val) => {
5071                fidl::encoding::encode_in_envelope::<fidl::encoding::UnboundedString, fidl::encoding::DefaultFuchsiaResourceDialect>(
5072                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(val),
5073                    encoder, offset + 8, _depth
5074                )
5075            }
5076            AnnotationValue::Buffer(ref mut val) => {
5077                fidl::encoding::encode_in_envelope::<fidl_fuchsia_mem::Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
5078                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5079                    encoder, offset + 8, _depth
5080                )
5081            }
5082        }
5083        }
5084    }
5085
5086    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5087        for AnnotationValue
5088    {
5089        #[inline(always)]
5090        fn new_empty() -> Self {
5091            Self::Text(fidl::new_empty!(
5092                fidl::encoding::UnboundedString,
5093                fidl::encoding::DefaultFuchsiaResourceDialect
5094            ))
5095        }
5096
5097        #[inline]
5098        unsafe fn decode(
5099            &mut self,
5100            decoder: &mut fidl::encoding::Decoder<
5101                '_,
5102                fidl::encoding::DefaultFuchsiaResourceDialect,
5103            >,
5104            offset: usize,
5105            mut depth: fidl::encoding::Depth,
5106        ) -> fidl::Result<()> {
5107            decoder.debug_check_bounds::<Self>(offset);
5108            #[allow(unused_variables)]
5109            let next_out_of_line = decoder.next_out_of_line();
5110            let handles_before = decoder.remaining_handles();
5111            let (ordinal, inlined, num_bytes, num_handles) =
5112                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5113
5114            let member_inline_size = match ordinal {
5115                1 => <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
5116                    decoder.context,
5117                ),
5118                2 => <fidl_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
5119                    decoder.context,
5120                ),
5121                _ => return Err(fidl::Error::UnknownUnionTag),
5122            };
5123
5124            if inlined != (member_inline_size <= 4) {
5125                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5126            }
5127            let _inner_offset;
5128            if inlined {
5129                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5130                _inner_offset = offset + 8;
5131            } else {
5132                depth.increment()?;
5133                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5134            }
5135            match ordinal {
5136                1 => {
5137                    #[allow(irrefutable_let_patterns)]
5138                    if let AnnotationValue::Text(_) = self {
5139                        // Do nothing, read the value into the object
5140                    } else {
5141                        // Initialize `self` to the right variant
5142                        *self = AnnotationValue::Text(fidl::new_empty!(
5143                            fidl::encoding::UnboundedString,
5144                            fidl::encoding::DefaultFuchsiaResourceDialect
5145                        ));
5146                    }
5147                    #[allow(irrefutable_let_patterns)]
5148                    if let AnnotationValue::Text(ref mut val) = self {
5149                        fidl::decode!(
5150                            fidl::encoding::UnboundedString,
5151                            fidl::encoding::DefaultFuchsiaResourceDialect,
5152                            val,
5153                            decoder,
5154                            _inner_offset,
5155                            depth
5156                        )?;
5157                    } else {
5158                        unreachable!()
5159                    }
5160                }
5161                2 => {
5162                    #[allow(irrefutable_let_patterns)]
5163                    if let AnnotationValue::Buffer(_) = self {
5164                        // Do nothing, read the value into the object
5165                    } else {
5166                        // Initialize `self` to the right variant
5167                        *self = AnnotationValue::Buffer(fidl::new_empty!(
5168                            fidl_fuchsia_mem::Buffer,
5169                            fidl::encoding::DefaultFuchsiaResourceDialect
5170                        ));
5171                    }
5172                    #[allow(irrefutable_let_patterns)]
5173                    if let AnnotationValue::Buffer(ref mut val) = self {
5174                        fidl::decode!(
5175                            fidl_fuchsia_mem::Buffer,
5176                            fidl::encoding::DefaultFuchsiaResourceDialect,
5177                            val,
5178                            decoder,
5179                            _inner_offset,
5180                            depth
5181                        )?;
5182                    } else {
5183                        unreachable!()
5184                    }
5185                }
5186                ordinal => panic!("unexpected ordinal {:?}", ordinal),
5187            }
5188            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5189                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5190            }
5191            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5192                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5193            }
5194            Ok(())
5195        }
5196    }
5197}