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