fidl_fuchsia_samplertestcontroller/
fidl_fuchsia_samplertestcontroller.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_samplertestcontroller__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct SamplerTestControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for SamplerTestControllerMarker {
18    type Proxy = SamplerTestControllerProxy;
19    type RequestStream = SamplerTestControllerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = SamplerTestControllerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.samplertestcontroller.SamplerTestController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for SamplerTestControllerMarker {}
26pub type SamplerTestControllerWaitForSampleResult = Result<(), SamplingError>;
27
28pub trait SamplerTestControllerProxyInterface: Send + Sync {
29    type IncrementIntResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
30    fn r#increment_int(&self, property_id: u16) -> Self::IncrementIntResponseFut;
31    type SetOptionalResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
32    fn r#set_optional(&self, value: i64) -> Self::SetOptionalResponseFut;
33    type RemoveOptionalResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
34    fn r#remove_optional(&self) -> Self::RemoveOptionalResponseFut;
35    type WaitForSampleResponseFut: std::future::Future<Output = Result<SamplerTestControllerWaitForSampleResult, fidl::Error>>
36        + Send;
37    fn r#wait_for_sample(&self) -> Self::WaitForSampleResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct SamplerTestControllerSynchronousProxy {
42    client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for SamplerTestControllerSynchronousProxy {
47    type Proxy = SamplerTestControllerProxy;
48    type Protocol = SamplerTestControllerMarker;
49
50    fn from_channel(inner: fidl::Channel) -> Self {
51        Self::new(inner)
52    }
53
54    fn into_channel(self) -> fidl::Channel {
55        self.client.into_channel()
56    }
57
58    fn as_channel(&self) -> &fidl::Channel {
59        self.client.as_channel()
60    }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl SamplerTestControllerSynchronousProxy {
65    pub fn new(channel: fidl::Channel) -> Self {
66        let protocol_name =
67            <SamplerTestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
68        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
69    }
70
71    pub fn into_channel(self) -> fidl::Channel {
72        self.client.into_channel()
73    }
74
75    /// Waits until an event arrives and returns it. It is safe for other
76    /// threads to make concurrent requests while waiting for an event.
77    pub fn wait_for_event(
78        &self,
79        deadline: zx::MonotonicInstant,
80    ) -> Result<SamplerTestControllerEvent, fidl::Error> {
81        SamplerTestControllerEvent::decode(self.client.wait_for_event(deadline)?)
82    }
83
84    pub fn r#increment_int(
85        &self,
86        mut property_id: u16,
87        ___deadline: zx::MonotonicInstant,
88    ) -> Result<(), fidl::Error> {
89        let _response = self
90            .client
91            .send_query::<SamplerTestControllerIncrementIntRequest, fidl::encoding::EmptyPayload>(
92                (property_id,),
93                0x38330ef9d7233f6e,
94                fidl::encoding::DynamicFlags::empty(),
95                ___deadline,
96            )?;
97        Ok(_response)
98    }
99
100    pub fn r#set_optional(
101        &self,
102        mut value: i64,
103        ___deadline: zx::MonotonicInstant,
104    ) -> Result<(), fidl::Error> {
105        let _response = self
106            .client
107            .send_query::<SamplerTestControllerSetOptionalRequest, fidl::encoding::EmptyPayload>(
108                (value,),
109                0x41f2f914c43d92d1,
110                fidl::encoding::DynamicFlags::empty(),
111                ___deadline,
112            )?;
113        Ok(_response)
114    }
115
116    pub fn r#remove_optional(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
117        let _response =
118            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
119                (),
120                0x3d2273c482b7014c,
121                fidl::encoding::DynamicFlags::empty(),
122                ___deadline,
123            )?;
124        Ok(_response)
125    }
126
127    pub fn r#wait_for_sample(
128        &self,
129        ___deadline: zx::MonotonicInstant,
130    ) -> Result<SamplerTestControllerWaitForSampleResult, fidl::Error> {
131        let _response = self.client.send_query::<
132            fidl::encoding::EmptyPayload,
133            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SamplingError>,
134        >(
135            (),
136            0x6edb38cecf8d027b,
137            fidl::encoding::DynamicFlags::empty(),
138            ___deadline,
139        )?;
140        Ok(_response.map(|x| x))
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl From<SamplerTestControllerSynchronousProxy> for zx::NullableHandle {
146    fn from(value: SamplerTestControllerSynchronousProxy) -> Self {
147        value.into_channel().into()
148    }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl From<fidl::Channel> for SamplerTestControllerSynchronousProxy {
153    fn from(value: fidl::Channel) -> Self {
154        Self::new(value)
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl fidl::endpoints::FromClient for SamplerTestControllerSynchronousProxy {
160    type Protocol = SamplerTestControllerMarker;
161
162    fn from_client(value: fidl::endpoints::ClientEnd<SamplerTestControllerMarker>) -> Self {
163        Self::new(value.into_channel())
164    }
165}
166
167#[derive(Debug, Clone)]
168pub struct SamplerTestControllerProxy {
169    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
170}
171
172impl fidl::endpoints::Proxy for SamplerTestControllerProxy {
173    type Protocol = SamplerTestControllerMarker;
174
175    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
176        Self::new(inner)
177    }
178
179    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
180        self.client.into_channel().map_err(|client| Self { client })
181    }
182
183    fn as_channel(&self) -> &::fidl::AsyncChannel {
184        self.client.as_channel()
185    }
186}
187
188impl SamplerTestControllerProxy {
189    /// Create a new Proxy for fuchsia.samplertestcontroller/SamplerTestController.
190    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
191        let protocol_name =
192            <SamplerTestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
193        Self { client: fidl::client::Client::new(channel, protocol_name) }
194    }
195
196    /// Get a Stream of events from the remote end of the protocol.
197    ///
198    /// # Panics
199    ///
200    /// Panics if the event stream was already taken.
201    pub fn take_event_stream(&self) -> SamplerTestControllerEventStream {
202        SamplerTestControllerEventStream { event_receiver: self.client.take_event_receiver() }
203    }
204
205    pub fn r#increment_int(
206        &self,
207        mut property_id: u16,
208    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
209        SamplerTestControllerProxyInterface::r#increment_int(self, property_id)
210    }
211
212    pub fn r#set_optional(
213        &self,
214        mut value: i64,
215    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
216        SamplerTestControllerProxyInterface::r#set_optional(self, value)
217    }
218
219    pub fn r#remove_optional(
220        &self,
221    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
222        SamplerTestControllerProxyInterface::r#remove_optional(self)
223    }
224
225    pub fn r#wait_for_sample(
226        &self,
227    ) -> fidl::client::QueryResponseFut<
228        SamplerTestControllerWaitForSampleResult,
229        fidl::encoding::DefaultFuchsiaResourceDialect,
230    > {
231        SamplerTestControllerProxyInterface::r#wait_for_sample(self)
232    }
233}
234
235impl SamplerTestControllerProxyInterface for SamplerTestControllerProxy {
236    type IncrementIntResponseFut =
237        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
238    fn r#increment_int(&self, mut property_id: u16) -> Self::IncrementIntResponseFut {
239        fn _decode(
240            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
241        ) -> Result<(), fidl::Error> {
242            let _response = fidl::client::decode_transaction_body::<
243                fidl::encoding::EmptyPayload,
244                fidl::encoding::DefaultFuchsiaResourceDialect,
245                0x38330ef9d7233f6e,
246            >(_buf?)?;
247            Ok(_response)
248        }
249        self.client.send_query_and_decode::<SamplerTestControllerIncrementIntRequest, ()>(
250            (property_id,),
251            0x38330ef9d7233f6e,
252            fidl::encoding::DynamicFlags::empty(),
253            _decode,
254        )
255    }
256
257    type SetOptionalResponseFut =
258        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
259    fn r#set_optional(&self, mut value: i64) -> Self::SetOptionalResponseFut {
260        fn _decode(
261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262        ) -> Result<(), fidl::Error> {
263            let _response = fidl::client::decode_transaction_body::<
264                fidl::encoding::EmptyPayload,
265                fidl::encoding::DefaultFuchsiaResourceDialect,
266                0x41f2f914c43d92d1,
267            >(_buf?)?;
268            Ok(_response)
269        }
270        self.client.send_query_and_decode::<SamplerTestControllerSetOptionalRequest, ()>(
271            (value,),
272            0x41f2f914c43d92d1,
273            fidl::encoding::DynamicFlags::empty(),
274            _decode,
275        )
276    }
277
278    type RemoveOptionalResponseFut =
279        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
280    fn r#remove_optional(&self) -> Self::RemoveOptionalResponseFut {
281        fn _decode(
282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
283        ) -> Result<(), fidl::Error> {
284            let _response = fidl::client::decode_transaction_body::<
285                fidl::encoding::EmptyPayload,
286                fidl::encoding::DefaultFuchsiaResourceDialect,
287                0x3d2273c482b7014c,
288            >(_buf?)?;
289            Ok(_response)
290        }
291        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
292            (),
293            0x3d2273c482b7014c,
294            fidl::encoding::DynamicFlags::empty(),
295            _decode,
296        )
297    }
298
299    type WaitForSampleResponseFut = fidl::client::QueryResponseFut<
300        SamplerTestControllerWaitForSampleResult,
301        fidl::encoding::DefaultFuchsiaResourceDialect,
302    >;
303    fn r#wait_for_sample(&self) -> Self::WaitForSampleResponseFut {
304        fn _decode(
305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
306        ) -> Result<SamplerTestControllerWaitForSampleResult, fidl::Error> {
307            let _response = fidl::client::decode_transaction_body::<
308                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SamplingError>,
309                fidl::encoding::DefaultFuchsiaResourceDialect,
310                0x6edb38cecf8d027b,
311            >(_buf?)?;
312            Ok(_response.map(|x| x))
313        }
314        self.client.send_query_and_decode::<
315            fidl::encoding::EmptyPayload,
316            SamplerTestControllerWaitForSampleResult,
317        >(
318            (),
319            0x6edb38cecf8d027b,
320            fidl::encoding::DynamicFlags::empty(),
321            _decode,
322        )
323    }
324}
325
326pub struct SamplerTestControllerEventStream {
327    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
328}
329
330impl std::marker::Unpin for SamplerTestControllerEventStream {}
331
332impl futures::stream::FusedStream for SamplerTestControllerEventStream {
333    fn is_terminated(&self) -> bool {
334        self.event_receiver.is_terminated()
335    }
336}
337
338impl futures::Stream for SamplerTestControllerEventStream {
339    type Item = Result<SamplerTestControllerEvent, fidl::Error>;
340
341    fn poll_next(
342        mut self: std::pin::Pin<&mut Self>,
343        cx: &mut std::task::Context<'_>,
344    ) -> std::task::Poll<Option<Self::Item>> {
345        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
346            &mut self.event_receiver,
347            cx
348        )?) {
349            Some(buf) => std::task::Poll::Ready(Some(SamplerTestControllerEvent::decode(buf))),
350            None => std::task::Poll::Ready(None),
351        }
352    }
353}
354
355#[derive(Debug)]
356pub enum SamplerTestControllerEvent {}
357
358impl SamplerTestControllerEvent {
359    /// Decodes a message buffer as a [`SamplerTestControllerEvent`].
360    fn decode(
361        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
362    ) -> Result<SamplerTestControllerEvent, fidl::Error> {
363        let (bytes, _handles) = buf.split_mut();
364        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
365        debug_assert_eq!(tx_header.tx_id, 0);
366        match tx_header.ordinal {
367            _ => Err(fidl::Error::UnknownOrdinal {
368                ordinal: tx_header.ordinal,
369                protocol_name:
370                    <SamplerTestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
371            }),
372        }
373    }
374}
375
376/// A Stream of incoming requests for fuchsia.samplertestcontroller/SamplerTestController.
377pub struct SamplerTestControllerRequestStream {
378    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
379    is_terminated: bool,
380}
381
382impl std::marker::Unpin for SamplerTestControllerRequestStream {}
383
384impl futures::stream::FusedStream for SamplerTestControllerRequestStream {
385    fn is_terminated(&self) -> bool {
386        self.is_terminated
387    }
388}
389
390impl fidl::endpoints::RequestStream for SamplerTestControllerRequestStream {
391    type Protocol = SamplerTestControllerMarker;
392    type ControlHandle = SamplerTestControllerControlHandle;
393
394    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
395        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
396    }
397
398    fn control_handle(&self) -> Self::ControlHandle {
399        SamplerTestControllerControlHandle { inner: self.inner.clone() }
400    }
401
402    fn into_inner(
403        self,
404    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
405    {
406        (self.inner, self.is_terminated)
407    }
408
409    fn from_inner(
410        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
411        is_terminated: bool,
412    ) -> Self {
413        Self { inner, is_terminated }
414    }
415}
416
417impl futures::Stream for SamplerTestControllerRequestStream {
418    type Item = Result<SamplerTestControllerRequest, fidl::Error>;
419
420    fn poll_next(
421        mut self: std::pin::Pin<&mut Self>,
422        cx: &mut std::task::Context<'_>,
423    ) -> std::task::Poll<Option<Self::Item>> {
424        let this = &mut *self;
425        if this.inner.check_shutdown(cx) {
426            this.is_terminated = true;
427            return std::task::Poll::Ready(None);
428        }
429        if this.is_terminated {
430            panic!("polled SamplerTestControllerRequestStream after completion");
431        }
432        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
433            |bytes, handles| {
434                match this.inner.channel().read_etc(cx, bytes, handles) {
435                    std::task::Poll::Ready(Ok(())) => {}
436                    std::task::Poll::Pending => return std::task::Poll::Pending,
437                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
438                        this.is_terminated = true;
439                        return std::task::Poll::Ready(None);
440                    }
441                    std::task::Poll::Ready(Err(e)) => {
442                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
443                            e.into(),
444                        ))));
445                    }
446                }
447
448                // A message has been received from the channel
449                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
450
451                std::task::Poll::Ready(Some(match header.ordinal {
452                0x38330ef9d7233f6e => {
453                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
454                    let mut req = fidl::new_empty!(SamplerTestControllerIncrementIntRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
455                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SamplerTestControllerIncrementIntRequest>(&header, _body_bytes, handles, &mut req)?;
456                    let control_handle = SamplerTestControllerControlHandle {
457                        inner: this.inner.clone(),
458                    };
459                    Ok(SamplerTestControllerRequest::IncrementInt {property_id: req.property_id,
460
461                        responder: SamplerTestControllerIncrementIntResponder {
462                            control_handle: std::mem::ManuallyDrop::new(control_handle),
463                            tx_id: header.tx_id,
464                        },
465                    })
466                }
467                0x41f2f914c43d92d1 => {
468                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
469                    let mut req = fidl::new_empty!(SamplerTestControllerSetOptionalRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
470                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SamplerTestControllerSetOptionalRequest>(&header, _body_bytes, handles, &mut req)?;
471                    let control_handle = SamplerTestControllerControlHandle {
472                        inner: this.inner.clone(),
473                    };
474                    Ok(SamplerTestControllerRequest::SetOptional {value: req.value,
475
476                        responder: SamplerTestControllerSetOptionalResponder {
477                            control_handle: std::mem::ManuallyDrop::new(control_handle),
478                            tx_id: header.tx_id,
479                        },
480                    })
481                }
482                0x3d2273c482b7014c => {
483                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
484                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
485                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
486                    let control_handle = SamplerTestControllerControlHandle {
487                        inner: this.inner.clone(),
488                    };
489                    Ok(SamplerTestControllerRequest::RemoveOptional {
490                        responder: SamplerTestControllerRemoveOptionalResponder {
491                            control_handle: std::mem::ManuallyDrop::new(control_handle),
492                            tx_id: header.tx_id,
493                        },
494                    })
495                }
496                0x6edb38cecf8d027b => {
497                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
498                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
499                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
500                    let control_handle = SamplerTestControllerControlHandle {
501                        inner: this.inner.clone(),
502                    };
503                    Ok(SamplerTestControllerRequest::WaitForSample {
504                        responder: SamplerTestControllerWaitForSampleResponder {
505                            control_handle: std::mem::ManuallyDrop::new(control_handle),
506                            tx_id: header.tx_id,
507                        },
508                    })
509                }
510                _ => Err(fidl::Error::UnknownOrdinal {
511                    ordinal: header.ordinal,
512                    protocol_name: <SamplerTestControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
513                }),
514            }))
515            },
516        )
517    }
518}
519
520#[derive(Debug)]
521pub enum SamplerTestControllerRequest {
522    IncrementInt { property_id: u16, responder: SamplerTestControllerIncrementIntResponder },
523    SetOptional { value: i64, responder: SamplerTestControllerSetOptionalResponder },
524    RemoveOptional { responder: SamplerTestControllerRemoveOptionalResponder },
525    WaitForSample { responder: SamplerTestControllerWaitForSampleResponder },
526}
527
528impl SamplerTestControllerRequest {
529    #[allow(irrefutable_let_patterns)]
530    pub fn into_increment_int(self) -> Option<(u16, SamplerTestControllerIncrementIntResponder)> {
531        if let SamplerTestControllerRequest::IncrementInt { property_id, responder } = self {
532            Some((property_id, responder))
533        } else {
534            None
535        }
536    }
537
538    #[allow(irrefutable_let_patterns)]
539    pub fn into_set_optional(self) -> Option<(i64, SamplerTestControllerSetOptionalResponder)> {
540        if let SamplerTestControllerRequest::SetOptional { value, responder } = self {
541            Some((value, responder))
542        } else {
543            None
544        }
545    }
546
547    #[allow(irrefutable_let_patterns)]
548    pub fn into_remove_optional(self) -> Option<(SamplerTestControllerRemoveOptionalResponder)> {
549        if let SamplerTestControllerRequest::RemoveOptional { responder } = self {
550            Some((responder))
551        } else {
552            None
553        }
554    }
555
556    #[allow(irrefutable_let_patterns)]
557    pub fn into_wait_for_sample(self) -> Option<(SamplerTestControllerWaitForSampleResponder)> {
558        if let SamplerTestControllerRequest::WaitForSample { responder } = self {
559            Some((responder))
560        } else {
561            None
562        }
563    }
564
565    /// Name of the method defined in FIDL
566    pub fn method_name(&self) -> &'static str {
567        match *self {
568            SamplerTestControllerRequest::IncrementInt { .. } => "increment_int",
569            SamplerTestControllerRequest::SetOptional { .. } => "set_optional",
570            SamplerTestControllerRequest::RemoveOptional { .. } => "remove_optional",
571            SamplerTestControllerRequest::WaitForSample { .. } => "wait_for_sample",
572        }
573    }
574}
575
576#[derive(Debug, Clone)]
577pub struct SamplerTestControllerControlHandle {
578    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
579}
580
581impl fidl::endpoints::ControlHandle for SamplerTestControllerControlHandle {
582    fn shutdown(&self) {
583        self.inner.shutdown()
584    }
585
586    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
587        self.inner.shutdown_with_epitaph(status)
588    }
589
590    fn is_closed(&self) -> bool {
591        self.inner.channel().is_closed()
592    }
593    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
594        self.inner.channel().on_closed()
595    }
596
597    #[cfg(target_os = "fuchsia")]
598    fn signal_peer(
599        &self,
600        clear_mask: zx::Signals,
601        set_mask: zx::Signals,
602    ) -> Result<(), zx_status::Status> {
603        use fidl::Peered;
604        self.inner.channel().signal_peer(clear_mask, set_mask)
605    }
606}
607
608impl SamplerTestControllerControlHandle {}
609
610#[must_use = "FIDL methods require a response to be sent"]
611#[derive(Debug)]
612pub struct SamplerTestControllerIncrementIntResponder {
613    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
614    tx_id: u32,
615}
616
617/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
618/// if the responder is dropped without sending a response, so that the client
619/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
620impl std::ops::Drop for SamplerTestControllerIncrementIntResponder {
621    fn drop(&mut self) {
622        self.control_handle.shutdown();
623        // Safety: drops once, never accessed again
624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
625    }
626}
627
628impl fidl::endpoints::Responder for SamplerTestControllerIncrementIntResponder {
629    type ControlHandle = SamplerTestControllerControlHandle;
630
631    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
632        &self.control_handle
633    }
634
635    fn drop_without_shutdown(mut self) {
636        // Safety: drops once, never accessed again due to mem::forget
637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
638        // Prevent Drop from running (which would shut down the channel)
639        std::mem::forget(self);
640    }
641}
642
643impl SamplerTestControllerIncrementIntResponder {
644    /// Sends a response to the FIDL transaction.
645    ///
646    /// Sets the channel to shutdown if an error occurs.
647    pub fn send(self) -> Result<(), fidl::Error> {
648        let _result = self.send_raw();
649        if _result.is_err() {
650            self.control_handle.shutdown();
651        }
652        self.drop_without_shutdown();
653        _result
654    }
655
656    /// Similar to "send" but does not shutdown the channel if an error occurs.
657    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
658        let _result = self.send_raw();
659        self.drop_without_shutdown();
660        _result
661    }
662
663    fn send_raw(&self) -> Result<(), fidl::Error> {
664        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
665            (),
666            self.tx_id,
667            0x38330ef9d7233f6e,
668            fidl::encoding::DynamicFlags::empty(),
669        )
670    }
671}
672
673#[must_use = "FIDL methods require a response to be sent"]
674#[derive(Debug)]
675pub struct SamplerTestControllerSetOptionalResponder {
676    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
677    tx_id: u32,
678}
679
680/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
681/// if the responder is dropped without sending a response, so that the client
682/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
683impl std::ops::Drop for SamplerTestControllerSetOptionalResponder {
684    fn drop(&mut self) {
685        self.control_handle.shutdown();
686        // Safety: drops once, never accessed again
687        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
688    }
689}
690
691impl fidl::endpoints::Responder for SamplerTestControllerSetOptionalResponder {
692    type ControlHandle = SamplerTestControllerControlHandle;
693
694    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
695        &self.control_handle
696    }
697
698    fn drop_without_shutdown(mut self) {
699        // Safety: drops once, never accessed again due to mem::forget
700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
701        // Prevent Drop from running (which would shut down the channel)
702        std::mem::forget(self);
703    }
704}
705
706impl SamplerTestControllerSetOptionalResponder {
707    /// Sends a response to the FIDL transaction.
708    ///
709    /// Sets the channel to shutdown if an error occurs.
710    pub fn send(self) -> Result<(), fidl::Error> {
711        let _result = self.send_raw();
712        if _result.is_err() {
713            self.control_handle.shutdown();
714        }
715        self.drop_without_shutdown();
716        _result
717    }
718
719    /// Similar to "send" but does not shutdown the channel if an error occurs.
720    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
721        let _result = self.send_raw();
722        self.drop_without_shutdown();
723        _result
724    }
725
726    fn send_raw(&self) -> Result<(), fidl::Error> {
727        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
728            (),
729            self.tx_id,
730            0x41f2f914c43d92d1,
731            fidl::encoding::DynamicFlags::empty(),
732        )
733    }
734}
735
736#[must_use = "FIDL methods require a response to be sent"]
737#[derive(Debug)]
738pub struct SamplerTestControllerRemoveOptionalResponder {
739    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
740    tx_id: u32,
741}
742
743/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
744/// if the responder is dropped without sending a response, so that the client
745/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
746impl std::ops::Drop for SamplerTestControllerRemoveOptionalResponder {
747    fn drop(&mut self) {
748        self.control_handle.shutdown();
749        // Safety: drops once, never accessed again
750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
751    }
752}
753
754impl fidl::endpoints::Responder for SamplerTestControllerRemoveOptionalResponder {
755    type ControlHandle = SamplerTestControllerControlHandle;
756
757    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
758        &self.control_handle
759    }
760
761    fn drop_without_shutdown(mut self) {
762        // Safety: drops once, never accessed again due to mem::forget
763        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
764        // Prevent Drop from running (which would shut down the channel)
765        std::mem::forget(self);
766    }
767}
768
769impl SamplerTestControllerRemoveOptionalResponder {
770    /// Sends a response to the FIDL transaction.
771    ///
772    /// Sets the channel to shutdown if an error occurs.
773    pub fn send(self) -> Result<(), fidl::Error> {
774        let _result = self.send_raw();
775        if _result.is_err() {
776            self.control_handle.shutdown();
777        }
778        self.drop_without_shutdown();
779        _result
780    }
781
782    /// Similar to "send" but does not shutdown the channel if an error occurs.
783    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
784        let _result = self.send_raw();
785        self.drop_without_shutdown();
786        _result
787    }
788
789    fn send_raw(&self) -> Result<(), fidl::Error> {
790        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
791            (),
792            self.tx_id,
793            0x3d2273c482b7014c,
794            fidl::encoding::DynamicFlags::empty(),
795        )
796    }
797}
798
799#[must_use = "FIDL methods require a response to be sent"]
800#[derive(Debug)]
801pub struct SamplerTestControllerWaitForSampleResponder {
802    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
803    tx_id: u32,
804}
805
806/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
807/// if the responder is dropped without sending a response, so that the client
808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
809impl std::ops::Drop for SamplerTestControllerWaitForSampleResponder {
810    fn drop(&mut self) {
811        self.control_handle.shutdown();
812        // Safety: drops once, never accessed again
813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
814    }
815}
816
817impl fidl::endpoints::Responder for SamplerTestControllerWaitForSampleResponder {
818    type ControlHandle = SamplerTestControllerControlHandle;
819
820    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
821        &self.control_handle
822    }
823
824    fn drop_without_shutdown(mut self) {
825        // Safety: drops once, never accessed again due to mem::forget
826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
827        // Prevent Drop from running (which would shut down the channel)
828        std::mem::forget(self);
829    }
830}
831
832impl SamplerTestControllerWaitForSampleResponder {
833    /// Sends a response to the FIDL transaction.
834    ///
835    /// Sets the channel to shutdown if an error occurs.
836    pub fn send(self, mut result: Result<(), SamplingError>) -> Result<(), fidl::Error> {
837        let _result = self.send_raw(result);
838        if _result.is_err() {
839            self.control_handle.shutdown();
840        }
841        self.drop_without_shutdown();
842        _result
843    }
844
845    /// Similar to "send" but does not shutdown the channel if an error occurs.
846    pub fn send_no_shutdown_on_err(
847        self,
848        mut result: Result<(), SamplingError>,
849    ) -> Result<(), fidl::Error> {
850        let _result = self.send_raw(result);
851        self.drop_without_shutdown();
852        _result
853    }
854
855    fn send_raw(&self, mut result: Result<(), SamplingError>) -> Result<(), fidl::Error> {
856        self.control_handle.inner.send::<fidl::encoding::ResultType<
857            fidl::encoding::EmptyStruct,
858            SamplingError,
859        >>(
860            result,
861            self.tx_id,
862            0x6edb38cecf8d027b,
863            fidl::encoding::DynamicFlags::empty(),
864        )
865    }
866}
867
868mod internal {
869    use super::*;
870}