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