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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
586        self.inner.shutdown_with_epitaph(status)
587    }
588
589    fn is_closed(&self) -> bool {
590        self.inner.channel().is_closed()
591    }
592    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
593        self.inner.channel().on_closed()
594    }
595
596    #[cfg(target_os = "fuchsia")]
597    fn signal_peer(
598        &self,
599        clear_mask: zx::Signals,
600        set_mask: zx::Signals,
601    ) -> Result<(), zx_status::Status> {
602        use fidl::Peered;
603        self.inner.channel().signal_peer(clear_mask, set_mask)
604    }
605}
606
607impl SamplerTestControllerControlHandle {}
608
609#[must_use = "FIDL methods require a response to be sent"]
610#[derive(Debug)]
611pub struct SamplerTestControllerIncrementIntResponder {
612    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
613    tx_id: u32,
614}
615
616/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
617/// if the responder is dropped without sending a response, so that the client
618/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
619impl std::ops::Drop for SamplerTestControllerIncrementIntResponder {
620    fn drop(&mut self) {
621        self.control_handle.shutdown();
622        // Safety: drops once, never accessed again
623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
624    }
625}
626
627impl fidl::endpoints::Responder for SamplerTestControllerIncrementIntResponder {
628    type ControlHandle = SamplerTestControllerControlHandle;
629
630    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
631        &self.control_handle
632    }
633
634    fn drop_without_shutdown(mut self) {
635        // Safety: drops once, never accessed again due to mem::forget
636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
637        // Prevent Drop from running (which would shut down the channel)
638        std::mem::forget(self);
639    }
640}
641
642impl SamplerTestControllerIncrementIntResponder {
643    /// Sends a response to the FIDL transaction.
644    ///
645    /// Sets the channel to shutdown if an error occurs.
646    pub fn send(self) -> Result<(), fidl::Error> {
647        let _result = self.send_raw();
648        if _result.is_err() {
649            self.control_handle.shutdown();
650        }
651        self.drop_without_shutdown();
652        _result
653    }
654
655    /// Similar to "send" but does not shutdown the channel if an error occurs.
656    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
657        let _result = self.send_raw();
658        self.drop_without_shutdown();
659        _result
660    }
661
662    fn send_raw(&self) -> Result<(), fidl::Error> {
663        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
664            (),
665            self.tx_id,
666            0x38330ef9d7233f6e,
667            fidl::encoding::DynamicFlags::empty(),
668        )
669    }
670}
671
672#[must_use = "FIDL methods require a response to be sent"]
673#[derive(Debug)]
674pub struct SamplerTestControllerSetOptionalResponder {
675    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
676    tx_id: u32,
677}
678
679/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
680/// if the responder is dropped without sending a response, so that the client
681/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
682impl std::ops::Drop for SamplerTestControllerSetOptionalResponder {
683    fn drop(&mut self) {
684        self.control_handle.shutdown();
685        // Safety: drops once, never accessed again
686        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
687    }
688}
689
690impl fidl::endpoints::Responder for SamplerTestControllerSetOptionalResponder {
691    type ControlHandle = SamplerTestControllerControlHandle;
692
693    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
694        &self.control_handle
695    }
696
697    fn drop_without_shutdown(mut self) {
698        // Safety: drops once, never accessed again due to mem::forget
699        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
700        // Prevent Drop from running (which would shut down the channel)
701        std::mem::forget(self);
702    }
703}
704
705impl SamplerTestControllerSetOptionalResponder {
706    /// Sends a response to the FIDL transaction.
707    ///
708    /// Sets the channel to shutdown if an error occurs.
709    pub fn send(self) -> Result<(), fidl::Error> {
710        let _result = self.send_raw();
711        if _result.is_err() {
712            self.control_handle.shutdown();
713        }
714        self.drop_without_shutdown();
715        _result
716    }
717
718    /// Similar to "send" but does not shutdown the channel if an error occurs.
719    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
720        let _result = self.send_raw();
721        self.drop_without_shutdown();
722        _result
723    }
724
725    fn send_raw(&self) -> Result<(), fidl::Error> {
726        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
727            (),
728            self.tx_id,
729            0x41f2f914c43d92d1,
730            fidl::encoding::DynamicFlags::empty(),
731        )
732    }
733}
734
735#[must_use = "FIDL methods require a response to be sent"]
736#[derive(Debug)]
737pub struct SamplerTestControllerRemoveOptionalResponder {
738    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
739    tx_id: u32,
740}
741
742/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
743/// if the responder is dropped without sending a response, so that the client
744/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
745impl std::ops::Drop for SamplerTestControllerRemoveOptionalResponder {
746    fn drop(&mut self) {
747        self.control_handle.shutdown();
748        // Safety: drops once, never accessed again
749        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
750    }
751}
752
753impl fidl::endpoints::Responder for SamplerTestControllerRemoveOptionalResponder {
754    type ControlHandle = SamplerTestControllerControlHandle;
755
756    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
757        &self.control_handle
758    }
759
760    fn drop_without_shutdown(mut self) {
761        // Safety: drops once, never accessed again due to mem::forget
762        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
763        // Prevent Drop from running (which would shut down the channel)
764        std::mem::forget(self);
765    }
766}
767
768impl SamplerTestControllerRemoveOptionalResponder {
769    /// Sends a response to the FIDL transaction.
770    ///
771    /// Sets the channel to shutdown if an error occurs.
772    pub fn send(self) -> Result<(), fidl::Error> {
773        let _result = self.send_raw();
774        if _result.is_err() {
775            self.control_handle.shutdown();
776        }
777        self.drop_without_shutdown();
778        _result
779    }
780
781    /// Similar to "send" but does not shutdown the channel if an error occurs.
782    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
783        let _result = self.send_raw();
784        self.drop_without_shutdown();
785        _result
786    }
787
788    fn send_raw(&self) -> Result<(), fidl::Error> {
789        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
790            (),
791            self.tx_id,
792            0x3d2273c482b7014c,
793            fidl::encoding::DynamicFlags::empty(),
794        )
795    }
796}
797
798#[must_use = "FIDL methods require a response to be sent"]
799#[derive(Debug)]
800pub struct SamplerTestControllerWaitForSampleResponder {
801    control_handle: std::mem::ManuallyDrop<SamplerTestControllerControlHandle>,
802    tx_id: u32,
803}
804
805/// Set the the channel to be shutdown (see [`SamplerTestControllerControlHandle::shutdown`])
806/// if the responder is dropped without sending a response, so that the client
807/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
808impl std::ops::Drop for SamplerTestControllerWaitForSampleResponder {
809    fn drop(&mut self) {
810        self.control_handle.shutdown();
811        // Safety: drops once, never accessed again
812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
813    }
814}
815
816impl fidl::endpoints::Responder for SamplerTestControllerWaitForSampleResponder {
817    type ControlHandle = SamplerTestControllerControlHandle;
818
819    fn control_handle(&self) -> &SamplerTestControllerControlHandle {
820        &self.control_handle
821    }
822
823    fn drop_without_shutdown(mut self) {
824        // Safety: drops once, never accessed again due to mem::forget
825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
826        // Prevent Drop from running (which would shut down the channel)
827        std::mem::forget(self);
828    }
829}
830
831impl SamplerTestControllerWaitForSampleResponder {
832    /// Sends a response to the FIDL transaction.
833    ///
834    /// Sets the channel to shutdown if an error occurs.
835    pub fn send(self, mut result: Result<(), SamplingError>) -> Result<(), fidl::Error> {
836        let _result = self.send_raw(result);
837        if _result.is_err() {
838            self.control_handle.shutdown();
839        }
840        self.drop_without_shutdown();
841        _result
842    }
843
844    /// Similar to "send" but does not shutdown the channel if an error occurs.
845    pub fn send_no_shutdown_on_err(
846        self,
847        mut result: Result<(), SamplingError>,
848    ) -> Result<(), fidl::Error> {
849        let _result = self.send_raw(result);
850        self.drop_without_shutdown();
851        _result
852    }
853
854    fn send_raw(&self, mut result: Result<(), SamplingError>) -> Result<(), fidl::Error> {
855        self.control_handle.inner.send::<fidl::encoding::ResultType<
856            fidl::encoding::EmptyStruct,
857            SamplingError,
858        >>(
859            result,
860            self.tx_id,
861            0x6edb38cecf8d027b,
862            fidl::encoding::DynamicFlags::empty(),
863        )
864    }
865}
866
867mod internal {
868    use super::*;
869}