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