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