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