fidl_fuchsia_fonts_experimental/
fidl_fuchsia_fonts_experimental.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_fonts_experimental__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ProviderListTypefacesRequest {
16    pub request: ListTypefacesRequest,
17    pub iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ProviderListTypefacesRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct ProviderGetTypefaceByIdResponse {
27    pub response: fidl_fuchsia_fonts::TypefaceResponse,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for ProviderGetTypefaceByIdResponse
32{
33}
34
35#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
36pub struct ListTypefacesIteratorMarker;
37
38impl fidl::endpoints::ProtocolMarker for ListTypefacesIteratorMarker {
39    type Proxy = ListTypefacesIteratorProxy;
40    type RequestStream = ListTypefacesIteratorRequestStream;
41    #[cfg(target_os = "fuchsia")]
42    type SynchronousProxy = ListTypefacesIteratorSynchronousProxy;
43
44    const DEBUG_NAME: &'static str = "(anonymous) ListTypefacesIterator";
45}
46
47pub trait ListTypefacesIteratorProxyInterface: Send + Sync {
48    type GetNextResponseFut: std::future::Future<Output = Result<TypefaceInfoResponse, fidl::Error>>
49        + Send;
50    fn r#get_next(&self) -> Self::GetNextResponseFut;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct ListTypefacesIteratorSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for ListTypefacesIteratorSynchronousProxy {
60    type Proxy = ListTypefacesIteratorProxy;
61    type Protocol = ListTypefacesIteratorMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl ListTypefacesIteratorSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        let protocol_name =
80            <ListTypefacesIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
81        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
82    }
83
84    pub fn into_channel(self) -> fidl::Channel {
85        self.client.into_channel()
86    }
87
88    /// Waits until an event arrives and returns it. It is safe for other
89    /// threads to make concurrent requests while waiting for an event.
90    pub fn wait_for_event(
91        &self,
92        deadline: zx::MonotonicInstant,
93    ) -> Result<ListTypefacesIteratorEvent, fidl::Error> {
94        ListTypefacesIteratorEvent::decode(self.client.wait_for_event(deadline)?)
95    }
96
97    /// Returns the next chunk of `TypefaceInfo` for all typefaces that match
98    /// the bound `ListTypefacesRequest`. If `response.results` is empty, no
99    /// results remain.
100    pub fn r#get_next(
101        &self,
102        ___deadline: zx::MonotonicInstant,
103    ) -> Result<TypefaceInfoResponse, fidl::Error> {
104        let _response = self
105            .client
106            .send_query::<fidl::encoding::EmptyPayload, ListTypefacesIteratorGetNextResponse>(
107                (),
108                0x6592495ffe922cec,
109                fidl::encoding::DynamicFlags::empty(),
110                ___deadline,
111            )?;
112        Ok(_response.response)
113    }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl From<ListTypefacesIteratorSynchronousProxy> for zx::NullableHandle {
118    fn from(value: ListTypefacesIteratorSynchronousProxy) -> Self {
119        value.into_channel().into()
120    }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl From<fidl::Channel> for ListTypefacesIteratorSynchronousProxy {
125    fn from(value: fidl::Channel) -> Self {
126        Self::new(value)
127    }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::FromClient for ListTypefacesIteratorSynchronousProxy {
132    type Protocol = ListTypefacesIteratorMarker;
133
134    fn from_client(value: fidl::endpoints::ClientEnd<ListTypefacesIteratorMarker>) -> Self {
135        Self::new(value.into_channel())
136    }
137}
138
139#[derive(Debug, Clone)]
140pub struct ListTypefacesIteratorProxy {
141    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
142}
143
144impl fidl::endpoints::Proxy for ListTypefacesIteratorProxy {
145    type Protocol = ListTypefacesIteratorMarker;
146
147    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
148        Self::new(inner)
149    }
150
151    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
152        self.client.into_channel().map_err(|client| Self { client })
153    }
154
155    fn as_channel(&self) -> &::fidl::AsyncChannel {
156        self.client.as_channel()
157    }
158}
159
160impl ListTypefacesIteratorProxy {
161    /// Create a new Proxy for fuchsia.fonts.experimental/ListTypefacesIterator.
162    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
163        let protocol_name =
164            <ListTypefacesIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
165        Self { client: fidl::client::Client::new(channel, protocol_name) }
166    }
167
168    /// Get a Stream of events from the remote end of the protocol.
169    ///
170    /// # Panics
171    ///
172    /// Panics if the event stream was already taken.
173    pub fn take_event_stream(&self) -> ListTypefacesIteratorEventStream {
174        ListTypefacesIteratorEventStream { event_receiver: self.client.take_event_receiver() }
175    }
176
177    /// Returns the next chunk of `TypefaceInfo` for all typefaces that match
178    /// the bound `ListTypefacesRequest`. If `response.results` is empty, no
179    /// results remain.
180    pub fn r#get_next(
181        &self,
182    ) -> fidl::client::QueryResponseFut<
183        TypefaceInfoResponse,
184        fidl::encoding::DefaultFuchsiaResourceDialect,
185    > {
186        ListTypefacesIteratorProxyInterface::r#get_next(self)
187    }
188}
189
190impl ListTypefacesIteratorProxyInterface for ListTypefacesIteratorProxy {
191    type GetNextResponseFut = fidl::client::QueryResponseFut<
192        TypefaceInfoResponse,
193        fidl::encoding::DefaultFuchsiaResourceDialect,
194    >;
195    fn r#get_next(&self) -> Self::GetNextResponseFut {
196        fn _decode(
197            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
198        ) -> Result<TypefaceInfoResponse, fidl::Error> {
199            let _response = fidl::client::decode_transaction_body::<
200                ListTypefacesIteratorGetNextResponse,
201                fidl::encoding::DefaultFuchsiaResourceDialect,
202                0x6592495ffe922cec,
203            >(_buf?)?;
204            Ok(_response.response)
205        }
206        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, TypefaceInfoResponse>(
207            (),
208            0x6592495ffe922cec,
209            fidl::encoding::DynamicFlags::empty(),
210            _decode,
211        )
212    }
213}
214
215pub struct ListTypefacesIteratorEventStream {
216    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl std::marker::Unpin for ListTypefacesIteratorEventStream {}
220
221impl futures::stream::FusedStream for ListTypefacesIteratorEventStream {
222    fn is_terminated(&self) -> bool {
223        self.event_receiver.is_terminated()
224    }
225}
226
227impl futures::Stream for ListTypefacesIteratorEventStream {
228    type Item = Result<ListTypefacesIteratorEvent, fidl::Error>;
229
230    fn poll_next(
231        mut self: std::pin::Pin<&mut Self>,
232        cx: &mut std::task::Context<'_>,
233    ) -> std::task::Poll<Option<Self::Item>> {
234        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
235            &mut self.event_receiver,
236            cx
237        )?) {
238            Some(buf) => std::task::Poll::Ready(Some(ListTypefacesIteratorEvent::decode(buf))),
239            None => std::task::Poll::Ready(None),
240        }
241    }
242}
243
244#[derive(Debug)]
245pub enum ListTypefacesIteratorEvent {}
246
247impl ListTypefacesIteratorEvent {
248    /// Decodes a message buffer as a [`ListTypefacesIteratorEvent`].
249    fn decode(
250        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
251    ) -> Result<ListTypefacesIteratorEvent, fidl::Error> {
252        let (bytes, _handles) = buf.split_mut();
253        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
254        debug_assert_eq!(tx_header.tx_id, 0);
255        match tx_header.ordinal {
256            _ => Err(fidl::Error::UnknownOrdinal {
257                ordinal: tx_header.ordinal,
258                protocol_name:
259                    <ListTypefacesIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
260            }),
261        }
262    }
263}
264
265/// A Stream of incoming requests for fuchsia.fonts.experimental/ListTypefacesIterator.
266pub struct ListTypefacesIteratorRequestStream {
267    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
268    is_terminated: bool,
269}
270
271impl std::marker::Unpin for ListTypefacesIteratorRequestStream {}
272
273impl futures::stream::FusedStream for ListTypefacesIteratorRequestStream {
274    fn is_terminated(&self) -> bool {
275        self.is_terminated
276    }
277}
278
279impl fidl::endpoints::RequestStream for ListTypefacesIteratorRequestStream {
280    type Protocol = ListTypefacesIteratorMarker;
281    type ControlHandle = ListTypefacesIteratorControlHandle;
282
283    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
284        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
285    }
286
287    fn control_handle(&self) -> Self::ControlHandle {
288        ListTypefacesIteratorControlHandle { inner: self.inner.clone() }
289    }
290
291    fn into_inner(
292        self,
293    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
294    {
295        (self.inner, self.is_terminated)
296    }
297
298    fn from_inner(
299        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
300        is_terminated: bool,
301    ) -> Self {
302        Self { inner, is_terminated }
303    }
304}
305
306impl futures::Stream for ListTypefacesIteratorRequestStream {
307    type Item = Result<ListTypefacesIteratorRequest, fidl::Error>;
308
309    fn poll_next(
310        mut self: std::pin::Pin<&mut Self>,
311        cx: &mut std::task::Context<'_>,
312    ) -> std::task::Poll<Option<Self::Item>> {
313        let this = &mut *self;
314        if this.inner.check_shutdown(cx) {
315            this.is_terminated = true;
316            return std::task::Poll::Ready(None);
317        }
318        if this.is_terminated {
319            panic!("polled ListTypefacesIteratorRequestStream after completion");
320        }
321        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
322            |bytes, handles| {
323                match this.inner.channel().read_etc(cx, bytes, handles) {
324                    std::task::Poll::Ready(Ok(())) => {}
325                    std::task::Poll::Pending => return std::task::Poll::Pending,
326                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
327                        this.is_terminated = true;
328                        return std::task::Poll::Ready(None);
329                    }
330                    std::task::Poll::Ready(Err(e)) => {
331                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
332                            e.into(),
333                        ))));
334                    }
335                }
336
337                // A message has been received from the channel
338                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
339
340                std::task::Poll::Ready(Some(match header.ordinal {
341                0x6592495ffe922cec => {
342                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
343                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
344                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
345                    let control_handle = ListTypefacesIteratorControlHandle {
346                        inner: this.inner.clone(),
347                    };
348                    Ok(ListTypefacesIteratorRequest::GetNext {
349                        responder: ListTypefacesIteratorGetNextResponder {
350                            control_handle: std::mem::ManuallyDrop::new(control_handle),
351                            tx_id: header.tx_id,
352                        },
353                    })
354                }
355                _ => Err(fidl::Error::UnknownOrdinal {
356                    ordinal: header.ordinal,
357                    protocol_name: <ListTypefacesIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
358                }),
359            }))
360            },
361        )
362    }
363}
364
365#[derive(Debug)]
366pub enum ListTypefacesIteratorRequest {
367    /// Returns the next chunk of `TypefaceInfo` for all typefaces that match
368    /// the bound `ListTypefacesRequest`. If `response.results` is empty, no
369    /// results remain.
370    GetNext { responder: ListTypefacesIteratorGetNextResponder },
371}
372
373impl ListTypefacesIteratorRequest {
374    #[allow(irrefutable_let_patterns)]
375    pub fn into_get_next(self) -> Option<(ListTypefacesIteratorGetNextResponder)> {
376        if let ListTypefacesIteratorRequest::GetNext { responder } = self {
377            Some((responder))
378        } else {
379            None
380        }
381    }
382
383    /// Name of the method defined in FIDL
384    pub fn method_name(&self) -> &'static str {
385        match *self {
386            ListTypefacesIteratorRequest::GetNext { .. } => "get_next",
387        }
388    }
389}
390
391#[derive(Debug, Clone)]
392pub struct ListTypefacesIteratorControlHandle {
393    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
394}
395
396impl fidl::endpoints::ControlHandle for ListTypefacesIteratorControlHandle {
397    fn shutdown(&self) {
398        self.inner.shutdown()
399    }
400
401    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
402        self.inner.shutdown_with_epitaph(status)
403    }
404
405    fn is_closed(&self) -> bool {
406        self.inner.channel().is_closed()
407    }
408    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
409        self.inner.channel().on_closed()
410    }
411
412    #[cfg(target_os = "fuchsia")]
413    fn signal_peer(
414        &self,
415        clear_mask: zx::Signals,
416        set_mask: zx::Signals,
417    ) -> Result<(), zx_status::Status> {
418        use fidl::Peered;
419        self.inner.channel().signal_peer(clear_mask, set_mask)
420    }
421}
422
423impl ListTypefacesIteratorControlHandle {}
424
425#[must_use = "FIDL methods require a response to be sent"]
426#[derive(Debug)]
427pub struct ListTypefacesIteratorGetNextResponder {
428    control_handle: std::mem::ManuallyDrop<ListTypefacesIteratorControlHandle>,
429    tx_id: u32,
430}
431
432/// Set the the channel to be shutdown (see [`ListTypefacesIteratorControlHandle::shutdown`])
433/// if the responder is dropped without sending a response, so that the client
434/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
435impl std::ops::Drop for ListTypefacesIteratorGetNextResponder {
436    fn drop(&mut self) {
437        self.control_handle.shutdown();
438        // Safety: drops once, never accessed again
439        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
440    }
441}
442
443impl fidl::endpoints::Responder for ListTypefacesIteratorGetNextResponder {
444    type ControlHandle = ListTypefacesIteratorControlHandle;
445
446    fn control_handle(&self) -> &ListTypefacesIteratorControlHandle {
447        &self.control_handle
448    }
449
450    fn drop_without_shutdown(mut self) {
451        // Safety: drops once, never accessed again due to mem::forget
452        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
453        // Prevent Drop from running (which would shut down the channel)
454        std::mem::forget(self);
455    }
456}
457
458impl ListTypefacesIteratorGetNextResponder {
459    /// Sends a response to the FIDL transaction.
460    ///
461    /// Sets the channel to shutdown if an error occurs.
462    pub fn send(self, mut response: &TypefaceInfoResponse) -> Result<(), fidl::Error> {
463        let _result = self.send_raw(response);
464        if _result.is_err() {
465            self.control_handle.shutdown();
466        }
467        self.drop_without_shutdown();
468        _result
469    }
470
471    /// Similar to "send" but does not shutdown the channel if an error occurs.
472    pub fn send_no_shutdown_on_err(
473        self,
474        mut response: &TypefaceInfoResponse,
475    ) -> Result<(), fidl::Error> {
476        let _result = self.send_raw(response);
477        self.drop_without_shutdown();
478        _result
479    }
480
481    fn send_raw(&self, mut response: &TypefaceInfoResponse) -> Result<(), fidl::Error> {
482        self.control_handle.inner.send::<ListTypefacesIteratorGetNextResponse>(
483            (response,),
484            self.tx_id,
485            0x6592495ffe922cec,
486            fidl::encoding::DynamicFlags::empty(),
487        )
488    }
489}
490
491#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
492pub struct ProviderMarker;
493
494impl fidl::endpoints::ProtocolMarker for ProviderMarker {
495    type Proxy = ProviderProxy;
496    type RequestStream = ProviderRequestStream;
497    #[cfg(target_os = "fuchsia")]
498    type SynchronousProxy = ProviderSynchronousProxy;
499
500    const DEBUG_NAME: &'static str = "fuchsia.fonts.experimental.Provider";
501}
502impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
503pub type ProviderGetTypefaceByIdResult = Result<fidl_fuchsia_fonts::TypefaceResponse, Error>;
504pub type ProviderListTypefacesResult = Result<(), Error>;
505pub type ProviderGetTypefacesByFamilyResult = Result<TypefaceInfoResponse, Error>;
506
507pub trait ProviderProxyInterface: Send + Sync {
508    type GetTypefaceByIdResponseFut: std::future::Future<Output = Result<ProviderGetTypefaceByIdResult, fidl::Error>>
509        + Send;
510    fn r#get_typeface_by_id(&self, id: u32) -> Self::GetTypefaceByIdResponseFut;
511    type ListTypefacesResponseFut: std::future::Future<Output = Result<ProviderListTypefacesResult, fidl::Error>>
512        + Send;
513    fn r#list_typefaces(
514        &self,
515        request: &ListTypefacesRequest,
516        iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
517    ) -> Self::ListTypefacesResponseFut;
518    type GetTypefacesByFamilyResponseFut: std::future::Future<Output = Result<ProviderGetTypefacesByFamilyResult, fidl::Error>>
519        + Send;
520    fn r#get_typefaces_by_family(
521        &self,
522        family: &fidl_fuchsia_fonts::FamilyName,
523    ) -> Self::GetTypefacesByFamilyResponseFut;
524}
525#[derive(Debug)]
526#[cfg(target_os = "fuchsia")]
527pub struct ProviderSynchronousProxy {
528    client: fidl::client::sync::Client,
529}
530
531#[cfg(target_os = "fuchsia")]
532impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
533    type Proxy = ProviderProxy;
534    type Protocol = ProviderMarker;
535
536    fn from_channel(inner: fidl::Channel) -> Self {
537        Self::new(inner)
538    }
539
540    fn into_channel(self) -> fidl::Channel {
541        self.client.into_channel()
542    }
543
544    fn as_channel(&self) -> &fidl::Channel {
545        self.client.as_channel()
546    }
547}
548
549#[cfg(target_os = "fuchsia")]
550impl ProviderSynchronousProxy {
551    pub fn new(channel: fidl::Channel) -> Self {
552        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
553        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
554    }
555
556    pub fn into_channel(self) -> fidl::Channel {
557        self.client.into_channel()
558    }
559
560    /// Waits until an event arrives and returns it. It is safe for other
561    /// threads to make concurrent requests while waiting for an event.
562    pub fn wait_for_event(
563        &self,
564        deadline: zx::MonotonicInstant,
565    ) -> Result<ProviderEvent, fidl::Error> {
566        ProviderEvent::decode(self.client.wait_for_event(deadline)?)
567    }
568
569    /// Get an exact font by asset ID. This would typically be called
570    /// after `ListTypefaces`, e.g. as part of a font selection interface.
571    /// As with `fuchsia.fonts.GetTypeface`, it is the caller's responsibility
572    /// to properly parse the file.
573    ///
574    /// Possible errors:
575    /// `NOT_FOUND` if no asset with the requested `id` exists.
576    /// `INTERNAL` if the requested `id` exists, but the asset failed to load.
577    ///
578    /// Eventually this should probably be folded into `GetTypeface`.
579    pub fn r#get_typeface_by_id(
580        &self,
581        mut id: u32,
582        ___deadline: zx::MonotonicInstant,
583    ) -> Result<ProviderGetTypefaceByIdResult, fidl::Error> {
584        let _response = self.client.send_query::<
585            ProviderGetTypefaceByIdRequest,
586            fidl::encoding::ResultType<ProviderGetTypefaceByIdResponse, Error>,
587        >(
588            (id,),
589            0x695e0babbf6c7f2c,
590            fidl::encoding::DynamicFlags::empty(),
591            ___deadline,
592        )?;
593        Ok(_response.map(|x| x.response))
594    }
595
596    /// Creates a `ListTypefacesIterator` instance that will return a paginated
597    /// list of fonts matching `request`.
598    ///
599    /// Possible errors:
600    /// `INTERNAL` if something bad happens.
601    pub fn r#list_typefaces(
602        &self,
603        mut request: &ListTypefacesRequest,
604        mut iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
605        ___deadline: zx::MonotonicInstant,
606    ) -> Result<ProviderListTypefacesResult, fidl::Error> {
607        let _response = self.client.send_query::<
608            ProviderListTypefacesRequest,
609            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
610        >(
611            (request, iterator,),
612            0x5245158a60e08325,
613            fidl::encoding::DynamicFlags::empty(),
614            ___deadline,
615        )?;
616        Ok(_response.map(|x| x))
617    }
618
619    /// Returns a `TypefaceInfo` for each font in the requested `family`. The
620    /// results' `family` fields will hold the canonical family name, even if
621    /// this method is called with an alias.
622    ///
623    /// This method should be called only if the caller knows `family` exists.
624    /// Requesting a family that does not exist results in an error. To search
625    /// for fonts by family name (or alias), use `ListTypefaces` instead.
626    ///
627    /// Possible errors:
628    /// `NOT_FOUND` if no family name or alias matches the requested `family`.
629    pub fn r#get_typefaces_by_family(
630        &self,
631        mut family: &fidl_fuchsia_fonts::FamilyName,
632        ___deadline: zx::MonotonicInstant,
633    ) -> Result<ProviderGetTypefacesByFamilyResult, fidl::Error> {
634        let _response = self.client.send_query::<
635            ProviderGetTypefacesByFamilyRequest,
636            fidl::encoding::ResultType<ProviderGetTypefacesByFamilyResponse, Error>,
637        >(
638            (family,),
639            0x64450c13bc304356,
640            fidl::encoding::DynamicFlags::empty(),
641            ___deadline,
642        )?;
643        Ok(_response.map(|x| x.response))
644    }
645}
646
647#[cfg(target_os = "fuchsia")]
648impl From<ProviderSynchronousProxy> for zx::NullableHandle {
649    fn from(value: ProviderSynchronousProxy) -> Self {
650        value.into_channel().into()
651    }
652}
653
654#[cfg(target_os = "fuchsia")]
655impl From<fidl::Channel> for ProviderSynchronousProxy {
656    fn from(value: fidl::Channel) -> Self {
657        Self::new(value)
658    }
659}
660
661#[cfg(target_os = "fuchsia")]
662impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
663    type Protocol = ProviderMarker;
664
665    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
666        Self::new(value.into_channel())
667    }
668}
669
670#[derive(Debug, Clone)]
671pub struct ProviderProxy {
672    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
673}
674
675impl fidl::endpoints::Proxy for ProviderProxy {
676    type Protocol = ProviderMarker;
677
678    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
679        Self::new(inner)
680    }
681
682    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
683        self.client.into_channel().map_err(|client| Self { client })
684    }
685
686    fn as_channel(&self) -> &::fidl::AsyncChannel {
687        self.client.as_channel()
688    }
689}
690
691impl ProviderProxy {
692    /// Create a new Proxy for fuchsia.fonts.experimental/Provider.
693    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
694        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
695        Self { client: fidl::client::Client::new(channel, protocol_name) }
696    }
697
698    /// Get a Stream of events from the remote end of the protocol.
699    ///
700    /// # Panics
701    ///
702    /// Panics if the event stream was already taken.
703    pub fn take_event_stream(&self) -> ProviderEventStream {
704        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
705    }
706
707    /// Get an exact font by asset ID. This would typically be called
708    /// after `ListTypefaces`, e.g. as part of a font selection interface.
709    /// As with `fuchsia.fonts.GetTypeface`, it is the caller's responsibility
710    /// to properly parse the file.
711    ///
712    /// Possible errors:
713    /// `NOT_FOUND` if no asset with the requested `id` exists.
714    /// `INTERNAL` if the requested `id` exists, but the asset failed to load.
715    ///
716    /// Eventually this should probably be folded into `GetTypeface`.
717    pub fn r#get_typeface_by_id(
718        &self,
719        mut id: u32,
720    ) -> fidl::client::QueryResponseFut<
721        ProviderGetTypefaceByIdResult,
722        fidl::encoding::DefaultFuchsiaResourceDialect,
723    > {
724        ProviderProxyInterface::r#get_typeface_by_id(self, id)
725    }
726
727    /// Creates a `ListTypefacesIterator` instance that will return a paginated
728    /// list of fonts matching `request`.
729    ///
730    /// Possible errors:
731    /// `INTERNAL` if something bad happens.
732    pub fn r#list_typefaces(
733        &self,
734        mut request: &ListTypefacesRequest,
735        mut iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
736    ) -> fidl::client::QueryResponseFut<
737        ProviderListTypefacesResult,
738        fidl::encoding::DefaultFuchsiaResourceDialect,
739    > {
740        ProviderProxyInterface::r#list_typefaces(self, request, iterator)
741    }
742
743    /// Returns a `TypefaceInfo` for each font in the requested `family`. The
744    /// results' `family` fields will hold the canonical family name, even if
745    /// this method is called with an alias.
746    ///
747    /// This method should be called only if the caller knows `family` exists.
748    /// Requesting a family that does not exist results in an error. To search
749    /// for fonts by family name (or alias), use `ListTypefaces` instead.
750    ///
751    /// Possible errors:
752    /// `NOT_FOUND` if no family name or alias matches the requested `family`.
753    pub fn r#get_typefaces_by_family(
754        &self,
755        mut family: &fidl_fuchsia_fonts::FamilyName,
756    ) -> fidl::client::QueryResponseFut<
757        ProviderGetTypefacesByFamilyResult,
758        fidl::encoding::DefaultFuchsiaResourceDialect,
759    > {
760        ProviderProxyInterface::r#get_typefaces_by_family(self, family)
761    }
762}
763
764impl ProviderProxyInterface for ProviderProxy {
765    type GetTypefaceByIdResponseFut = fidl::client::QueryResponseFut<
766        ProviderGetTypefaceByIdResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    >;
769    fn r#get_typeface_by_id(&self, mut id: u32) -> Self::GetTypefaceByIdResponseFut {
770        fn _decode(
771            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
772        ) -> Result<ProviderGetTypefaceByIdResult, fidl::Error> {
773            let _response = fidl::client::decode_transaction_body::<
774                fidl::encoding::ResultType<ProviderGetTypefaceByIdResponse, Error>,
775                fidl::encoding::DefaultFuchsiaResourceDialect,
776                0x695e0babbf6c7f2c,
777            >(_buf?)?;
778            Ok(_response.map(|x| x.response))
779        }
780        self.client
781            .send_query_and_decode::<ProviderGetTypefaceByIdRequest, ProviderGetTypefaceByIdResult>(
782                (id,),
783                0x695e0babbf6c7f2c,
784                fidl::encoding::DynamicFlags::empty(),
785                _decode,
786            )
787    }
788
789    type ListTypefacesResponseFut = fidl::client::QueryResponseFut<
790        ProviderListTypefacesResult,
791        fidl::encoding::DefaultFuchsiaResourceDialect,
792    >;
793    fn r#list_typefaces(
794        &self,
795        mut request: &ListTypefacesRequest,
796        mut iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
797    ) -> Self::ListTypefacesResponseFut {
798        fn _decode(
799            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
800        ) -> Result<ProviderListTypefacesResult, fidl::Error> {
801            let _response = fidl::client::decode_transaction_body::<
802                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
803                fidl::encoding::DefaultFuchsiaResourceDialect,
804                0x5245158a60e08325,
805            >(_buf?)?;
806            Ok(_response.map(|x| x))
807        }
808        self.client
809            .send_query_and_decode::<ProviderListTypefacesRequest, ProviderListTypefacesResult>(
810                (request, iterator),
811                0x5245158a60e08325,
812                fidl::encoding::DynamicFlags::empty(),
813                _decode,
814            )
815    }
816
817    type GetTypefacesByFamilyResponseFut = fidl::client::QueryResponseFut<
818        ProviderGetTypefacesByFamilyResult,
819        fidl::encoding::DefaultFuchsiaResourceDialect,
820    >;
821    fn r#get_typefaces_by_family(
822        &self,
823        mut family: &fidl_fuchsia_fonts::FamilyName,
824    ) -> Self::GetTypefacesByFamilyResponseFut {
825        fn _decode(
826            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
827        ) -> Result<ProviderGetTypefacesByFamilyResult, fidl::Error> {
828            let _response = fidl::client::decode_transaction_body::<
829                fidl::encoding::ResultType<ProviderGetTypefacesByFamilyResponse, Error>,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831                0x64450c13bc304356,
832            >(_buf?)?;
833            Ok(_response.map(|x| x.response))
834        }
835        self.client.send_query_and_decode::<
836            ProviderGetTypefacesByFamilyRequest,
837            ProviderGetTypefacesByFamilyResult,
838        >(
839            (family,),
840            0x64450c13bc304356,
841            fidl::encoding::DynamicFlags::empty(),
842            _decode,
843        )
844    }
845}
846
847pub struct ProviderEventStream {
848    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
849}
850
851impl std::marker::Unpin for ProviderEventStream {}
852
853impl futures::stream::FusedStream for ProviderEventStream {
854    fn is_terminated(&self) -> bool {
855        self.event_receiver.is_terminated()
856    }
857}
858
859impl futures::Stream for ProviderEventStream {
860    type Item = Result<ProviderEvent, fidl::Error>;
861
862    fn poll_next(
863        mut self: std::pin::Pin<&mut Self>,
864        cx: &mut std::task::Context<'_>,
865    ) -> std::task::Poll<Option<Self::Item>> {
866        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
867            &mut self.event_receiver,
868            cx
869        )?) {
870            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
871            None => std::task::Poll::Ready(None),
872        }
873    }
874}
875
876#[derive(Debug)]
877pub enum ProviderEvent {}
878
879impl ProviderEvent {
880    /// Decodes a message buffer as a [`ProviderEvent`].
881    fn decode(
882        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
883    ) -> Result<ProviderEvent, fidl::Error> {
884        let (bytes, _handles) = buf.split_mut();
885        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
886        debug_assert_eq!(tx_header.tx_id, 0);
887        match tx_header.ordinal {
888            _ => Err(fidl::Error::UnknownOrdinal {
889                ordinal: tx_header.ordinal,
890                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
891            }),
892        }
893    }
894}
895
896/// A Stream of incoming requests for fuchsia.fonts.experimental/Provider.
897pub struct ProviderRequestStream {
898    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
899    is_terminated: bool,
900}
901
902impl std::marker::Unpin for ProviderRequestStream {}
903
904impl futures::stream::FusedStream for ProviderRequestStream {
905    fn is_terminated(&self) -> bool {
906        self.is_terminated
907    }
908}
909
910impl fidl::endpoints::RequestStream for ProviderRequestStream {
911    type Protocol = ProviderMarker;
912    type ControlHandle = ProviderControlHandle;
913
914    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
915        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
916    }
917
918    fn control_handle(&self) -> Self::ControlHandle {
919        ProviderControlHandle { inner: self.inner.clone() }
920    }
921
922    fn into_inner(
923        self,
924    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
925    {
926        (self.inner, self.is_terminated)
927    }
928
929    fn from_inner(
930        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
931        is_terminated: bool,
932    ) -> Self {
933        Self { inner, is_terminated }
934    }
935}
936
937impl futures::Stream for ProviderRequestStream {
938    type Item = Result<ProviderRequest, fidl::Error>;
939
940    fn poll_next(
941        mut self: std::pin::Pin<&mut Self>,
942        cx: &mut std::task::Context<'_>,
943    ) -> std::task::Poll<Option<Self::Item>> {
944        let this = &mut *self;
945        if this.inner.check_shutdown(cx) {
946            this.is_terminated = true;
947            return std::task::Poll::Ready(None);
948        }
949        if this.is_terminated {
950            panic!("polled ProviderRequestStream after completion");
951        }
952        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
953            |bytes, handles| {
954                match this.inner.channel().read_etc(cx, bytes, handles) {
955                    std::task::Poll::Ready(Ok(())) => {}
956                    std::task::Poll::Pending => return std::task::Poll::Pending,
957                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
958                        this.is_terminated = true;
959                        return std::task::Poll::Ready(None);
960                    }
961                    std::task::Poll::Ready(Err(e)) => {
962                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
963                            e.into(),
964                        ))));
965                    }
966                }
967
968                // A message has been received from the channel
969                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
970
971                std::task::Poll::Ready(Some(match header.ordinal {
972                    0x695e0babbf6c7f2c => {
973                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
974                        let mut req = fidl::new_empty!(
975                            ProviderGetTypefaceByIdRequest,
976                            fidl::encoding::DefaultFuchsiaResourceDialect
977                        );
978                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderGetTypefaceByIdRequest>(&header, _body_bytes, handles, &mut req)?;
979                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
980                        Ok(ProviderRequest::GetTypefaceById {
981                            id: req.id,
982
983                            responder: ProviderGetTypefaceByIdResponder {
984                                control_handle: std::mem::ManuallyDrop::new(control_handle),
985                                tx_id: header.tx_id,
986                            },
987                        })
988                    }
989                    0x5245158a60e08325 => {
990                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
991                        let mut req = fidl::new_empty!(
992                            ProviderListTypefacesRequest,
993                            fidl::encoding::DefaultFuchsiaResourceDialect
994                        );
995                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderListTypefacesRequest>(&header, _body_bytes, handles, &mut req)?;
996                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
997                        Ok(ProviderRequest::ListTypefaces {
998                            request: req.request,
999                            iterator: req.iterator,
1000
1001                            responder: ProviderListTypefacesResponder {
1002                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1003                                tx_id: header.tx_id,
1004                            },
1005                        })
1006                    }
1007                    0x64450c13bc304356 => {
1008                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1009                        let mut req = fidl::new_empty!(
1010                            ProviderGetTypefacesByFamilyRequest,
1011                            fidl::encoding::DefaultFuchsiaResourceDialect
1012                        );
1013                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderGetTypefacesByFamilyRequest>(&header, _body_bytes, handles, &mut req)?;
1014                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
1015                        Ok(ProviderRequest::GetTypefacesByFamily {
1016                            family: req.family,
1017
1018                            responder: ProviderGetTypefacesByFamilyResponder {
1019                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1020                                tx_id: header.tx_id,
1021                            },
1022                        })
1023                    }
1024                    _ => Err(fidl::Error::UnknownOrdinal {
1025                        ordinal: header.ordinal,
1026                        protocol_name:
1027                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1028                    }),
1029                }))
1030            },
1031        )
1032    }
1033}
1034
1035/// Experimental additions to `Provider`.
1036#[derive(Debug)]
1037pub enum ProviderRequest {
1038    /// Get an exact font by asset ID. This would typically be called
1039    /// after `ListTypefaces`, e.g. as part of a font selection interface.
1040    /// As with `fuchsia.fonts.GetTypeface`, it is the caller's responsibility
1041    /// to properly parse the file.
1042    ///
1043    /// Possible errors:
1044    /// `NOT_FOUND` if no asset with the requested `id` exists.
1045    /// `INTERNAL` if the requested `id` exists, but the asset failed to load.
1046    ///
1047    /// Eventually this should probably be folded into `GetTypeface`.
1048    GetTypefaceById { id: u32, responder: ProviderGetTypefaceByIdResponder },
1049    /// Creates a `ListTypefacesIterator` instance that will return a paginated
1050    /// list of fonts matching `request`.
1051    ///
1052    /// Possible errors:
1053    /// `INTERNAL` if something bad happens.
1054    ListTypefaces {
1055        request: ListTypefacesRequest,
1056        iterator: fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
1057        responder: ProviderListTypefacesResponder,
1058    },
1059    /// Returns a `TypefaceInfo` for each font in the requested `family`. The
1060    /// results' `family` fields will hold the canonical family name, even if
1061    /// this method is called with an alias.
1062    ///
1063    /// This method should be called only if the caller knows `family` exists.
1064    /// Requesting a family that does not exist results in an error. To search
1065    /// for fonts by family name (or alias), use `ListTypefaces` instead.
1066    ///
1067    /// Possible errors:
1068    /// `NOT_FOUND` if no family name or alias matches the requested `family`.
1069    GetTypefacesByFamily {
1070        family: fidl_fuchsia_fonts::FamilyName,
1071        responder: ProviderGetTypefacesByFamilyResponder,
1072    },
1073}
1074
1075impl ProviderRequest {
1076    #[allow(irrefutable_let_patterns)]
1077    pub fn into_get_typeface_by_id(self) -> Option<(u32, ProviderGetTypefaceByIdResponder)> {
1078        if let ProviderRequest::GetTypefaceById { id, responder } = self {
1079            Some((id, responder))
1080        } else {
1081            None
1082        }
1083    }
1084
1085    #[allow(irrefutable_let_patterns)]
1086    pub fn into_list_typefaces(
1087        self,
1088    ) -> Option<(
1089        ListTypefacesRequest,
1090        fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
1091        ProviderListTypefacesResponder,
1092    )> {
1093        if let ProviderRequest::ListTypefaces { request, iterator, responder } = self {
1094            Some((request, iterator, responder))
1095        } else {
1096            None
1097        }
1098    }
1099
1100    #[allow(irrefutable_let_patterns)]
1101    pub fn into_get_typefaces_by_family(
1102        self,
1103    ) -> Option<(fidl_fuchsia_fonts::FamilyName, ProviderGetTypefacesByFamilyResponder)> {
1104        if let ProviderRequest::GetTypefacesByFamily { family, responder } = self {
1105            Some((family, responder))
1106        } else {
1107            None
1108        }
1109    }
1110
1111    /// Name of the method defined in FIDL
1112    pub fn method_name(&self) -> &'static str {
1113        match *self {
1114            ProviderRequest::GetTypefaceById { .. } => "get_typeface_by_id",
1115            ProviderRequest::ListTypefaces { .. } => "list_typefaces",
1116            ProviderRequest::GetTypefacesByFamily { .. } => "get_typefaces_by_family",
1117        }
1118    }
1119}
1120
1121#[derive(Debug, Clone)]
1122pub struct ProviderControlHandle {
1123    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1124}
1125
1126impl fidl::endpoints::ControlHandle for ProviderControlHandle {
1127    fn shutdown(&self) {
1128        self.inner.shutdown()
1129    }
1130
1131    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1132        self.inner.shutdown_with_epitaph(status)
1133    }
1134
1135    fn is_closed(&self) -> bool {
1136        self.inner.channel().is_closed()
1137    }
1138    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1139        self.inner.channel().on_closed()
1140    }
1141
1142    #[cfg(target_os = "fuchsia")]
1143    fn signal_peer(
1144        &self,
1145        clear_mask: zx::Signals,
1146        set_mask: zx::Signals,
1147    ) -> Result<(), zx_status::Status> {
1148        use fidl::Peered;
1149        self.inner.channel().signal_peer(clear_mask, set_mask)
1150    }
1151}
1152
1153impl ProviderControlHandle {}
1154
1155#[must_use = "FIDL methods require a response to be sent"]
1156#[derive(Debug)]
1157pub struct ProviderGetTypefaceByIdResponder {
1158    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1159    tx_id: u32,
1160}
1161
1162/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1163/// if the responder is dropped without sending a response, so that the client
1164/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1165impl std::ops::Drop for ProviderGetTypefaceByIdResponder {
1166    fn drop(&mut self) {
1167        self.control_handle.shutdown();
1168        // Safety: drops once, never accessed again
1169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1170    }
1171}
1172
1173impl fidl::endpoints::Responder for ProviderGetTypefaceByIdResponder {
1174    type ControlHandle = ProviderControlHandle;
1175
1176    fn control_handle(&self) -> &ProviderControlHandle {
1177        &self.control_handle
1178    }
1179
1180    fn drop_without_shutdown(mut self) {
1181        // Safety: drops once, never accessed again due to mem::forget
1182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1183        // Prevent Drop from running (which would shut down the channel)
1184        std::mem::forget(self);
1185    }
1186}
1187
1188impl ProviderGetTypefaceByIdResponder {
1189    /// Sends a response to the FIDL transaction.
1190    ///
1191    /// Sets the channel to shutdown if an error occurs.
1192    pub fn send(
1193        self,
1194        mut result: Result<fidl_fuchsia_fonts::TypefaceResponse, Error>,
1195    ) -> Result<(), fidl::Error> {
1196        let _result = self.send_raw(result);
1197        if _result.is_err() {
1198            self.control_handle.shutdown();
1199        }
1200        self.drop_without_shutdown();
1201        _result
1202    }
1203
1204    /// Similar to "send" but does not shutdown the channel if an error occurs.
1205    pub fn send_no_shutdown_on_err(
1206        self,
1207        mut result: Result<fidl_fuchsia_fonts::TypefaceResponse, Error>,
1208    ) -> Result<(), fidl::Error> {
1209        let _result = self.send_raw(result);
1210        self.drop_without_shutdown();
1211        _result
1212    }
1213
1214    fn send_raw(
1215        &self,
1216        mut result: Result<fidl_fuchsia_fonts::TypefaceResponse, Error>,
1217    ) -> Result<(), fidl::Error> {
1218        self.control_handle
1219            .inner
1220            .send::<fidl::encoding::ResultType<ProviderGetTypefaceByIdResponse, Error>>(
1221                result.as_mut().map_err(|e| *e).map(|response| (response,)),
1222                self.tx_id,
1223                0x695e0babbf6c7f2c,
1224                fidl::encoding::DynamicFlags::empty(),
1225            )
1226    }
1227}
1228
1229#[must_use = "FIDL methods require a response to be sent"]
1230#[derive(Debug)]
1231pub struct ProviderListTypefacesResponder {
1232    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1233    tx_id: u32,
1234}
1235
1236/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1237/// if the responder is dropped without sending a response, so that the client
1238/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1239impl std::ops::Drop for ProviderListTypefacesResponder {
1240    fn drop(&mut self) {
1241        self.control_handle.shutdown();
1242        // Safety: drops once, never accessed again
1243        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1244    }
1245}
1246
1247impl fidl::endpoints::Responder for ProviderListTypefacesResponder {
1248    type ControlHandle = ProviderControlHandle;
1249
1250    fn control_handle(&self) -> &ProviderControlHandle {
1251        &self.control_handle
1252    }
1253
1254    fn drop_without_shutdown(mut self) {
1255        // Safety: drops once, never accessed again due to mem::forget
1256        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1257        // Prevent Drop from running (which would shut down the channel)
1258        std::mem::forget(self);
1259    }
1260}
1261
1262impl ProviderListTypefacesResponder {
1263    /// Sends a response to the FIDL transaction.
1264    ///
1265    /// Sets the channel to shutdown if an error occurs.
1266    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1267        let _result = self.send_raw(result);
1268        if _result.is_err() {
1269            self.control_handle.shutdown();
1270        }
1271        self.drop_without_shutdown();
1272        _result
1273    }
1274
1275    /// Similar to "send" but does not shutdown the channel if an error occurs.
1276    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1277        let _result = self.send_raw(result);
1278        self.drop_without_shutdown();
1279        _result
1280    }
1281
1282    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1283        self.control_handle
1284            .inner
1285            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1286                result,
1287                self.tx_id,
1288                0x5245158a60e08325,
1289                fidl::encoding::DynamicFlags::empty(),
1290            )
1291    }
1292}
1293
1294#[must_use = "FIDL methods require a response to be sent"]
1295#[derive(Debug)]
1296pub struct ProviderGetTypefacesByFamilyResponder {
1297    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
1298    tx_id: u32,
1299}
1300
1301/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
1302/// if the responder is dropped without sending a response, so that the client
1303/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1304impl std::ops::Drop for ProviderGetTypefacesByFamilyResponder {
1305    fn drop(&mut self) {
1306        self.control_handle.shutdown();
1307        // Safety: drops once, never accessed again
1308        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1309    }
1310}
1311
1312impl fidl::endpoints::Responder for ProviderGetTypefacesByFamilyResponder {
1313    type ControlHandle = ProviderControlHandle;
1314
1315    fn control_handle(&self) -> &ProviderControlHandle {
1316        &self.control_handle
1317    }
1318
1319    fn drop_without_shutdown(mut self) {
1320        // Safety: drops once, never accessed again due to mem::forget
1321        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1322        // Prevent Drop from running (which would shut down the channel)
1323        std::mem::forget(self);
1324    }
1325}
1326
1327impl ProviderGetTypefacesByFamilyResponder {
1328    /// Sends a response to the FIDL transaction.
1329    ///
1330    /// Sets the channel to shutdown if an error occurs.
1331    pub fn send(self, mut result: Result<&TypefaceInfoResponse, Error>) -> Result<(), fidl::Error> {
1332        let _result = self.send_raw(result);
1333        if _result.is_err() {
1334            self.control_handle.shutdown();
1335        }
1336        self.drop_without_shutdown();
1337        _result
1338    }
1339
1340    /// Similar to "send" but does not shutdown the channel if an error occurs.
1341    pub fn send_no_shutdown_on_err(
1342        self,
1343        mut result: Result<&TypefaceInfoResponse, Error>,
1344    ) -> Result<(), fidl::Error> {
1345        let _result = self.send_raw(result);
1346        self.drop_without_shutdown();
1347        _result
1348    }
1349
1350    fn send_raw(
1351        &self,
1352        mut result: Result<&TypefaceInfoResponse, Error>,
1353    ) -> Result<(), fidl::Error> {
1354        self.control_handle.inner.send::<fidl::encoding::ResultType<
1355            ProviderGetTypefacesByFamilyResponse,
1356            Error,
1357        >>(
1358            result.map(|response| (response,)),
1359            self.tx_id,
1360            0x64450c13bc304356,
1361            fidl::encoding::DynamicFlags::empty(),
1362        )
1363    }
1364}
1365
1366mod internal {
1367    use super::*;
1368
1369    impl fidl::encoding::ResourceTypeMarker for ProviderListTypefacesRequest {
1370        type Borrowed<'a> = &'a mut Self;
1371        fn take_or_borrow<'a>(
1372            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1373        ) -> Self::Borrowed<'a> {
1374            value
1375        }
1376    }
1377
1378    unsafe impl fidl::encoding::TypeMarker for ProviderListTypefacesRequest {
1379        type Owned = Self;
1380
1381        #[inline(always)]
1382        fn inline_align(_context: fidl::encoding::Context) -> usize {
1383            8
1384        }
1385
1386        #[inline(always)]
1387        fn inline_size(_context: fidl::encoding::Context) -> usize {
1388            24
1389        }
1390    }
1391
1392    unsafe impl
1393        fidl::encoding::Encode<
1394            ProviderListTypefacesRequest,
1395            fidl::encoding::DefaultFuchsiaResourceDialect,
1396        > for &mut ProviderListTypefacesRequest
1397    {
1398        #[inline]
1399        unsafe fn encode(
1400            self,
1401            encoder: &mut fidl::encoding::Encoder<
1402                '_,
1403                fidl::encoding::DefaultFuchsiaResourceDialect,
1404            >,
1405            offset: usize,
1406            _depth: fidl::encoding::Depth,
1407        ) -> fidl::Result<()> {
1408            encoder.debug_check_bounds::<ProviderListTypefacesRequest>(offset);
1409            // Delegate to tuple encoding.
1410            fidl::encoding::Encode::<
1411                ProviderListTypefacesRequest,
1412                fidl::encoding::DefaultFuchsiaResourceDialect,
1413            >::encode(
1414                (
1415                    <ListTypefacesRequest as fidl::encoding::ValueTypeMarker>::borrow(
1416                        &self.request,
1417                    ),
1418                    <fidl::encoding::Endpoint<
1419                        fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
1420                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1421                        &mut self.iterator
1422                    ),
1423                ),
1424                encoder,
1425                offset,
1426                _depth,
1427            )
1428        }
1429    }
1430    unsafe impl<
1431        T0: fidl::encoding::Encode<ListTypefacesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>,
1432        T1: fidl::encoding::Encode<
1433                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>>,
1434                fidl::encoding::DefaultFuchsiaResourceDialect,
1435            >,
1436    >
1437        fidl::encoding::Encode<
1438            ProviderListTypefacesRequest,
1439            fidl::encoding::DefaultFuchsiaResourceDialect,
1440        > for (T0, T1)
1441    {
1442        #[inline]
1443        unsafe fn encode(
1444            self,
1445            encoder: &mut fidl::encoding::Encoder<
1446                '_,
1447                fidl::encoding::DefaultFuchsiaResourceDialect,
1448            >,
1449            offset: usize,
1450            depth: fidl::encoding::Depth,
1451        ) -> fidl::Result<()> {
1452            encoder.debug_check_bounds::<ProviderListTypefacesRequest>(offset);
1453            // Zero out padding regions. There's no need to apply masks
1454            // because the unmasked parts will be overwritten by fields.
1455            unsafe {
1456                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1457                (ptr as *mut u64).write_unaligned(0);
1458            }
1459            // Write the fields.
1460            self.0.encode(encoder, offset + 0, depth)?;
1461            self.1.encode(encoder, offset + 16, depth)?;
1462            Ok(())
1463        }
1464    }
1465
1466    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1467        for ProviderListTypefacesRequest
1468    {
1469        #[inline(always)]
1470        fn new_empty() -> Self {
1471            Self {
1472                request: fidl::new_empty!(
1473                    ListTypefacesRequest,
1474                    fidl::encoding::DefaultFuchsiaResourceDialect
1475                ),
1476                iterator: fidl::new_empty!(
1477                    fidl::encoding::Endpoint<
1478                        fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>,
1479                    >,
1480                    fidl::encoding::DefaultFuchsiaResourceDialect
1481                ),
1482            }
1483        }
1484
1485        #[inline]
1486        unsafe fn decode(
1487            &mut self,
1488            decoder: &mut fidl::encoding::Decoder<
1489                '_,
1490                fidl::encoding::DefaultFuchsiaResourceDialect,
1491            >,
1492            offset: usize,
1493            _depth: fidl::encoding::Depth,
1494        ) -> fidl::Result<()> {
1495            decoder.debug_check_bounds::<Self>(offset);
1496            // Verify that padding bytes are zero.
1497            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1498            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1499            let mask = 0xffffffff00000000u64;
1500            let maskedval = padval & mask;
1501            if maskedval != 0 {
1502                return Err(fidl::Error::NonZeroPadding {
1503                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1504                });
1505            }
1506            fidl::decode!(
1507                ListTypefacesRequest,
1508                fidl::encoding::DefaultFuchsiaResourceDialect,
1509                &mut self.request,
1510                decoder,
1511                offset + 0,
1512                _depth
1513            )?;
1514            fidl::decode!(
1515                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ListTypefacesIteratorMarker>>,
1516                fidl::encoding::DefaultFuchsiaResourceDialect,
1517                &mut self.iterator,
1518                decoder,
1519                offset + 16,
1520                _depth
1521            )?;
1522            Ok(())
1523        }
1524    }
1525
1526    impl fidl::encoding::ResourceTypeMarker for ProviderGetTypefaceByIdResponse {
1527        type Borrowed<'a> = &'a mut Self;
1528        fn take_or_borrow<'a>(
1529            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1530        ) -> Self::Borrowed<'a> {
1531            value
1532        }
1533    }
1534
1535    unsafe impl fidl::encoding::TypeMarker for ProviderGetTypefaceByIdResponse {
1536        type Owned = Self;
1537
1538        #[inline(always)]
1539        fn inline_align(_context: fidl::encoding::Context) -> usize {
1540            8
1541        }
1542
1543        #[inline(always)]
1544        fn inline_size(_context: fidl::encoding::Context) -> usize {
1545            16
1546        }
1547    }
1548
1549    unsafe impl
1550        fidl::encoding::Encode<
1551            ProviderGetTypefaceByIdResponse,
1552            fidl::encoding::DefaultFuchsiaResourceDialect,
1553        > for &mut ProviderGetTypefaceByIdResponse
1554    {
1555        #[inline]
1556        unsafe fn encode(
1557            self,
1558            encoder: &mut fidl::encoding::Encoder<
1559                '_,
1560                fidl::encoding::DefaultFuchsiaResourceDialect,
1561            >,
1562            offset: usize,
1563            _depth: fidl::encoding::Depth,
1564        ) -> fidl::Result<()> {
1565            encoder.debug_check_bounds::<ProviderGetTypefaceByIdResponse>(offset);
1566            // Delegate to tuple encoding.
1567            fidl::encoding::Encode::<ProviderGetTypefaceByIdResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1568                (
1569                    <fidl_fuchsia_fonts::TypefaceResponse as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.response),
1570                ),
1571                encoder, offset, _depth
1572            )
1573        }
1574    }
1575    unsafe impl<
1576        T0: fidl::encoding::Encode<
1577                fidl_fuchsia_fonts::TypefaceResponse,
1578                fidl::encoding::DefaultFuchsiaResourceDialect,
1579            >,
1580    >
1581        fidl::encoding::Encode<
1582            ProviderGetTypefaceByIdResponse,
1583            fidl::encoding::DefaultFuchsiaResourceDialect,
1584        > for (T0,)
1585    {
1586        #[inline]
1587        unsafe fn encode(
1588            self,
1589            encoder: &mut fidl::encoding::Encoder<
1590                '_,
1591                fidl::encoding::DefaultFuchsiaResourceDialect,
1592            >,
1593            offset: usize,
1594            depth: fidl::encoding::Depth,
1595        ) -> fidl::Result<()> {
1596            encoder.debug_check_bounds::<ProviderGetTypefaceByIdResponse>(offset);
1597            // Zero out padding regions. There's no need to apply masks
1598            // because the unmasked parts will be overwritten by fields.
1599            // Write the fields.
1600            self.0.encode(encoder, offset + 0, depth)?;
1601            Ok(())
1602        }
1603    }
1604
1605    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1606        for ProviderGetTypefaceByIdResponse
1607    {
1608        #[inline(always)]
1609        fn new_empty() -> Self {
1610            Self {
1611                response: fidl::new_empty!(
1612                    fidl_fuchsia_fonts::TypefaceResponse,
1613                    fidl::encoding::DefaultFuchsiaResourceDialect
1614                ),
1615            }
1616        }
1617
1618        #[inline]
1619        unsafe fn decode(
1620            &mut self,
1621            decoder: &mut fidl::encoding::Decoder<
1622                '_,
1623                fidl::encoding::DefaultFuchsiaResourceDialect,
1624            >,
1625            offset: usize,
1626            _depth: fidl::encoding::Depth,
1627        ) -> fidl::Result<()> {
1628            decoder.debug_check_bounds::<Self>(offset);
1629            // Verify that padding bytes are zero.
1630            fidl::decode!(
1631                fidl_fuchsia_fonts::TypefaceResponse,
1632                fidl::encoding::DefaultFuchsiaResourceDialect,
1633                &mut self.response,
1634                decoder,
1635                offset + 0,
1636                _depth
1637            )?;
1638            Ok(())
1639        }
1640    }
1641}