fidl_fuchsia_element/
fidl_fuchsia_element.rs

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