Skip to main content

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