fidl_fuchsia_hardware_trippoint/
fidl_fuchsia_hardware_trippoint.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_hardware_trippoint__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DebugMarker;
16
17impl fidl::endpoints::ProtocolMarker for DebugMarker {
18    type Proxy = DebugProxy;
19    type RequestStream = DebugRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DebugSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Debug";
24}
25pub type DebugTripResult = Result<(), i32>;
26
27pub trait DebugProxyInterface: Send + Sync {
28    type TripResponseFut: std::future::Future<Output = Result<DebugTripResult, fidl::Error>> + Send;
29    fn r#trip(&self, index: u32) -> Self::TripResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct DebugSynchronousProxy {
34    client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
39    type Proxy = DebugProxy;
40    type Protocol = DebugMarker;
41
42    fn from_channel(inner: fidl::Channel) -> Self {
43        Self::new(inner)
44    }
45
46    fn into_channel(self) -> fidl::Channel {
47        self.client.into_channel()
48    }
49
50    fn as_channel(&self) -> &fidl::Channel {
51        self.client.as_channel()
52    }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl DebugSynchronousProxy {
57    pub fn new(channel: fidl::Channel) -> Self {
58        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60    }
61
62    pub fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    /// Waits until an event arrives and returns it. It is safe for other
67    /// threads to make concurrent requests while waiting for an event.
68    pub fn wait_for_event(
69        &self,
70        deadline: zx::MonotonicInstant,
71    ) -> Result<DebugEvent, fidl::Error> {
72        DebugEvent::decode(self.client.wait_for_event(deadline)?)
73    }
74
75    /// Trips the trip point with index if it exists. If not, returns ZX_ERR_NOT_FOUND. Note that
76    /// for OneShot trip points, if it is tripped, it gets cleared. Tripping manually with this
77    /// method will have the same effect.
78    pub fn r#trip(
79        &self,
80        mut index: u32,
81        ___deadline: zx::MonotonicInstant,
82    ) -> Result<DebugTripResult, fidl::Error> {
83        let _response = self.client.send_query::<
84            DebugTripRequest,
85            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
86        >(
87            (index,),
88            0x2785e550debdf5a,
89            fidl::encoding::DynamicFlags::FLEXIBLE,
90            ___deadline,
91        )?
92        .into_result::<DebugMarker>("trip")?;
93        Ok(_response.map(|x| x))
94    }
95}
96
97#[cfg(target_os = "fuchsia")]
98impl From<DebugSynchronousProxy> for zx::NullableHandle {
99    fn from(value: DebugSynchronousProxy) -> Self {
100        value.into_channel().into()
101    }
102}
103
104#[cfg(target_os = "fuchsia")]
105impl From<fidl::Channel> for DebugSynchronousProxy {
106    fn from(value: fidl::Channel) -> Self {
107        Self::new(value)
108    }
109}
110
111#[cfg(target_os = "fuchsia")]
112impl fidl::endpoints::FromClient for DebugSynchronousProxy {
113    type Protocol = DebugMarker;
114
115    fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
116        Self::new(value.into_channel())
117    }
118}
119
120#[derive(Debug, Clone)]
121pub struct DebugProxy {
122    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
123}
124
125impl fidl::endpoints::Proxy for DebugProxy {
126    type Protocol = DebugMarker;
127
128    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
129        Self::new(inner)
130    }
131
132    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
133        self.client.into_channel().map_err(|client| Self { client })
134    }
135
136    fn as_channel(&self) -> &::fidl::AsyncChannel {
137        self.client.as_channel()
138    }
139}
140
141impl DebugProxy {
142    /// Create a new Proxy for fuchsia.hardware.trippoint/Debug.
143    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
144        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
145        Self { client: fidl::client::Client::new(channel, protocol_name) }
146    }
147
148    /// Get a Stream of events from the remote end of the protocol.
149    ///
150    /// # Panics
151    ///
152    /// Panics if the event stream was already taken.
153    pub fn take_event_stream(&self) -> DebugEventStream {
154        DebugEventStream { event_receiver: self.client.take_event_receiver() }
155    }
156
157    /// Trips the trip point with index if it exists. If not, returns ZX_ERR_NOT_FOUND. Note that
158    /// for OneShot trip points, if it is tripped, it gets cleared. Tripping manually with this
159    /// method will have the same effect.
160    pub fn r#trip(
161        &self,
162        mut index: u32,
163    ) -> fidl::client::QueryResponseFut<
164        DebugTripResult,
165        fidl::encoding::DefaultFuchsiaResourceDialect,
166    > {
167        DebugProxyInterface::r#trip(self, index)
168    }
169}
170
171impl DebugProxyInterface for DebugProxy {
172    type TripResponseFut = fidl::client::QueryResponseFut<
173        DebugTripResult,
174        fidl::encoding::DefaultFuchsiaResourceDialect,
175    >;
176    fn r#trip(&self, mut index: u32) -> Self::TripResponseFut {
177        fn _decode(
178            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
179        ) -> Result<DebugTripResult, fidl::Error> {
180            let _response = fidl::client::decode_transaction_body::<
181                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
182                fidl::encoding::DefaultFuchsiaResourceDialect,
183                0x2785e550debdf5a,
184            >(_buf?)?
185            .into_result::<DebugMarker>("trip")?;
186            Ok(_response.map(|x| x))
187        }
188        self.client.send_query_and_decode::<DebugTripRequest, DebugTripResult>(
189            (index,),
190            0x2785e550debdf5a,
191            fidl::encoding::DynamicFlags::FLEXIBLE,
192            _decode,
193        )
194    }
195}
196
197pub struct DebugEventStream {
198    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
199}
200
201impl std::marker::Unpin for DebugEventStream {}
202
203impl futures::stream::FusedStream for DebugEventStream {
204    fn is_terminated(&self) -> bool {
205        self.event_receiver.is_terminated()
206    }
207}
208
209impl futures::Stream for DebugEventStream {
210    type Item = Result<DebugEvent, fidl::Error>;
211
212    fn poll_next(
213        mut self: std::pin::Pin<&mut Self>,
214        cx: &mut std::task::Context<'_>,
215    ) -> std::task::Poll<Option<Self::Item>> {
216        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
217            &mut self.event_receiver,
218            cx
219        )?) {
220            Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
221            None => std::task::Poll::Ready(None),
222        }
223    }
224}
225
226#[derive(Debug)]
227pub enum DebugEvent {
228    #[non_exhaustive]
229    _UnknownEvent {
230        /// Ordinal of the event that was sent.
231        ordinal: u64,
232    },
233}
234
235impl DebugEvent {
236    /// Decodes a message buffer as a [`DebugEvent`].
237    fn decode(
238        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
239    ) -> Result<DebugEvent, fidl::Error> {
240        let (bytes, _handles) = buf.split_mut();
241        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
242        debug_assert_eq!(tx_header.tx_id, 0);
243        match tx_header.ordinal {
244            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
245                Ok(DebugEvent::_UnknownEvent { ordinal: tx_header.ordinal })
246            }
247            _ => Err(fidl::Error::UnknownOrdinal {
248                ordinal: tx_header.ordinal,
249                protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
250            }),
251        }
252    }
253}
254
255/// A Stream of incoming requests for fuchsia.hardware.trippoint/Debug.
256pub struct DebugRequestStream {
257    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
258    is_terminated: bool,
259}
260
261impl std::marker::Unpin for DebugRequestStream {}
262
263impl futures::stream::FusedStream for DebugRequestStream {
264    fn is_terminated(&self) -> bool {
265        self.is_terminated
266    }
267}
268
269impl fidl::endpoints::RequestStream for DebugRequestStream {
270    type Protocol = DebugMarker;
271    type ControlHandle = DebugControlHandle;
272
273    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
274        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
275    }
276
277    fn control_handle(&self) -> Self::ControlHandle {
278        DebugControlHandle { inner: self.inner.clone() }
279    }
280
281    fn into_inner(
282        self,
283    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
284    {
285        (self.inner, self.is_terminated)
286    }
287
288    fn from_inner(
289        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
290        is_terminated: bool,
291    ) -> Self {
292        Self { inner, is_terminated }
293    }
294}
295
296impl futures::Stream for DebugRequestStream {
297    type Item = Result<DebugRequest, fidl::Error>;
298
299    fn poll_next(
300        mut self: std::pin::Pin<&mut Self>,
301        cx: &mut std::task::Context<'_>,
302    ) -> std::task::Poll<Option<Self::Item>> {
303        let this = &mut *self;
304        if this.inner.check_shutdown(cx) {
305            this.is_terminated = true;
306            return std::task::Poll::Ready(None);
307        }
308        if this.is_terminated {
309            panic!("polled DebugRequestStream after completion");
310        }
311        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
312            |bytes, handles| {
313                match this.inner.channel().read_etc(cx, bytes, handles) {
314                    std::task::Poll::Ready(Ok(())) => {}
315                    std::task::Poll::Pending => return std::task::Poll::Pending,
316                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
317                        this.is_terminated = true;
318                        return std::task::Poll::Ready(None);
319                    }
320                    std::task::Poll::Ready(Err(e)) => {
321                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
322                            e.into(),
323                        ))));
324                    }
325                }
326
327                // A message has been received from the channel
328                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
329
330                std::task::Poll::Ready(Some(match header.ordinal {
331                    0x2785e550debdf5a => {
332                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
333                        let mut req = fidl::new_empty!(
334                            DebugTripRequest,
335                            fidl::encoding::DefaultFuchsiaResourceDialect
336                        );
337                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugTripRequest>(&header, _body_bytes, handles, &mut req)?;
338                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
339                        Ok(DebugRequest::Trip {
340                            index: req.index,
341
342                            responder: DebugTripResponder {
343                                control_handle: std::mem::ManuallyDrop::new(control_handle),
344                                tx_id: header.tx_id,
345                            },
346                        })
347                    }
348                    _ if header.tx_id == 0
349                        && header
350                            .dynamic_flags()
351                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
352                    {
353                        Ok(DebugRequest::_UnknownMethod {
354                            ordinal: header.ordinal,
355                            control_handle: DebugControlHandle { inner: this.inner.clone() },
356                            method_type: fidl::MethodType::OneWay,
357                        })
358                    }
359                    _ if header
360                        .dynamic_flags()
361                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
362                    {
363                        this.inner.send_framework_err(
364                            fidl::encoding::FrameworkErr::UnknownMethod,
365                            header.tx_id,
366                            header.ordinal,
367                            header.dynamic_flags(),
368                            (bytes, handles),
369                        )?;
370                        Ok(DebugRequest::_UnknownMethod {
371                            ordinal: header.ordinal,
372                            control_handle: DebugControlHandle { inner: this.inner.clone() },
373                            method_type: fidl::MethodType::TwoWay,
374                        })
375                    }
376                    _ => Err(fidl::Error::UnknownOrdinal {
377                        ordinal: header.ordinal,
378                        protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
379                    }),
380                }))
381            },
382        )
383    }
384}
385
386/// Debug protocol to fake tripping trip points.
387#[derive(Debug)]
388pub enum DebugRequest {
389    /// Trips the trip point with index if it exists. If not, returns ZX_ERR_NOT_FOUND. Note that
390    /// for OneShot trip points, if it is tripped, it gets cleared. Tripping manually with this
391    /// method will have the same effect.
392    Trip { index: u32, responder: DebugTripResponder },
393    /// An interaction was received which does not match any known method.
394    #[non_exhaustive]
395    _UnknownMethod {
396        /// Ordinal of the method that was called.
397        ordinal: u64,
398        control_handle: DebugControlHandle,
399        method_type: fidl::MethodType,
400    },
401}
402
403impl DebugRequest {
404    #[allow(irrefutable_let_patterns)]
405    pub fn into_trip(self) -> Option<(u32, DebugTripResponder)> {
406        if let DebugRequest::Trip { index, responder } = self {
407            Some((index, responder))
408        } else {
409            None
410        }
411    }
412
413    /// Name of the method defined in FIDL
414    pub fn method_name(&self) -> &'static str {
415        match *self {
416            DebugRequest::Trip { .. } => "trip",
417            DebugRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
418                "unknown one-way method"
419            }
420            DebugRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
421                "unknown two-way method"
422            }
423        }
424    }
425}
426
427#[derive(Debug, Clone)]
428pub struct DebugControlHandle {
429    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
430}
431
432impl fidl::endpoints::ControlHandle for DebugControlHandle {
433    fn shutdown(&self) {
434        self.inner.shutdown()
435    }
436
437    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
438        self.inner.shutdown_with_epitaph(status)
439    }
440
441    fn is_closed(&self) -> bool {
442        self.inner.channel().is_closed()
443    }
444    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
445        self.inner.channel().on_closed()
446    }
447
448    #[cfg(target_os = "fuchsia")]
449    fn signal_peer(
450        &self,
451        clear_mask: zx::Signals,
452        set_mask: zx::Signals,
453    ) -> Result<(), zx_status::Status> {
454        use fidl::Peered;
455        self.inner.channel().signal_peer(clear_mask, set_mask)
456    }
457}
458
459impl DebugControlHandle {}
460
461#[must_use = "FIDL methods require a response to be sent"]
462#[derive(Debug)]
463pub struct DebugTripResponder {
464    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
465    tx_id: u32,
466}
467
468/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
469/// if the responder is dropped without sending a response, so that the client
470/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
471impl std::ops::Drop for DebugTripResponder {
472    fn drop(&mut self) {
473        self.control_handle.shutdown();
474        // Safety: drops once, never accessed again
475        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
476    }
477}
478
479impl fidl::endpoints::Responder for DebugTripResponder {
480    type ControlHandle = DebugControlHandle;
481
482    fn control_handle(&self) -> &DebugControlHandle {
483        &self.control_handle
484    }
485
486    fn drop_without_shutdown(mut self) {
487        // Safety: drops once, never accessed again due to mem::forget
488        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
489        // Prevent Drop from running (which would shut down the channel)
490        std::mem::forget(self);
491    }
492}
493
494impl DebugTripResponder {
495    /// Sends a response to the FIDL transaction.
496    ///
497    /// Sets the channel to shutdown if an error occurs.
498    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
499        let _result = self.send_raw(result);
500        if _result.is_err() {
501            self.control_handle.shutdown();
502        }
503        self.drop_without_shutdown();
504        _result
505    }
506
507    /// Similar to "send" but does not shutdown the channel if an error occurs.
508    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
509        let _result = self.send_raw(result);
510        self.drop_without_shutdown();
511        _result
512    }
513
514    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
515        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
516            fidl::encoding::EmptyStruct,
517            i32,
518        >>(
519            fidl::encoding::FlexibleResult::new(result),
520            self.tx_id,
521            0x2785e550debdf5a,
522            fidl::encoding::DynamicFlags::FLEXIBLE,
523        )
524    }
525}
526
527#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
528pub struct TripPointMarker;
529
530impl fidl::endpoints::ProtocolMarker for TripPointMarker {
531    type Proxy = TripPointProxy;
532    type RequestStream = TripPointRequestStream;
533    #[cfg(target_os = "fuchsia")]
534    type SynchronousProxy = TripPointSynchronousProxy;
535
536    const DEBUG_NAME: &'static str = "(anonymous) TripPoint";
537}
538pub type TripPointGetTripPointDescriptorsResult = Result<Vec<TripPointDescriptor>, i32>;
539pub type TripPointSetTripPointsResult = Result<(), i32>;
540pub type TripPointWaitForAnyTripPointResult = Result<TripPointResult, i32>;
541
542pub trait TripPointProxyInterface: Send + Sync {
543    type GetTripPointDescriptorsResponseFut: std::future::Future<Output = Result<TripPointGetTripPointDescriptorsResult, fidl::Error>>
544        + Send;
545    fn r#get_trip_point_descriptors(&self) -> Self::GetTripPointDescriptorsResponseFut;
546    type SetTripPointsResponseFut: std::future::Future<Output = Result<TripPointSetTripPointsResult, fidl::Error>>
547        + Send;
548    fn r#set_trip_points(
549        &self,
550        descriptors: &[TripPointDescriptor],
551    ) -> Self::SetTripPointsResponseFut;
552    type WaitForAnyTripPointResponseFut: std::future::Future<Output = Result<TripPointWaitForAnyTripPointResult, fidl::Error>>
553        + Send;
554    fn r#wait_for_any_trip_point(&self) -> Self::WaitForAnyTripPointResponseFut;
555}
556#[derive(Debug)]
557#[cfg(target_os = "fuchsia")]
558pub struct TripPointSynchronousProxy {
559    client: fidl::client::sync::Client,
560}
561
562#[cfg(target_os = "fuchsia")]
563impl fidl::endpoints::SynchronousProxy for TripPointSynchronousProxy {
564    type Proxy = TripPointProxy;
565    type Protocol = TripPointMarker;
566
567    fn from_channel(inner: fidl::Channel) -> Self {
568        Self::new(inner)
569    }
570
571    fn into_channel(self) -> fidl::Channel {
572        self.client.into_channel()
573    }
574
575    fn as_channel(&self) -> &fidl::Channel {
576        self.client.as_channel()
577    }
578}
579
580#[cfg(target_os = "fuchsia")]
581impl TripPointSynchronousProxy {
582    pub fn new(channel: fidl::Channel) -> Self {
583        let protocol_name = <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
584        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
585    }
586
587    pub fn into_channel(self) -> fidl::Channel {
588        self.client.into_channel()
589    }
590
591    /// Waits until an event arrives and returns it. It is safe for other
592    /// threads to make concurrent requests while waiting for an event.
593    pub fn wait_for_event(
594        &self,
595        deadline: zx::MonotonicInstant,
596    ) -> Result<TripPointEvent, fidl::Error> {
597        TripPointEvent::decode(self.client.wait_for_event(deadline)?)
598    }
599
600    /// Returns N descriptors. Each descriptor describes one trip point
601    /// supported by the hardware.
602    pub fn r#get_trip_point_descriptors(
603        &self,
604        ___deadline: zx::MonotonicInstant,
605    ) -> Result<TripPointGetTripPointDescriptorsResult, fidl::Error> {
606        let _response = self.client.send_query::<
607            fidl::encoding::EmptyPayload,
608            fidl::encoding::FlexibleResultType<TripPointGetTripPointDescriptorsResponse, i32>,
609        >(
610            (),
611            0xbbc73e208bf4875,
612            fidl::encoding::DynamicFlags::FLEXIBLE,
613            ___deadline,
614        )?
615        .into_result::<TripPointMarker>("get_trip_point_descriptors")?;
616        Ok(_response.map(|x| x.descriptors))
617    }
618
619    /// Configure 0 or more hardware trip points.
620    pub fn r#set_trip_points(
621        &self,
622        mut descriptors: &[TripPointDescriptor],
623        ___deadline: zx::MonotonicInstant,
624    ) -> Result<TripPointSetTripPointsResult, fidl::Error> {
625        let _response = self.client.send_query::<
626            TripPointSetTripPointsRequest,
627            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
628        >(
629            (descriptors,),
630            0x8e768ac1e677593,
631            fidl::encoding::DynamicFlags::FLEXIBLE,
632            ___deadline,
633        )?
634        .into_result::<TripPointMarker>("set_trip_points")?;
635        Ok(_response.map(|x| x))
636    }
637
638    /// Hanging get API that returns when any configured trip point has been
639    /// crossed.
640    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
641    /// all configured trip points are cleared by a call to SetTripPoints.
642    pub fn r#wait_for_any_trip_point(
643        &self,
644        ___deadline: zx::MonotonicInstant,
645    ) -> Result<TripPointWaitForAnyTripPointResult, fidl::Error> {
646        let _response = self.client.send_query::<
647            fidl::encoding::EmptyPayload,
648            fidl::encoding::FlexibleResultType<TripPointWaitForAnyTripPointResponse, i32>,
649        >(
650            (),
651            0x66b959b54d27ce45,
652            fidl::encoding::DynamicFlags::FLEXIBLE,
653            ___deadline,
654        )?
655        .into_result::<TripPointMarker>("wait_for_any_trip_point")?;
656        Ok(_response.map(|x| x.result))
657    }
658}
659
660#[cfg(target_os = "fuchsia")]
661impl From<TripPointSynchronousProxy> for zx::NullableHandle {
662    fn from(value: TripPointSynchronousProxy) -> Self {
663        value.into_channel().into()
664    }
665}
666
667#[cfg(target_os = "fuchsia")]
668impl From<fidl::Channel> for TripPointSynchronousProxy {
669    fn from(value: fidl::Channel) -> Self {
670        Self::new(value)
671    }
672}
673
674#[cfg(target_os = "fuchsia")]
675impl fidl::endpoints::FromClient for TripPointSynchronousProxy {
676    type Protocol = TripPointMarker;
677
678    fn from_client(value: fidl::endpoints::ClientEnd<TripPointMarker>) -> Self {
679        Self::new(value.into_channel())
680    }
681}
682
683#[derive(Debug, Clone)]
684pub struct TripPointProxy {
685    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
686}
687
688impl fidl::endpoints::Proxy for TripPointProxy {
689    type Protocol = TripPointMarker;
690
691    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
692        Self::new(inner)
693    }
694
695    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
696        self.client.into_channel().map_err(|client| Self { client })
697    }
698
699    fn as_channel(&self) -> &::fidl::AsyncChannel {
700        self.client.as_channel()
701    }
702}
703
704impl TripPointProxy {
705    /// Create a new Proxy for fuchsia.hardware.trippoint/TripPoint.
706    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
707        let protocol_name = <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
708        Self { client: fidl::client::Client::new(channel, protocol_name) }
709    }
710
711    /// Get a Stream of events from the remote end of the protocol.
712    ///
713    /// # Panics
714    ///
715    /// Panics if the event stream was already taken.
716    pub fn take_event_stream(&self) -> TripPointEventStream {
717        TripPointEventStream { event_receiver: self.client.take_event_receiver() }
718    }
719
720    /// Returns N descriptors. Each descriptor describes one trip point
721    /// supported by the hardware.
722    pub fn r#get_trip_point_descriptors(
723        &self,
724    ) -> fidl::client::QueryResponseFut<
725        TripPointGetTripPointDescriptorsResult,
726        fidl::encoding::DefaultFuchsiaResourceDialect,
727    > {
728        TripPointProxyInterface::r#get_trip_point_descriptors(self)
729    }
730
731    /// Configure 0 or more hardware trip points.
732    pub fn r#set_trip_points(
733        &self,
734        mut descriptors: &[TripPointDescriptor],
735    ) -> fidl::client::QueryResponseFut<
736        TripPointSetTripPointsResult,
737        fidl::encoding::DefaultFuchsiaResourceDialect,
738    > {
739        TripPointProxyInterface::r#set_trip_points(self, descriptors)
740    }
741
742    /// Hanging get API that returns when any configured trip point has been
743    /// crossed.
744    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
745    /// all configured trip points are cleared by a call to SetTripPoints.
746    pub fn r#wait_for_any_trip_point(
747        &self,
748    ) -> fidl::client::QueryResponseFut<
749        TripPointWaitForAnyTripPointResult,
750        fidl::encoding::DefaultFuchsiaResourceDialect,
751    > {
752        TripPointProxyInterface::r#wait_for_any_trip_point(self)
753    }
754}
755
756impl TripPointProxyInterface for TripPointProxy {
757    type GetTripPointDescriptorsResponseFut = fidl::client::QueryResponseFut<
758        TripPointGetTripPointDescriptorsResult,
759        fidl::encoding::DefaultFuchsiaResourceDialect,
760    >;
761    fn r#get_trip_point_descriptors(&self) -> Self::GetTripPointDescriptorsResponseFut {
762        fn _decode(
763            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
764        ) -> Result<TripPointGetTripPointDescriptorsResult, fidl::Error> {
765            let _response = fidl::client::decode_transaction_body::<
766                fidl::encoding::FlexibleResultType<TripPointGetTripPointDescriptorsResponse, i32>,
767                fidl::encoding::DefaultFuchsiaResourceDialect,
768                0xbbc73e208bf4875,
769            >(_buf?)?
770            .into_result::<TripPointMarker>("get_trip_point_descriptors")?;
771            Ok(_response.map(|x| x.descriptors))
772        }
773        self.client.send_query_and_decode::<
774            fidl::encoding::EmptyPayload,
775            TripPointGetTripPointDescriptorsResult,
776        >(
777            (),
778            0xbbc73e208bf4875,
779            fidl::encoding::DynamicFlags::FLEXIBLE,
780            _decode,
781        )
782    }
783
784    type SetTripPointsResponseFut = fidl::client::QueryResponseFut<
785        TripPointSetTripPointsResult,
786        fidl::encoding::DefaultFuchsiaResourceDialect,
787    >;
788    fn r#set_trip_points(
789        &self,
790        mut descriptors: &[TripPointDescriptor],
791    ) -> Self::SetTripPointsResponseFut {
792        fn _decode(
793            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
794        ) -> Result<TripPointSetTripPointsResult, fidl::Error> {
795            let _response = fidl::client::decode_transaction_body::<
796                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
797                fidl::encoding::DefaultFuchsiaResourceDialect,
798                0x8e768ac1e677593,
799            >(_buf?)?
800            .into_result::<TripPointMarker>("set_trip_points")?;
801            Ok(_response.map(|x| x))
802        }
803        self.client
804            .send_query_and_decode::<TripPointSetTripPointsRequest, TripPointSetTripPointsResult>(
805                (descriptors,),
806                0x8e768ac1e677593,
807                fidl::encoding::DynamicFlags::FLEXIBLE,
808                _decode,
809            )
810    }
811
812    type WaitForAnyTripPointResponseFut = fidl::client::QueryResponseFut<
813        TripPointWaitForAnyTripPointResult,
814        fidl::encoding::DefaultFuchsiaResourceDialect,
815    >;
816    fn r#wait_for_any_trip_point(&self) -> Self::WaitForAnyTripPointResponseFut {
817        fn _decode(
818            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
819        ) -> Result<TripPointWaitForAnyTripPointResult, fidl::Error> {
820            let _response = fidl::client::decode_transaction_body::<
821                fidl::encoding::FlexibleResultType<TripPointWaitForAnyTripPointResponse, i32>,
822                fidl::encoding::DefaultFuchsiaResourceDialect,
823                0x66b959b54d27ce45,
824            >(_buf?)?
825            .into_result::<TripPointMarker>("wait_for_any_trip_point")?;
826            Ok(_response.map(|x| x.result))
827        }
828        self.client.send_query_and_decode::<
829            fidl::encoding::EmptyPayload,
830            TripPointWaitForAnyTripPointResult,
831        >(
832            (),
833            0x66b959b54d27ce45,
834            fidl::encoding::DynamicFlags::FLEXIBLE,
835            _decode,
836        )
837    }
838}
839
840pub struct TripPointEventStream {
841    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
842}
843
844impl std::marker::Unpin for TripPointEventStream {}
845
846impl futures::stream::FusedStream for TripPointEventStream {
847    fn is_terminated(&self) -> bool {
848        self.event_receiver.is_terminated()
849    }
850}
851
852impl futures::Stream for TripPointEventStream {
853    type Item = Result<TripPointEvent, fidl::Error>;
854
855    fn poll_next(
856        mut self: std::pin::Pin<&mut Self>,
857        cx: &mut std::task::Context<'_>,
858    ) -> std::task::Poll<Option<Self::Item>> {
859        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
860            &mut self.event_receiver,
861            cx
862        )?) {
863            Some(buf) => std::task::Poll::Ready(Some(TripPointEvent::decode(buf))),
864            None => std::task::Poll::Ready(None),
865        }
866    }
867}
868
869#[derive(Debug)]
870pub enum TripPointEvent {
871    #[non_exhaustive]
872    _UnknownEvent {
873        /// Ordinal of the event that was sent.
874        ordinal: u64,
875    },
876}
877
878impl TripPointEvent {
879    /// Decodes a message buffer as a [`TripPointEvent`].
880    fn decode(
881        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
882    ) -> Result<TripPointEvent, fidl::Error> {
883        let (bytes, _handles) = buf.split_mut();
884        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
885        debug_assert_eq!(tx_header.tx_id, 0);
886        match tx_header.ordinal {
887            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
888                Ok(TripPointEvent::_UnknownEvent { ordinal: tx_header.ordinal })
889            }
890            _ => Err(fidl::Error::UnknownOrdinal {
891                ordinal: tx_header.ordinal,
892                protocol_name: <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
893            }),
894        }
895    }
896}
897
898/// A Stream of incoming requests for fuchsia.hardware.trippoint/TripPoint.
899pub struct TripPointRequestStream {
900    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
901    is_terminated: bool,
902}
903
904impl std::marker::Unpin for TripPointRequestStream {}
905
906impl futures::stream::FusedStream for TripPointRequestStream {
907    fn is_terminated(&self) -> bool {
908        self.is_terminated
909    }
910}
911
912impl fidl::endpoints::RequestStream for TripPointRequestStream {
913    type Protocol = TripPointMarker;
914    type ControlHandle = TripPointControlHandle;
915
916    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
917        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
918    }
919
920    fn control_handle(&self) -> Self::ControlHandle {
921        TripPointControlHandle { inner: self.inner.clone() }
922    }
923
924    fn into_inner(
925        self,
926    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
927    {
928        (self.inner, self.is_terminated)
929    }
930
931    fn from_inner(
932        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
933        is_terminated: bool,
934    ) -> Self {
935        Self { inner, is_terminated }
936    }
937}
938
939impl futures::Stream for TripPointRequestStream {
940    type Item = Result<TripPointRequest, fidl::Error>;
941
942    fn poll_next(
943        mut self: std::pin::Pin<&mut Self>,
944        cx: &mut std::task::Context<'_>,
945    ) -> std::task::Poll<Option<Self::Item>> {
946        let this = &mut *self;
947        if this.inner.check_shutdown(cx) {
948            this.is_terminated = true;
949            return std::task::Poll::Ready(None);
950        }
951        if this.is_terminated {
952            panic!("polled TripPointRequestStream after completion");
953        }
954        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
955            |bytes, handles| {
956                match this.inner.channel().read_etc(cx, bytes, handles) {
957                    std::task::Poll::Ready(Ok(())) => {}
958                    std::task::Poll::Pending => return std::task::Poll::Pending,
959                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
960                        this.is_terminated = true;
961                        return std::task::Poll::Ready(None);
962                    }
963                    std::task::Poll::Ready(Err(e)) => {
964                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
965                            e.into(),
966                        ))));
967                    }
968                }
969
970                // A message has been received from the channel
971                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
972
973                std::task::Poll::Ready(Some(match header.ordinal {
974                    0xbbc73e208bf4875 => {
975                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
976                        let mut req = fidl::new_empty!(
977                            fidl::encoding::EmptyPayload,
978                            fidl::encoding::DefaultFuchsiaResourceDialect
979                        );
980                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
981                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
982                        Ok(TripPointRequest::GetTripPointDescriptors {
983                            responder: TripPointGetTripPointDescriptorsResponder {
984                                control_handle: std::mem::ManuallyDrop::new(control_handle),
985                                tx_id: header.tx_id,
986                            },
987                        })
988                    }
989                    0x8e768ac1e677593 => {
990                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
991                        let mut req = fidl::new_empty!(
992                            TripPointSetTripPointsRequest,
993                            fidl::encoding::DefaultFuchsiaResourceDialect
994                        );
995                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TripPointSetTripPointsRequest>(&header, _body_bytes, handles, &mut req)?;
996                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
997                        Ok(TripPointRequest::SetTripPoints {
998                            descriptors: req.descriptors,
999
1000                            responder: TripPointSetTripPointsResponder {
1001                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1002                                tx_id: header.tx_id,
1003                            },
1004                        })
1005                    }
1006                    0x66b959b54d27ce45 => {
1007                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1008                        let mut req = fidl::new_empty!(
1009                            fidl::encoding::EmptyPayload,
1010                            fidl::encoding::DefaultFuchsiaResourceDialect
1011                        );
1012                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1013                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
1014                        Ok(TripPointRequest::WaitForAnyTripPoint {
1015                            responder: TripPointWaitForAnyTripPointResponder {
1016                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1017                                tx_id: header.tx_id,
1018                            },
1019                        })
1020                    }
1021                    _ if header.tx_id == 0
1022                        && header
1023                            .dynamic_flags()
1024                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1025                    {
1026                        Ok(TripPointRequest::_UnknownMethod {
1027                            ordinal: header.ordinal,
1028                            control_handle: TripPointControlHandle { inner: this.inner.clone() },
1029                            method_type: fidl::MethodType::OneWay,
1030                        })
1031                    }
1032                    _ if header
1033                        .dynamic_flags()
1034                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1035                    {
1036                        this.inner.send_framework_err(
1037                            fidl::encoding::FrameworkErr::UnknownMethod,
1038                            header.tx_id,
1039                            header.ordinal,
1040                            header.dynamic_flags(),
1041                            (bytes, handles),
1042                        )?;
1043                        Ok(TripPointRequest::_UnknownMethod {
1044                            ordinal: header.ordinal,
1045                            control_handle: TripPointControlHandle { inner: this.inner.clone() },
1046                            method_type: fidl::MethodType::TwoWay,
1047                        })
1048                    }
1049                    _ => Err(fidl::Error::UnknownOrdinal {
1050                        ordinal: header.ordinal,
1051                        protocol_name:
1052                            <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1053                    }),
1054                }))
1055            },
1056        )
1057    }
1058}
1059
1060/// The server should enforce that only one client may be connected and
1061/// configuring trip points at any given time.
1062/// If a second client attempts to configure trip points while a client is
1063/// already connected, the server should return ZX_ERR_ALREADY_BOUND to indicate
1064/// that it is busy.
1065#[derive(Debug)]
1066pub enum TripPointRequest {
1067    /// Returns N descriptors. Each descriptor describes one trip point
1068    /// supported by the hardware.
1069    GetTripPointDescriptors { responder: TripPointGetTripPointDescriptorsResponder },
1070    /// Configure 0 or more hardware trip points.
1071    SetTripPoints {
1072        descriptors: Vec<TripPointDescriptor>,
1073        responder: TripPointSetTripPointsResponder,
1074    },
1075    /// Hanging get API that returns when any configured trip point has been
1076    /// crossed.
1077    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
1078    /// all configured trip points are cleared by a call to SetTripPoints.
1079    WaitForAnyTripPoint { responder: TripPointWaitForAnyTripPointResponder },
1080    /// An interaction was received which does not match any known method.
1081    #[non_exhaustive]
1082    _UnknownMethod {
1083        /// Ordinal of the method that was called.
1084        ordinal: u64,
1085        control_handle: TripPointControlHandle,
1086        method_type: fidl::MethodType,
1087    },
1088}
1089
1090impl TripPointRequest {
1091    #[allow(irrefutable_let_patterns)]
1092    pub fn into_get_trip_point_descriptors(
1093        self,
1094    ) -> Option<(TripPointGetTripPointDescriptorsResponder)> {
1095        if let TripPointRequest::GetTripPointDescriptors { responder } = self {
1096            Some((responder))
1097        } else {
1098            None
1099        }
1100    }
1101
1102    #[allow(irrefutable_let_patterns)]
1103    pub fn into_set_trip_points(
1104        self,
1105    ) -> Option<(Vec<TripPointDescriptor>, TripPointSetTripPointsResponder)> {
1106        if let TripPointRequest::SetTripPoints { descriptors, responder } = self {
1107            Some((descriptors, responder))
1108        } else {
1109            None
1110        }
1111    }
1112
1113    #[allow(irrefutable_let_patterns)]
1114    pub fn into_wait_for_any_trip_point(self) -> Option<(TripPointWaitForAnyTripPointResponder)> {
1115        if let TripPointRequest::WaitForAnyTripPoint { responder } = self {
1116            Some((responder))
1117        } else {
1118            None
1119        }
1120    }
1121
1122    /// Name of the method defined in FIDL
1123    pub fn method_name(&self) -> &'static str {
1124        match *self {
1125            TripPointRequest::GetTripPointDescriptors { .. } => "get_trip_point_descriptors",
1126            TripPointRequest::SetTripPoints { .. } => "set_trip_points",
1127            TripPointRequest::WaitForAnyTripPoint { .. } => "wait_for_any_trip_point",
1128            TripPointRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1129                "unknown one-way method"
1130            }
1131            TripPointRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1132                "unknown two-way method"
1133            }
1134        }
1135    }
1136}
1137
1138#[derive(Debug, Clone)]
1139pub struct TripPointControlHandle {
1140    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1141}
1142
1143impl fidl::endpoints::ControlHandle for TripPointControlHandle {
1144    fn shutdown(&self) {
1145        self.inner.shutdown()
1146    }
1147
1148    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1149        self.inner.shutdown_with_epitaph(status)
1150    }
1151
1152    fn is_closed(&self) -> bool {
1153        self.inner.channel().is_closed()
1154    }
1155    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1156        self.inner.channel().on_closed()
1157    }
1158
1159    #[cfg(target_os = "fuchsia")]
1160    fn signal_peer(
1161        &self,
1162        clear_mask: zx::Signals,
1163        set_mask: zx::Signals,
1164    ) -> Result<(), zx_status::Status> {
1165        use fidl::Peered;
1166        self.inner.channel().signal_peer(clear_mask, set_mask)
1167    }
1168}
1169
1170impl TripPointControlHandle {}
1171
1172#[must_use = "FIDL methods require a response to be sent"]
1173#[derive(Debug)]
1174pub struct TripPointGetTripPointDescriptorsResponder {
1175    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1176    tx_id: u32,
1177}
1178
1179/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1180/// if the responder is dropped without sending a response, so that the client
1181/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1182impl std::ops::Drop for TripPointGetTripPointDescriptorsResponder {
1183    fn drop(&mut self) {
1184        self.control_handle.shutdown();
1185        // Safety: drops once, never accessed again
1186        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1187    }
1188}
1189
1190impl fidl::endpoints::Responder for TripPointGetTripPointDescriptorsResponder {
1191    type ControlHandle = TripPointControlHandle;
1192
1193    fn control_handle(&self) -> &TripPointControlHandle {
1194        &self.control_handle
1195    }
1196
1197    fn drop_without_shutdown(mut self) {
1198        // Safety: drops once, never accessed again due to mem::forget
1199        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1200        // Prevent Drop from running (which would shut down the channel)
1201        std::mem::forget(self);
1202    }
1203}
1204
1205impl TripPointGetTripPointDescriptorsResponder {
1206    /// Sends a response to the FIDL transaction.
1207    ///
1208    /// Sets the channel to shutdown if an error occurs.
1209    pub fn send(self, mut result: Result<&[TripPointDescriptor], i32>) -> Result<(), fidl::Error> {
1210        let _result = self.send_raw(result);
1211        if _result.is_err() {
1212            self.control_handle.shutdown();
1213        }
1214        self.drop_without_shutdown();
1215        _result
1216    }
1217
1218    /// Similar to "send" but does not shutdown the channel if an error occurs.
1219    pub fn send_no_shutdown_on_err(
1220        self,
1221        mut result: Result<&[TripPointDescriptor], i32>,
1222    ) -> Result<(), fidl::Error> {
1223        let _result = self.send_raw(result);
1224        self.drop_without_shutdown();
1225        _result
1226    }
1227
1228    fn send_raw(&self, mut result: Result<&[TripPointDescriptor], i32>) -> Result<(), fidl::Error> {
1229        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1230            TripPointGetTripPointDescriptorsResponse,
1231            i32,
1232        >>(
1233            fidl::encoding::FlexibleResult::new(result.map(|descriptors| (descriptors,))),
1234            self.tx_id,
1235            0xbbc73e208bf4875,
1236            fidl::encoding::DynamicFlags::FLEXIBLE,
1237        )
1238    }
1239}
1240
1241#[must_use = "FIDL methods require a response to be sent"]
1242#[derive(Debug)]
1243pub struct TripPointSetTripPointsResponder {
1244    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1245    tx_id: u32,
1246}
1247
1248/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1249/// if the responder is dropped without sending a response, so that the client
1250/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1251impl std::ops::Drop for TripPointSetTripPointsResponder {
1252    fn drop(&mut self) {
1253        self.control_handle.shutdown();
1254        // Safety: drops once, never accessed again
1255        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1256    }
1257}
1258
1259impl fidl::endpoints::Responder for TripPointSetTripPointsResponder {
1260    type ControlHandle = TripPointControlHandle;
1261
1262    fn control_handle(&self) -> &TripPointControlHandle {
1263        &self.control_handle
1264    }
1265
1266    fn drop_without_shutdown(mut self) {
1267        // Safety: drops once, never accessed again due to mem::forget
1268        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1269        // Prevent Drop from running (which would shut down the channel)
1270        std::mem::forget(self);
1271    }
1272}
1273
1274impl TripPointSetTripPointsResponder {
1275    /// Sends a response to the FIDL transaction.
1276    ///
1277    /// Sets the channel to shutdown if an error occurs.
1278    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1279        let _result = self.send_raw(result);
1280        if _result.is_err() {
1281            self.control_handle.shutdown();
1282        }
1283        self.drop_without_shutdown();
1284        _result
1285    }
1286
1287    /// Similar to "send" but does not shutdown the channel if an error occurs.
1288    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1289        let _result = self.send_raw(result);
1290        self.drop_without_shutdown();
1291        _result
1292    }
1293
1294    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1295        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1296            fidl::encoding::EmptyStruct,
1297            i32,
1298        >>(
1299            fidl::encoding::FlexibleResult::new(result),
1300            self.tx_id,
1301            0x8e768ac1e677593,
1302            fidl::encoding::DynamicFlags::FLEXIBLE,
1303        )
1304    }
1305}
1306
1307#[must_use = "FIDL methods require a response to be sent"]
1308#[derive(Debug)]
1309pub struct TripPointWaitForAnyTripPointResponder {
1310    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1311    tx_id: u32,
1312}
1313
1314/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1315/// if the responder is dropped without sending a response, so that the client
1316/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1317impl std::ops::Drop for TripPointWaitForAnyTripPointResponder {
1318    fn drop(&mut self) {
1319        self.control_handle.shutdown();
1320        // Safety: drops once, never accessed again
1321        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1322    }
1323}
1324
1325impl fidl::endpoints::Responder for TripPointWaitForAnyTripPointResponder {
1326    type ControlHandle = TripPointControlHandle;
1327
1328    fn control_handle(&self) -> &TripPointControlHandle {
1329        &self.control_handle
1330    }
1331
1332    fn drop_without_shutdown(mut self) {
1333        // Safety: drops once, never accessed again due to mem::forget
1334        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1335        // Prevent Drop from running (which would shut down the channel)
1336        std::mem::forget(self);
1337    }
1338}
1339
1340impl TripPointWaitForAnyTripPointResponder {
1341    /// Sends a response to the FIDL transaction.
1342    ///
1343    /// Sets the channel to shutdown if an error occurs.
1344    pub fn send(self, mut result: Result<&TripPointResult, i32>) -> Result<(), fidl::Error> {
1345        let _result = self.send_raw(result);
1346        if _result.is_err() {
1347            self.control_handle.shutdown();
1348        }
1349        self.drop_without_shutdown();
1350        _result
1351    }
1352
1353    /// Similar to "send" but does not shutdown the channel if an error occurs.
1354    pub fn send_no_shutdown_on_err(
1355        self,
1356        mut result: Result<&TripPointResult, i32>,
1357    ) -> Result<(), fidl::Error> {
1358        let _result = self.send_raw(result);
1359        self.drop_without_shutdown();
1360        _result
1361    }
1362
1363    fn send_raw(&self, mut result: Result<&TripPointResult, i32>) -> Result<(), fidl::Error> {
1364        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1365            TripPointWaitForAnyTripPointResponse,
1366            i32,
1367        >>(
1368            fidl::encoding::FlexibleResult::new(result.map(|result| (result,))),
1369            self.tx_id,
1370            0x66b959b54d27ce45,
1371            fidl::encoding::DynamicFlags::FLEXIBLE,
1372        )
1373    }
1374}
1375
1376#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1377pub struct DebugServiceMarker;
1378
1379#[cfg(target_os = "fuchsia")]
1380impl fidl::endpoints::ServiceMarker for DebugServiceMarker {
1381    type Proxy = DebugServiceProxy;
1382    type Request = DebugServiceRequest;
1383    const SERVICE_NAME: &'static str = "fuchsia.hardware.trippoint.DebugService";
1384}
1385
1386/// A request for one of the member protocols of DebugService.
1387///
1388#[cfg(target_os = "fuchsia")]
1389pub enum DebugServiceRequest {
1390    Debug(DebugRequestStream),
1391}
1392
1393#[cfg(target_os = "fuchsia")]
1394impl fidl::endpoints::ServiceRequest for DebugServiceRequest {
1395    type Service = DebugServiceMarker;
1396
1397    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1398        match name {
1399            "debug" => Self::Debug(
1400                <DebugRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1401            ),
1402            _ => panic!("no such member protocol name for service DebugService"),
1403        }
1404    }
1405
1406    fn member_names() -> &'static [&'static str] {
1407        &["debug"]
1408    }
1409}
1410#[cfg(target_os = "fuchsia")]
1411pub struct DebugServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1412
1413#[cfg(target_os = "fuchsia")]
1414impl fidl::endpoints::ServiceProxy for DebugServiceProxy {
1415    type Service = DebugServiceMarker;
1416
1417    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1418        Self(opener)
1419    }
1420}
1421
1422#[cfg(target_os = "fuchsia")]
1423impl DebugServiceProxy {
1424    pub fn connect_to_debug(&self) -> Result<DebugProxy, fidl::Error> {
1425        let (proxy, server_end) = fidl::endpoints::create_proxy::<DebugMarker>();
1426        self.connect_channel_to_debug(server_end)?;
1427        Ok(proxy)
1428    }
1429
1430    /// Like `connect_to_debug`, but returns a sync proxy.
1431    /// See [`Self::connect_to_debug`] for more details.
1432    pub fn connect_to_debug_sync(&self) -> Result<DebugSynchronousProxy, fidl::Error> {
1433        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DebugMarker>();
1434        self.connect_channel_to_debug(server_end)?;
1435        Ok(proxy)
1436    }
1437
1438    /// Like `connect_to_debug`, but accepts a server end.
1439    /// See [`Self::connect_to_debug`] for more details.
1440    pub fn connect_channel_to_debug(
1441        &self,
1442        server_end: fidl::endpoints::ServerEnd<DebugMarker>,
1443    ) -> Result<(), fidl::Error> {
1444        self.0.open_member("debug", server_end.into_channel())
1445    }
1446
1447    pub fn instance_name(&self) -> &str {
1448        self.0.instance_name()
1449    }
1450}
1451
1452#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1453pub struct ServiceMarker;
1454
1455#[cfg(target_os = "fuchsia")]
1456impl fidl::endpoints::ServiceMarker for ServiceMarker {
1457    type Proxy = ServiceProxy;
1458    type Request = ServiceRequest;
1459    const SERVICE_NAME: &'static str = "fuchsia.hardware.trippoint.Service";
1460}
1461
1462/// A request for one of the member protocols of Service.
1463///
1464#[cfg(target_os = "fuchsia")]
1465pub enum ServiceRequest {
1466    Trippoint(TripPointRequestStream),
1467}
1468
1469#[cfg(target_os = "fuchsia")]
1470impl fidl::endpoints::ServiceRequest for ServiceRequest {
1471    type Service = ServiceMarker;
1472
1473    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1474        match name {
1475            "trippoint" => Self::Trippoint(
1476                <TripPointRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1477            ),
1478            _ => panic!("no such member protocol name for service Service"),
1479        }
1480    }
1481
1482    fn member_names() -> &'static [&'static str] {
1483        &["trippoint"]
1484    }
1485}
1486#[cfg(target_os = "fuchsia")]
1487pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1488
1489#[cfg(target_os = "fuchsia")]
1490impl fidl::endpoints::ServiceProxy for ServiceProxy {
1491    type Service = ServiceMarker;
1492
1493    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1494        Self(opener)
1495    }
1496}
1497
1498#[cfg(target_os = "fuchsia")]
1499impl ServiceProxy {
1500    pub fn connect_to_trippoint(&self) -> Result<TripPointProxy, fidl::Error> {
1501        let (proxy, server_end) = fidl::endpoints::create_proxy::<TripPointMarker>();
1502        self.connect_channel_to_trippoint(server_end)?;
1503        Ok(proxy)
1504    }
1505
1506    /// Like `connect_to_trippoint`, but returns a sync proxy.
1507    /// See [`Self::connect_to_trippoint`] for more details.
1508    pub fn connect_to_trippoint_sync(&self) -> Result<TripPointSynchronousProxy, fidl::Error> {
1509        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<TripPointMarker>();
1510        self.connect_channel_to_trippoint(server_end)?;
1511        Ok(proxy)
1512    }
1513
1514    /// Like `connect_to_trippoint`, but accepts a server end.
1515    /// See [`Self::connect_to_trippoint`] for more details.
1516    pub fn connect_channel_to_trippoint(
1517        &self,
1518        server_end: fidl::endpoints::ServerEnd<TripPointMarker>,
1519    ) -> Result<(), fidl::Error> {
1520        self.0.open_member("trippoint", server_end.into_channel())
1521    }
1522
1523    pub fn instance_name(&self) -> &str {
1524        self.0.instance_name()
1525    }
1526}
1527
1528mod internal {
1529    use super::*;
1530}