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