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