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