Skip to main content

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        Self { client: fidl::client::sync::Client::new(channel) }
59    }
60
61    pub fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    /// Waits until an event arrives and returns it. It is safe for other
66    /// threads to make concurrent requests while waiting for an event.
67    pub fn wait_for_event(
68        &self,
69        deadline: zx::MonotonicInstant,
70    ) -> Result<DebugEvent, fidl::Error> {
71        DebugEvent::decode(self.client.wait_for_event::<DebugMarker>(deadline)?)
72    }
73
74    /// Trips the trip point with index if it exists. If not, returns ZX_ERR_NOT_FOUND. Note that
75    /// for OneShot trip points, if it is tripped, it gets cleared. Tripping manually with this
76    /// method will have the same effect.
77    pub fn r#trip(
78        &self,
79        mut index: u32,
80        ___deadline: zx::MonotonicInstant,
81    ) -> Result<DebugTripResult, fidl::Error> {
82        let _response = self.client.send_query::<
83            DebugTripRequest,
84            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
85            DebugMarker,
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 DebugControlHandle {
433    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
434        self.inner.shutdown_with_epitaph(status.into())
435    }
436}
437
438impl fidl::endpoints::ControlHandle for DebugControlHandle {
439    fn shutdown(&self) {
440        self.inner.shutdown()
441    }
442
443    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
444        self.inner.shutdown_with_epitaph(status)
445    }
446
447    fn is_closed(&self) -> bool {
448        self.inner.channel().is_closed()
449    }
450    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
451        self.inner.channel().on_closed()
452    }
453
454    #[cfg(target_os = "fuchsia")]
455    fn signal_peer(
456        &self,
457        clear_mask: zx::Signals,
458        set_mask: zx::Signals,
459    ) -> Result<(), zx_status::Status> {
460        use fidl::Peered;
461        self.inner.channel().signal_peer(clear_mask, set_mask)
462    }
463}
464
465impl DebugControlHandle {}
466
467#[must_use = "FIDL methods require a response to be sent"]
468#[derive(Debug)]
469pub struct DebugTripResponder {
470    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
471    tx_id: u32,
472}
473
474/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
475/// if the responder is dropped without sending a response, so that the client
476/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
477impl std::ops::Drop for DebugTripResponder {
478    fn drop(&mut self) {
479        self.control_handle.shutdown();
480        // Safety: drops once, never accessed again
481        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482    }
483}
484
485impl fidl::endpoints::Responder for DebugTripResponder {
486    type ControlHandle = DebugControlHandle;
487
488    fn control_handle(&self) -> &DebugControlHandle {
489        &self.control_handle
490    }
491
492    fn drop_without_shutdown(mut self) {
493        // Safety: drops once, never accessed again due to mem::forget
494        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
495        // Prevent Drop from running (which would shut down the channel)
496        std::mem::forget(self);
497    }
498}
499
500impl DebugTripResponder {
501    /// Sends a response to the FIDL transaction.
502    ///
503    /// Sets the channel to shutdown if an error occurs.
504    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
505        let _result = self.send_raw(result);
506        if _result.is_err() {
507            self.control_handle.shutdown();
508        }
509        self.drop_without_shutdown();
510        _result
511    }
512
513    /// Similar to "send" but does not shutdown the channel if an error occurs.
514    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
515        let _result = self.send_raw(result);
516        self.drop_without_shutdown();
517        _result
518    }
519
520    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
521        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
522            fidl::encoding::EmptyStruct,
523            i32,
524        >>(
525            fidl::encoding::FlexibleResult::new(result),
526            self.tx_id,
527            0x2785e550debdf5a,
528            fidl::encoding::DynamicFlags::FLEXIBLE,
529        )
530    }
531}
532
533#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
534pub struct TripPointMarker;
535
536impl fidl::endpoints::ProtocolMarker for TripPointMarker {
537    type Proxy = TripPointProxy;
538    type RequestStream = TripPointRequestStream;
539    #[cfg(target_os = "fuchsia")]
540    type SynchronousProxy = TripPointSynchronousProxy;
541
542    const DEBUG_NAME: &'static str = "(anonymous) TripPoint";
543}
544pub type TripPointGetTripPointDescriptorsResult = Result<Vec<TripPointDescriptor>, i32>;
545pub type TripPointSetTripPointsResult = Result<(), i32>;
546pub type TripPointWaitForAnyTripPointResult = Result<TripPointResult, i32>;
547
548pub trait TripPointProxyInterface: Send + Sync {
549    type GetTripPointDescriptorsResponseFut: std::future::Future<Output = Result<TripPointGetTripPointDescriptorsResult, fidl::Error>>
550        + Send;
551    fn r#get_trip_point_descriptors(&self) -> Self::GetTripPointDescriptorsResponseFut;
552    type SetTripPointsResponseFut: std::future::Future<Output = Result<TripPointSetTripPointsResult, fidl::Error>>
553        + Send;
554    fn r#set_trip_points(
555        &self,
556        descriptors: &[TripPointDescriptor],
557    ) -> Self::SetTripPointsResponseFut;
558    type WaitForAnyTripPointResponseFut: std::future::Future<Output = Result<TripPointWaitForAnyTripPointResult, fidl::Error>>
559        + Send;
560    fn r#wait_for_any_trip_point(&self) -> Self::WaitForAnyTripPointResponseFut;
561}
562#[derive(Debug)]
563#[cfg(target_os = "fuchsia")]
564pub struct TripPointSynchronousProxy {
565    client: fidl::client::sync::Client,
566}
567
568#[cfg(target_os = "fuchsia")]
569impl fidl::endpoints::SynchronousProxy for TripPointSynchronousProxy {
570    type Proxy = TripPointProxy;
571    type Protocol = TripPointMarker;
572
573    fn from_channel(inner: fidl::Channel) -> Self {
574        Self::new(inner)
575    }
576
577    fn into_channel(self) -> fidl::Channel {
578        self.client.into_channel()
579    }
580
581    fn as_channel(&self) -> &fidl::Channel {
582        self.client.as_channel()
583    }
584}
585
586#[cfg(target_os = "fuchsia")]
587impl TripPointSynchronousProxy {
588    pub fn new(channel: fidl::Channel) -> Self {
589        Self { client: fidl::client::sync::Client::new(channel) }
590    }
591
592    pub fn into_channel(self) -> fidl::Channel {
593        self.client.into_channel()
594    }
595
596    /// Waits until an event arrives and returns it. It is safe for other
597    /// threads to make concurrent requests while waiting for an event.
598    pub fn wait_for_event(
599        &self,
600        deadline: zx::MonotonicInstant,
601    ) -> Result<TripPointEvent, fidl::Error> {
602        TripPointEvent::decode(self.client.wait_for_event::<TripPointMarker>(deadline)?)
603    }
604
605    /// Returns N descriptors. Each descriptor describes one trip point
606    /// supported by the hardware.
607    pub fn r#get_trip_point_descriptors(
608        &self,
609        ___deadline: zx::MonotonicInstant,
610    ) -> Result<TripPointGetTripPointDescriptorsResult, fidl::Error> {
611        let _response = self.client.send_query::<
612            fidl::encoding::EmptyPayload,
613            fidl::encoding::FlexibleResultType<TripPointGetTripPointDescriptorsResponse, i32>,
614            TripPointMarker,
615        >(
616            (),
617            0xbbc73e208bf4875,
618            fidl::encoding::DynamicFlags::FLEXIBLE,
619            ___deadline,
620        )?
621        .into_result::<TripPointMarker>("get_trip_point_descriptors")?;
622        Ok(_response.map(|x| x.descriptors))
623    }
624
625    /// Configure 0 or more hardware trip points.
626    pub fn r#set_trip_points(
627        &self,
628        mut descriptors: &[TripPointDescriptor],
629        ___deadline: zx::MonotonicInstant,
630    ) -> Result<TripPointSetTripPointsResult, fidl::Error> {
631        let _response = self.client.send_query::<
632            TripPointSetTripPointsRequest,
633            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
634            TripPointMarker,
635        >(
636            (descriptors,),
637            0x8e768ac1e677593,
638            fidl::encoding::DynamicFlags::FLEXIBLE,
639            ___deadline,
640        )?
641        .into_result::<TripPointMarker>("set_trip_points")?;
642        Ok(_response.map(|x| x))
643    }
644
645    /// Hanging get API that returns when any configured trip point has been
646    /// crossed.
647    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
648    /// all configured trip points are cleared by a call to SetTripPoints.
649    pub fn r#wait_for_any_trip_point(
650        &self,
651        ___deadline: zx::MonotonicInstant,
652    ) -> Result<TripPointWaitForAnyTripPointResult, fidl::Error> {
653        let _response = self.client.send_query::<
654            fidl::encoding::EmptyPayload,
655            fidl::encoding::FlexibleResultType<TripPointWaitForAnyTripPointResponse, i32>,
656            TripPointMarker,
657        >(
658            (),
659            0x66b959b54d27ce45,
660            fidl::encoding::DynamicFlags::FLEXIBLE,
661            ___deadline,
662        )?
663        .into_result::<TripPointMarker>("wait_for_any_trip_point")?;
664        Ok(_response.map(|x| x.result))
665    }
666}
667
668#[cfg(target_os = "fuchsia")]
669impl From<TripPointSynchronousProxy> for zx::NullableHandle {
670    fn from(value: TripPointSynchronousProxy) -> Self {
671        value.into_channel().into()
672    }
673}
674
675#[cfg(target_os = "fuchsia")]
676impl From<fidl::Channel> for TripPointSynchronousProxy {
677    fn from(value: fidl::Channel) -> Self {
678        Self::new(value)
679    }
680}
681
682#[cfg(target_os = "fuchsia")]
683impl fidl::endpoints::FromClient for TripPointSynchronousProxy {
684    type Protocol = TripPointMarker;
685
686    fn from_client(value: fidl::endpoints::ClientEnd<TripPointMarker>) -> Self {
687        Self::new(value.into_channel())
688    }
689}
690
691#[derive(Debug, Clone)]
692pub struct TripPointProxy {
693    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
694}
695
696impl fidl::endpoints::Proxy for TripPointProxy {
697    type Protocol = TripPointMarker;
698
699    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
700        Self::new(inner)
701    }
702
703    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
704        self.client.into_channel().map_err(|client| Self { client })
705    }
706
707    fn as_channel(&self) -> &::fidl::AsyncChannel {
708        self.client.as_channel()
709    }
710}
711
712impl TripPointProxy {
713    /// Create a new Proxy for fuchsia.hardware.trippoint/TripPoint.
714    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
715        let protocol_name = <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
716        Self { client: fidl::client::Client::new(channel, protocol_name) }
717    }
718
719    /// Get a Stream of events from the remote end of the protocol.
720    ///
721    /// # Panics
722    ///
723    /// Panics if the event stream was already taken.
724    pub fn take_event_stream(&self) -> TripPointEventStream {
725        TripPointEventStream { event_receiver: self.client.take_event_receiver() }
726    }
727
728    /// Returns N descriptors. Each descriptor describes one trip point
729    /// supported by the hardware.
730    pub fn r#get_trip_point_descriptors(
731        &self,
732    ) -> fidl::client::QueryResponseFut<
733        TripPointGetTripPointDescriptorsResult,
734        fidl::encoding::DefaultFuchsiaResourceDialect,
735    > {
736        TripPointProxyInterface::r#get_trip_point_descriptors(self)
737    }
738
739    /// Configure 0 or more hardware trip points.
740    pub fn r#set_trip_points(
741        &self,
742        mut descriptors: &[TripPointDescriptor],
743    ) -> fidl::client::QueryResponseFut<
744        TripPointSetTripPointsResult,
745        fidl::encoding::DefaultFuchsiaResourceDialect,
746    > {
747        TripPointProxyInterface::r#set_trip_points(self, descriptors)
748    }
749
750    /// Hanging get API that returns when any configured trip point has been
751    /// crossed.
752    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
753    /// all configured trip points are cleared by a call to SetTripPoints.
754    pub fn r#wait_for_any_trip_point(
755        &self,
756    ) -> fidl::client::QueryResponseFut<
757        TripPointWaitForAnyTripPointResult,
758        fidl::encoding::DefaultFuchsiaResourceDialect,
759    > {
760        TripPointProxyInterface::r#wait_for_any_trip_point(self)
761    }
762}
763
764impl TripPointProxyInterface for TripPointProxy {
765    type GetTripPointDescriptorsResponseFut = fidl::client::QueryResponseFut<
766        TripPointGetTripPointDescriptorsResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    >;
769    fn r#get_trip_point_descriptors(&self) -> Self::GetTripPointDescriptorsResponseFut {
770        fn _decode(
771            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
772        ) -> Result<TripPointGetTripPointDescriptorsResult, fidl::Error> {
773            let _response = fidl::client::decode_transaction_body::<
774                fidl::encoding::FlexibleResultType<TripPointGetTripPointDescriptorsResponse, i32>,
775                fidl::encoding::DefaultFuchsiaResourceDialect,
776                0xbbc73e208bf4875,
777            >(_buf?)?
778            .into_result::<TripPointMarker>("get_trip_point_descriptors")?;
779            Ok(_response.map(|x| x.descriptors))
780        }
781        self.client.send_query_and_decode::<
782            fidl::encoding::EmptyPayload,
783            TripPointGetTripPointDescriptorsResult,
784        >(
785            (),
786            0xbbc73e208bf4875,
787            fidl::encoding::DynamicFlags::FLEXIBLE,
788            _decode,
789        )
790    }
791
792    type SetTripPointsResponseFut = fidl::client::QueryResponseFut<
793        TripPointSetTripPointsResult,
794        fidl::encoding::DefaultFuchsiaResourceDialect,
795    >;
796    fn r#set_trip_points(
797        &self,
798        mut descriptors: &[TripPointDescriptor],
799    ) -> Self::SetTripPointsResponseFut {
800        fn _decode(
801            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
802        ) -> Result<TripPointSetTripPointsResult, fidl::Error> {
803            let _response = fidl::client::decode_transaction_body::<
804                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
805                fidl::encoding::DefaultFuchsiaResourceDialect,
806                0x8e768ac1e677593,
807            >(_buf?)?
808            .into_result::<TripPointMarker>("set_trip_points")?;
809            Ok(_response.map(|x| x))
810        }
811        self.client
812            .send_query_and_decode::<TripPointSetTripPointsRequest, TripPointSetTripPointsResult>(
813                (descriptors,),
814                0x8e768ac1e677593,
815                fidl::encoding::DynamicFlags::FLEXIBLE,
816                _decode,
817            )
818    }
819
820    type WaitForAnyTripPointResponseFut = fidl::client::QueryResponseFut<
821        TripPointWaitForAnyTripPointResult,
822        fidl::encoding::DefaultFuchsiaResourceDialect,
823    >;
824    fn r#wait_for_any_trip_point(&self) -> Self::WaitForAnyTripPointResponseFut {
825        fn _decode(
826            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
827        ) -> Result<TripPointWaitForAnyTripPointResult, fidl::Error> {
828            let _response = fidl::client::decode_transaction_body::<
829                fidl::encoding::FlexibleResultType<TripPointWaitForAnyTripPointResponse, i32>,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831                0x66b959b54d27ce45,
832            >(_buf?)?
833            .into_result::<TripPointMarker>("wait_for_any_trip_point")?;
834            Ok(_response.map(|x| x.result))
835        }
836        self.client.send_query_and_decode::<
837            fidl::encoding::EmptyPayload,
838            TripPointWaitForAnyTripPointResult,
839        >(
840            (),
841            0x66b959b54d27ce45,
842            fidl::encoding::DynamicFlags::FLEXIBLE,
843            _decode,
844        )
845    }
846}
847
848pub struct TripPointEventStream {
849    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
850}
851
852impl std::marker::Unpin for TripPointEventStream {}
853
854impl futures::stream::FusedStream for TripPointEventStream {
855    fn is_terminated(&self) -> bool {
856        self.event_receiver.is_terminated()
857    }
858}
859
860impl futures::Stream for TripPointEventStream {
861    type Item = Result<TripPointEvent, fidl::Error>;
862
863    fn poll_next(
864        mut self: std::pin::Pin<&mut Self>,
865        cx: &mut std::task::Context<'_>,
866    ) -> std::task::Poll<Option<Self::Item>> {
867        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
868            &mut self.event_receiver,
869            cx
870        )?) {
871            Some(buf) => std::task::Poll::Ready(Some(TripPointEvent::decode(buf))),
872            None => std::task::Poll::Ready(None),
873        }
874    }
875}
876
877#[derive(Debug)]
878pub enum TripPointEvent {
879    #[non_exhaustive]
880    _UnknownEvent {
881        /// Ordinal of the event that was sent.
882        ordinal: u64,
883    },
884}
885
886impl TripPointEvent {
887    /// Decodes a message buffer as a [`TripPointEvent`].
888    fn decode(
889        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
890    ) -> Result<TripPointEvent, fidl::Error> {
891        let (bytes, _handles) = buf.split_mut();
892        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
893        debug_assert_eq!(tx_header.tx_id, 0);
894        match tx_header.ordinal {
895            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
896                Ok(TripPointEvent::_UnknownEvent { ordinal: tx_header.ordinal })
897            }
898            _ => Err(fidl::Error::UnknownOrdinal {
899                ordinal: tx_header.ordinal,
900                protocol_name: <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
901            }),
902        }
903    }
904}
905
906/// A Stream of incoming requests for fuchsia.hardware.trippoint/TripPoint.
907pub struct TripPointRequestStream {
908    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
909    is_terminated: bool,
910}
911
912impl std::marker::Unpin for TripPointRequestStream {}
913
914impl futures::stream::FusedStream for TripPointRequestStream {
915    fn is_terminated(&self) -> bool {
916        self.is_terminated
917    }
918}
919
920impl fidl::endpoints::RequestStream for TripPointRequestStream {
921    type Protocol = TripPointMarker;
922    type ControlHandle = TripPointControlHandle;
923
924    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
925        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
926    }
927
928    fn control_handle(&self) -> Self::ControlHandle {
929        TripPointControlHandle { inner: self.inner.clone() }
930    }
931
932    fn into_inner(
933        self,
934    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
935    {
936        (self.inner, self.is_terminated)
937    }
938
939    fn from_inner(
940        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
941        is_terminated: bool,
942    ) -> Self {
943        Self { inner, is_terminated }
944    }
945}
946
947impl futures::Stream for TripPointRequestStream {
948    type Item = Result<TripPointRequest, fidl::Error>;
949
950    fn poll_next(
951        mut self: std::pin::Pin<&mut Self>,
952        cx: &mut std::task::Context<'_>,
953    ) -> std::task::Poll<Option<Self::Item>> {
954        let this = &mut *self;
955        if this.inner.check_shutdown(cx) {
956            this.is_terminated = true;
957            return std::task::Poll::Ready(None);
958        }
959        if this.is_terminated {
960            panic!("polled TripPointRequestStream after completion");
961        }
962        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
963            |bytes, handles| {
964                match this.inner.channel().read_etc(cx, bytes, handles) {
965                    std::task::Poll::Ready(Ok(())) => {}
966                    std::task::Poll::Pending => return std::task::Poll::Pending,
967                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
968                        this.is_terminated = true;
969                        return std::task::Poll::Ready(None);
970                    }
971                    std::task::Poll::Ready(Err(e)) => {
972                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
973                            e.into(),
974                        ))));
975                    }
976                }
977
978                // A message has been received from the channel
979                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
980
981                std::task::Poll::Ready(Some(match header.ordinal {
982                    0xbbc73e208bf4875 => {
983                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
984                        let mut req = fidl::new_empty!(
985                            fidl::encoding::EmptyPayload,
986                            fidl::encoding::DefaultFuchsiaResourceDialect
987                        );
988                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
989                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
990                        Ok(TripPointRequest::GetTripPointDescriptors {
991                            responder: TripPointGetTripPointDescriptorsResponder {
992                                control_handle: std::mem::ManuallyDrop::new(control_handle),
993                                tx_id: header.tx_id,
994                            },
995                        })
996                    }
997                    0x8e768ac1e677593 => {
998                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
999                        let mut req = fidl::new_empty!(
1000                            TripPointSetTripPointsRequest,
1001                            fidl::encoding::DefaultFuchsiaResourceDialect
1002                        );
1003                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TripPointSetTripPointsRequest>(&header, _body_bytes, handles, &mut req)?;
1004                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
1005                        Ok(TripPointRequest::SetTripPoints {
1006                            descriptors: req.descriptors,
1007
1008                            responder: TripPointSetTripPointsResponder {
1009                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1010                                tx_id: header.tx_id,
1011                            },
1012                        })
1013                    }
1014                    0x66b959b54d27ce45 => {
1015                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1016                        let mut req = fidl::new_empty!(
1017                            fidl::encoding::EmptyPayload,
1018                            fidl::encoding::DefaultFuchsiaResourceDialect
1019                        );
1020                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1021                        let control_handle = TripPointControlHandle { inner: this.inner.clone() };
1022                        Ok(TripPointRequest::WaitForAnyTripPoint {
1023                            responder: TripPointWaitForAnyTripPointResponder {
1024                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1025                                tx_id: header.tx_id,
1026                            },
1027                        })
1028                    }
1029                    _ if header.tx_id == 0
1030                        && header
1031                            .dynamic_flags()
1032                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1033                    {
1034                        Ok(TripPointRequest::_UnknownMethod {
1035                            ordinal: header.ordinal,
1036                            control_handle: TripPointControlHandle { inner: this.inner.clone() },
1037                            method_type: fidl::MethodType::OneWay,
1038                        })
1039                    }
1040                    _ if header
1041                        .dynamic_flags()
1042                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1043                    {
1044                        this.inner.send_framework_err(
1045                            fidl::encoding::FrameworkErr::UnknownMethod,
1046                            header.tx_id,
1047                            header.ordinal,
1048                            header.dynamic_flags(),
1049                            (bytes, handles),
1050                        )?;
1051                        Ok(TripPointRequest::_UnknownMethod {
1052                            ordinal: header.ordinal,
1053                            control_handle: TripPointControlHandle { inner: this.inner.clone() },
1054                            method_type: fidl::MethodType::TwoWay,
1055                        })
1056                    }
1057                    _ => Err(fidl::Error::UnknownOrdinal {
1058                        ordinal: header.ordinal,
1059                        protocol_name:
1060                            <TripPointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1061                    }),
1062                }))
1063            },
1064        )
1065    }
1066}
1067
1068/// The server should enforce that only one client may be connected and
1069/// configuring trip points at any given time.
1070/// If a second client attempts to configure trip points while a client is
1071/// already connected, the server should return ZX_ERR_ALREADY_BOUND to indicate
1072/// that it is busy.
1073#[derive(Debug)]
1074pub enum TripPointRequest {
1075    /// Returns N descriptors. Each descriptor describes one trip point
1076    /// supported by the hardware.
1077    GetTripPointDescriptors { responder: TripPointGetTripPointDescriptorsResponder },
1078    /// Configure 0 or more hardware trip points.
1079    SetTripPoints {
1080        descriptors: Vec<TripPointDescriptor>,
1081        responder: TripPointSetTripPointsResponder,
1082    },
1083    /// Hanging get API that returns when any configured trip point has been
1084    /// crossed.
1085    /// Returns ZX_ERR_BAD_STATE if no trip points have been configured or if
1086    /// all configured trip points are cleared by a call to SetTripPoints.
1087    WaitForAnyTripPoint { responder: TripPointWaitForAnyTripPointResponder },
1088    /// An interaction was received which does not match any known method.
1089    #[non_exhaustive]
1090    _UnknownMethod {
1091        /// Ordinal of the method that was called.
1092        ordinal: u64,
1093        control_handle: TripPointControlHandle,
1094        method_type: fidl::MethodType,
1095    },
1096}
1097
1098impl TripPointRequest {
1099    #[allow(irrefutable_let_patterns)]
1100    pub fn into_get_trip_point_descriptors(
1101        self,
1102    ) -> Option<(TripPointGetTripPointDescriptorsResponder)> {
1103        if let TripPointRequest::GetTripPointDescriptors { responder } = self {
1104            Some((responder))
1105        } else {
1106            None
1107        }
1108    }
1109
1110    #[allow(irrefutable_let_patterns)]
1111    pub fn into_set_trip_points(
1112        self,
1113    ) -> Option<(Vec<TripPointDescriptor>, TripPointSetTripPointsResponder)> {
1114        if let TripPointRequest::SetTripPoints { descriptors, responder } = self {
1115            Some((descriptors, responder))
1116        } else {
1117            None
1118        }
1119    }
1120
1121    #[allow(irrefutable_let_patterns)]
1122    pub fn into_wait_for_any_trip_point(self) -> Option<(TripPointWaitForAnyTripPointResponder)> {
1123        if let TripPointRequest::WaitForAnyTripPoint { responder } = self {
1124            Some((responder))
1125        } else {
1126            None
1127        }
1128    }
1129
1130    /// Name of the method defined in FIDL
1131    pub fn method_name(&self) -> &'static str {
1132        match *self {
1133            TripPointRequest::GetTripPointDescriptors { .. } => "get_trip_point_descriptors",
1134            TripPointRequest::SetTripPoints { .. } => "set_trip_points",
1135            TripPointRequest::WaitForAnyTripPoint { .. } => "wait_for_any_trip_point",
1136            TripPointRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1137                "unknown one-way method"
1138            }
1139            TripPointRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1140                "unknown two-way method"
1141            }
1142        }
1143    }
1144}
1145
1146#[derive(Debug, Clone)]
1147pub struct TripPointControlHandle {
1148    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1149}
1150
1151impl TripPointControlHandle {
1152    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1153        self.inner.shutdown_with_epitaph(status.into())
1154    }
1155}
1156
1157impl fidl::endpoints::ControlHandle for TripPointControlHandle {
1158    fn shutdown(&self) {
1159        self.inner.shutdown()
1160    }
1161
1162    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1163        self.inner.shutdown_with_epitaph(status)
1164    }
1165
1166    fn is_closed(&self) -> bool {
1167        self.inner.channel().is_closed()
1168    }
1169    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1170        self.inner.channel().on_closed()
1171    }
1172
1173    #[cfg(target_os = "fuchsia")]
1174    fn signal_peer(
1175        &self,
1176        clear_mask: zx::Signals,
1177        set_mask: zx::Signals,
1178    ) -> Result<(), zx_status::Status> {
1179        use fidl::Peered;
1180        self.inner.channel().signal_peer(clear_mask, set_mask)
1181    }
1182}
1183
1184impl TripPointControlHandle {}
1185
1186#[must_use = "FIDL methods require a response to be sent"]
1187#[derive(Debug)]
1188pub struct TripPointGetTripPointDescriptorsResponder {
1189    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1190    tx_id: u32,
1191}
1192
1193/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1194/// if the responder is dropped without sending a response, so that the client
1195/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1196impl std::ops::Drop for TripPointGetTripPointDescriptorsResponder {
1197    fn drop(&mut self) {
1198        self.control_handle.shutdown();
1199        // Safety: drops once, never accessed again
1200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1201    }
1202}
1203
1204impl fidl::endpoints::Responder for TripPointGetTripPointDescriptorsResponder {
1205    type ControlHandle = TripPointControlHandle;
1206
1207    fn control_handle(&self) -> &TripPointControlHandle {
1208        &self.control_handle
1209    }
1210
1211    fn drop_without_shutdown(mut self) {
1212        // Safety: drops once, never accessed again due to mem::forget
1213        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1214        // Prevent Drop from running (which would shut down the channel)
1215        std::mem::forget(self);
1216    }
1217}
1218
1219impl TripPointGetTripPointDescriptorsResponder {
1220    /// Sends a response to the FIDL transaction.
1221    ///
1222    /// Sets the channel to shutdown if an error occurs.
1223    pub fn send(self, mut result: Result<&[TripPointDescriptor], i32>) -> Result<(), fidl::Error> {
1224        let _result = self.send_raw(result);
1225        if _result.is_err() {
1226            self.control_handle.shutdown();
1227        }
1228        self.drop_without_shutdown();
1229        _result
1230    }
1231
1232    /// Similar to "send" but does not shutdown the channel if an error occurs.
1233    pub fn send_no_shutdown_on_err(
1234        self,
1235        mut result: Result<&[TripPointDescriptor], i32>,
1236    ) -> Result<(), fidl::Error> {
1237        let _result = self.send_raw(result);
1238        self.drop_without_shutdown();
1239        _result
1240    }
1241
1242    fn send_raw(&self, mut result: Result<&[TripPointDescriptor], i32>) -> Result<(), fidl::Error> {
1243        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1244            TripPointGetTripPointDescriptorsResponse,
1245            i32,
1246        >>(
1247            fidl::encoding::FlexibleResult::new(result.map(|descriptors| (descriptors,))),
1248            self.tx_id,
1249            0xbbc73e208bf4875,
1250            fidl::encoding::DynamicFlags::FLEXIBLE,
1251        )
1252    }
1253}
1254
1255#[must_use = "FIDL methods require a response to be sent"]
1256#[derive(Debug)]
1257pub struct TripPointSetTripPointsResponder {
1258    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1259    tx_id: u32,
1260}
1261
1262/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1263/// if the responder is dropped without sending a response, so that the client
1264/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1265impl std::ops::Drop for TripPointSetTripPointsResponder {
1266    fn drop(&mut self) {
1267        self.control_handle.shutdown();
1268        // Safety: drops once, never accessed again
1269        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1270    }
1271}
1272
1273impl fidl::endpoints::Responder for TripPointSetTripPointsResponder {
1274    type ControlHandle = TripPointControlHandle;
1275
1276    fn control_handle(&self) -> &TripPointControlHandle {
1277        &self.control_handle
1278    }
1279
1280    fn drop_without_shutdown(mut self) {
1281        // Safety: drops once, never accessed again due to mem::forget
1282        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1283        // Prevent Drop from running (which would shut down the channel)
1284        std::mem::forget(self);
1285    }
1286}
1287
1288impl TripPointSetTripPointsResponder {
1289    /// Sends a response to the FIDL transaction.
1290    ///
1291    /// Sets the channel to shutdown if an error occurs.
1292    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1293        let _result = self.send_raw(result);
1294        if _result.is_err() {
1295            self.control_handle.shutdown();
1296        }
1297        self.drop_without_shutdown();
1298        _result
1299    }
1300
1301    /// Similar to "send" but does not shutdown the channel if an error occurs.
1302    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1303        let _result = self.send_raw(result);
1304        self.drop_without_shutdown();
1305        _result
1306    }
1307
1308    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1309        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1310            fidl::encoding::EmptyStruct,
1311            i32,
1312        >>(
1313            fidl::encoding::FlexibleResult::new(result),
1314            self.tx_id,
1315            0x8e768ac1e677593,
1316            fidl::encoding::DynamicFlags::FLEXIBLE,
1317        )
1318    }
1319}
1320
1321#[must_use = "FIDL methods require a response to be sent"]
1322#[derive(Debug)]
1323pub struct TripPointWaitForAnyTripPointResponder {
1324    control_handle: std::mem::ManuallyDrop<TripPointControlHandle>,
1325    tx_id: u32,
1326}
1327
1328/// Set the the channel to be shutdown (see [`TripPointControlHandle::shutdown`])
1329/// if the responder is dropped without sending a response, so that the client
1330/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1331impl std::ops::Drop for TripPointWaitForAnyTripPointResponder {
1332    fn drop(&mut self) {
1333        self.control_handle.shutdown();
1334        // Safety: drops once, never accessed again
1335        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1336    }
1337}
1338
1339impl fidl::endpoints::Responder for TripPointWaitForAnyTripPointResponder {
1340    type ControlHandle = TripPointControlHandle;
1341
1342    fn control_handle(&self) -> &TripPointControlHandle {
1343        &self.control_handle
1344    }
1345
1346    fn drop_without_shutdown(mut self) {
1347        // Safety: drops once, never accessed again due to mem::forget
1348        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1349        // Prevent Drop from running (which would shut down the channel)
1350        std::mem::forget(self);
1351    }
1352}
1353
1354impl TripPointWaitForAnyTripPointResponder {
1355    /// Sends a response to the FIDL transaction.
1356    ///
1357    /// Sets the channel to shutdown if an error occurs.
1358    pub fn send(self, mut result: Result<&TripPointResult, i32>) -> Result<(), fidl::Error> {
1359        let _result = self.send_raw(result);
1360        if _result.is_err() {
1361            self.control_handle.shutdown();
1362        }
1363        self.drop_without_shutdown();
1364        _result
1365    }
1366
1367    /// Similar to "send" but does not shutdown the channel if an error occurs.
1368    pub fn send_no_shutdown_on_err(
1369        self,
1370        mut result: Result<&TripPointResult, i32>,
1371    ) -> Result<(), fidl::Error> {
1372        let _result = self.send_raw(result);
1373        self.drop_without_shutdown();
1374        _result
1375    }
1376
1377    fn send_raw(&self, mut result: Result<&TripPointResult, i32>) -> Result<(), fidl::Error> {
1378        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1379            TripPointWaitForAnyTripPointResponse,
1380            i32,
1381        >>(
1382            fidl::encoding::FlexibleResult::new(result.map(|result| (result,))),
1383            self.tx_id,
1384            0x66b959b54d27ce45,
1385            fidl::encoding::DynamicFlags::FLEXIBLE,
1386        )
1387    }
1388}
1389
1390#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1391pub struct DebugServiceMarker;
1392
1393#[cfg(target_os = "fuchsia")]
1394impl fidl::endpoints::ServiceMarker for DebugServiceMarker {
1395    type Proxy = DebugServiceProxy;
1396    type Request = DebugServiceRequest;
1397    const SERVICE_NAME: &'static str = "fuchsia.hardware.trippoint.DebugService";
1398}
1399
1400/// A request for one of the member protocols of DebugService.
1401///
1402#[cfg(target_os = "fuchsia")]
1403pub enum DebugServiceRequest {
1404    Debug(DebugRequestStream),
1405}
1406
1407#[cfg(target_os = "fuchsia")]
1408impl fidl::endpoints::ServiceRequest for DebugServiceRequest {
1409    type Service = DebugServiceMarker;
1410
1411    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1412        match name {
1413            "debug" => Self::Debug(
1414                <DebugRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1415            ),
1416            _ => panic!("no such member protocol name for service DebugService"),
1417        }
1418    }
1419
1420    fn member_names() -> &'static [&'static str] {
1421        &["debug"]
1422    }
1423}
1424#[cfg(target_os = "fuchsia")]
1425pub struct DebugServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1426
1427#[cfg(target_os = "fuchsia")]
1428impl fidl::endpoints::ServiceProxy for DebugServiceProxy {
1429    type Service = DebugServiceMarker;
1430
1431    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1432        Self(opener)
1433    }
1434}
1435
1436#[cfg(target_os = "fuchsia")]
1437impl DebugServiceProxy {
1438    pub fn connect_to_debug(&self) -> Result<DebugProxy, fidl::Error> {
1439        let (proxy, server_end) = fidl::endpoints::create_proxy::<DebugMarker>();
1440        self.connect_channel_to_debug(server_end)?;
1441        Ok(proxy)
1442    }
1443
1444    /// Like `connect_to_debug`, but returns a sync proxy.
1445    /// See [`Self::connect_to_debug`] for more details.
1446    pub fn connect_to_debug_sync(&self) -> Result<DebugSynchronousProxy, fidl::Error> {
1447        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DebugMarker>();
1448        self.connect_channel_to_debug(server_end)?;
1449        Ok(proxy)
1450    }
1451
1452    /// Like `connect_to_debug`, but accepts a server end.
1453    /// See [`Self::connect_to_debug`] for more details.
1454    pub fn connect_channel_to_debug(
1455        &self,
1456        server_end: fidl::endpoints::ServerEnd<DebugMarker>,
1457    ) -> Result<(), fidl::Error> {
1458        self.0.open_member("debug", server_end.into_channel())
1459    }
1460
1461    pub fn instance_name(&self) -> &str {
1462        self.0.instance_name()
1463    }
1464}
1465
1466#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1467pub struct ServiceMarker;
1468
1469#[cfg(target_os = "fuchsia")]
1470impl fidl::endpoints::ServiceMarker for ServiceMarker {
1471    type Proxy = ServiceProxy;
1472    type Request = ServiceRequest;
1473    const SERVICE_NAME: &'static str = "fuchsia.hardware.trippoint.Service";
1474}
1475
1476/// A request for one of the member protocols of Service.
1477///
1478#[cfg(target_os = "fuchsia")]
1479pub enum ServiceRequest {
1480    Trippoint(TripPointRequestStream),
1481}
1482
1483#[cfg(target_os = "fuchsia")]
1484impl fidl::endpoints::ServiceRequest for ServiceRequest {
1485    type Service = ServiceMarker;
1486
1487    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1488        match name {
1489            "trippoint" => Self::Trippoint(
1490                <TripPointRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1491            ),
1492            _ => panic!("no such member protocol name for service Service"),
1493        }
1494    }
1495
1496    fn member_names() -> &'static [&'static str] {
1497        &["trippoint"]
1498    }
1499}
1500#[cfg(target_os = "fuchsia")]
1501pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1502
1503#[cfg(target_os = "fuchsia")]
1504impl fidl::endpoints::ServiceProxy for ServiceProxy {
1505    type Service = ServiceMarker;
1506
1507    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1508        Self(opener)
1509    }
1510}
1511
1512#[cfg(target_os = "fuchsia")]
1513impl ServiceProxy {
1514    pub fn connect_to_trippoint(&self) -> Result<TripPointProxy, fidl::Error> {
1515        let (proxy, server_end) = fidl::endpoints::create_proxy::<TripPointMarker>();
1516        self.connect_channel_to_trippoint(server_end)?;
1517        Ok(proxy)
1518    }
1519
1520    /// Like `connect_to_trippoint`, but returns a sync proxy.
1521    /// See [`Self::connect_to_trippoint`] for more details.
1522    pub fn connect_to_trippoint_sync(&self) -> Result<TripPointSynchronousProxy, fidl::Error> {
1523        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<TripPointMarker>();
1524        self.connect_channel_to_trippoint(server_end)?;
1525        Ok(proxy)
1526    }
1527
1528    /// Like `connect_to_trippoint`, but accepts a server end.
1529    /// See [`Self::connect_to_trippoint`] for more details.
1530    pub fn connect_channel_to_trippoint(
1531        &self,
1532        server_end: fidl::endpoints::ServerEnd<TripPointMarker>,
1533    ) -> Result<(), fidl::Error> {
1534        self.0.open_member("trippoint", server_end.into_channel())
1535    }
1536
1537    pub fn instance_name(&self) -> &str {
1538        self.0.instance_name()
1539    }
1540}
1541
1542mod internal {
1543    use super::*;
1544}