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