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