Skip to main content

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