fidl_test_config_parentoverrides/
fidl_test_config_parentoverrides.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_test_config_parentoverrides_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ReporterMarker;
16
17impl fidl::endpoints::ProtocolMarker for ReporterMarker {
18    type Proxy = ReporterProxy;
19    type RequestStream = ReporterRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ReporterSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "test.config.parentoverrides.Reporter";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ReporterMarker {}
26
27pub trait ReporterProxyInterface: Send + Sync {
28    type GetParentProvidedConfigStringResponseFut: std::future::Future<Output = Result<String, fidl::Error>>
29        + Send;
30    fn r#get_parent_provided_config_string(&self)
31        -> Self::GetParentProvidedConfigStringResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct ReporterSynchronousProxy {
36    client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for ReporterSynchronousProxy {
41    type Proxy = ReporterProxy;
42    type Protocol = ReporterMarker;
43
44    fn from_channel(inner: fidl::Channel) -> Self {
45        Self::new(inner)
46    }
47
48    fn into_channel(self) -> fidl::Channel {
49        self.client.into_channel()
50    }
51
52    fn as_channel(&self) -> &fidl::Channel {
53        self.client.as_channel()
54    }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl ReporterSynchronousProxy {
59    pub fn new(channel: fidl::Channel) -> Self {
60        let protocol_name = <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
61        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
62    }
63
64    pub fn into_channel(self) -> fidl::Channel {
65        self.client.into_channel()
66    }
67
68    /// Waits until an event arrives and returns it. It is safe for other
69    /// threads to make concurrent requests while waiting for an event.
70    pub fn wait_for_event(
71        &self,
72        deadline: zx::MonotonicInstant,
73    ) -> Result<ReporterEvent, fidl::Error> {
74        ReporterEvent::decode(self.client.wait_for_event(deadline)?)
75    }
76
77    pub fn r#get_parent_provided_config_string(
78        &self,
79        ___deadline: zx::MonotonicInstant,
80    ) -> Result<String, fidl::Error> {
81        let _response = self.client.send_query::<
82            fidl::encoding::EmptyPayload,
83            ReporterGetParentProvidedConfigStringResponse,
84        >(
85            (),
86            0x5fd767f67a6dd786,
87            fidl::encoding::DynamicFlags::empty(),
88            ___deadline,
89        )?;
90        Ok(_response.value)
91    }
92}
93
94#[cfg(target_os = "fuchsia")]
95impl From<ReporterSynchronousProxy> for zx::Handle {
96    fn from(value: ReporterSynchronousProxy) -> Self {
97        value.into_channel().into()
98    }
99}
100
101#[cfg(target_os = "fuchsia")]
102impl From<fidl::Channel> for ReporterSynchronousProxy {
103    fn from(value: fidl::Channel) -> Self {
104        Self::new(value)
105    }
106}
107
108#[derive(Debug, Clone)]
109pub struct ReporterProxy {
110    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
111}
112
113impl fidl::endpoints::Proxy for ReporterProxy {
114    type Protocol = ReporterMarker;
115
116    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
117        Self::new(inner)
118    }
119
120    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
121        self.client.into_channel().map_err(|client| Self { client })
122    }
123
124    fn as_channel(&self) -> &::fidl::AsyncChannel {
125        self.client.as_channel()
126    }
127}
128
129impl ReporterProxy {
130    /// Create a new Proxy for test.config.parentoverrides/Reporter.
131    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
132        let protocol_name = <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
133        Self { client: fidl::client::Client::new(channel, protocol_name) }
134    }
135
136    /// Get a Stream of events from the remote end of the protocol.
137    ///
138    /// # Panics
139    ///
140    /// Panics if the event stream was already taken.
141    pub fn take_event_stream(&self) -> ReporterEventStream {
142        ReporterEventStream { event_receiver: self.client.take_event_receiver() }
143    }
144
145    pub fn r#get_parent_provided_config_string(
146        &self,
147    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
148        ReporterProxyInterface::r#get_parent_provided_config_string(self)
149    }
150}
151
152impl ReporterProxyInterface for ReporterProxy {
153    type GetParentProvidedConfigStringResponseFut =
154        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
155    fn r#get_parent_provided_config_string(
156        &self,
157    ) -> Self::GetParentProvidedConfigStringResponseFut {
158        fn _decode(
159            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
160        ) -> Result<String, fidl::Error> {
161            let _response = fidl::client::decode_transaction_body::<
162                ReporterGetParentProvidedConfigStringResponse,
163                fidl::encoding::DefaultFuchsiaResourceDialect,
164                0x5fd767f67a6dd786,
165            >(_buf?)?;
166            Ok(_response.value)
167        }
168        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
169            (),
170            0x5fd767f67a6dd786,
171            fidl::encoding::DynamicFlags::empty(),
172            _decode,
173        )
174    }
175}
176
177pub struct ReporterEventStream {
178    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
179}
180
181impl std::marker::Unpin for ReporterEventStream {}
182
183impl futures::stream::FusedStream for ReporterEventStream {
184    fn is_terminated(&self) -> bool {
185        self.event_receiver.is_terminated()
186    }
187}
188
189impl futures::Stream for ReporterEventStream {
190    type Item = Result<ReporterEvent, fidl::Error>;
191
192    fn poll_next(
193        mut self: std::pin::Pin<&mut Self>,
194        cx: &mut std::task::Context<'_>,
195    ) -> std::task::Poll<Option<Self::Item>> {
196        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
197            &mut self.event_receiver,
198            cx
199        )?) {
200            Some(buf) => std::task::Poll::Ready(Some(ReporterEvent::decode(buf))),
201            None => std::task::Poll::Ready(None),
202        }
203    }
204}
205
206#[derive(Debug)]
207pub enum ReporterEvent {}
208
209impl ReporterEvent {
210    /// Decodes a message buffer as a [`ReporterEvent`].
211    fn decode(
212        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
213    ) -> Result<ReporterEvent, fidl::Error> {
214        let (bytes, _handles) = buf.split_mut();
215        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
216        debug_assert_eq!(tx_header.tx_id, 0);
217        match tx_header.ordinal {
218            _ => Err(fidl::Error::UnknownOrdinal {
219                ordinal: tx_header.ordinal,
220                protocol_name: <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
221            }),
222        }
223    }
224}
225
226/// A Stream of incoming requests for test.config.parentoverrides/Reporter.
227pub struct ReporterRequestStream {
228    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
229    is_terminated: bool,
230}
231
232impl std::marker::Unpin for ReporterRequestStream {}
233
234impl futures::stream::FusedStream for ReporterRequestStream {
235    fn is_terminated(&self) -> bool {
236        self.is_terminated
237    }
238}
239
240impl fidl::endpoints::RequestStream for ReporterRequestStream {
241    type Protocol = ReporterMarker;
242    type ControlHandle = ReporterControlHandle;
243
244    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
245        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
246    }
247
248    fn control_handle(&self) -> Self::ControlHandle {
249        ReporterControlHandle { inner: self.inner.clone() }
250    }
251
252    fn into_inner(
253        self,
254    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
255    {
256        (self.inner, self.is_terminated)
257    }
258
259    fn from_inner(
260        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261        is_terminated: bool,
262    ) -> Self {
263        Self { inner, is_terminated }
264    }
265}
266
267impl futures::Stream for ReporterRequestStream {
268    type Item = Result<ReporterRequest, fidl::Error>;
269
270    fn poll_next(
271        mut self: std::pin::Pin<&mut Self>,
272        cx: &mut std::task::Context<'_>,
273    ) -> std::task::Poll<Option<Self::Item>> {
274        let this = &mut *self;
275        if this.inner.check_shutdown(cx) {
276            this.is_terminated = true;
277            return std::task::Poll::Ready(None);
278        }
279        if this.is_terminated {
280            panic!("polled ReporterRequestStream after completion");
281        }
282        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
283            |bytes, handles| {
284                match this.inner.channel().read_etc(cx, bytes, handles) {
285                    std::task::Poll::Ready(Ok(())) => {}
286                    std::task::Poll::Pending => return std::task::Poll::Pending,
287                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
288                        this.is_terminated = true;
289                        return std::task::Poll::Ready(None);
290                    }
291                    std::task::Poll::Ready(Err(e)) => {
292                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
293                            e.into(),
294                        ))))
295                    }
296                }
297
298                // A message has been received from the channel
299                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
300
301                std::task::Poll::Ready(Some(match header.ordinal {
302                    0x5fd767f67a6dd786 => {
303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
304                        let mut req = fidl::new_empty!(
305                            fidl::encoding::EmptyPayload,
306                            fidl::encoding::DefaultFuchsiaResourceDialect
307                        );
308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
309                        let control_handle = ReporterControlHandle { inner: this.inner.clone() };
310                        Ok(ReporterRequest::GetParentProvidedConfigString {
311                            responder: ReporterGetParentProvidedConfigStringResponder {
312                                control_handle: std::mem::ManuallyDrop::new(control_handle),
313                                tx_id: header.tx_id,
314                            },
315                        })
316                    }
317                    _ => Err(fidl::Error::UnknownOrdinal {
318                        ordinal: header.ordinal,
319                        protocol_name:
320                            <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
321                    }),
322                }))
323            },
324        )
325    }
326}
327
328#[derive(Debug)]
329pub enum ReporterRequest {
330    GetParentProvidedConfigString { responder: ReporterGetParentProvidedConfigStringResponder },
331}
332
333impl ReporterRequest {
334    #[allow(irrefutable_let_patterns)]
335    pub fn into_get_parent_provided_config_string(
336        self,
337    ) -> Option<(ReporterGetParentProvidedConfigStringResponder)> {
338        if let ReporterRequest::GetParentProvidedConfigString { responder } = self {
339            Some((responder))
340        } else {
341            None
342        }
343    }
344
345    /// Name of the method defined in FIDL
346    pub fn method_name(&self) -> &'static str {
347        match *self {
348            ReporterRequest::GetParentProvidedConfigString { .. } => {
349                "get_parent_provided_config_string"
350            }
351        }
352    }
353}
354
355#[derive(Debug, Clone)]
356pub struct ReporterControlHandle {
357    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
358}
359
360impl fidl::endpoints::ControlHandle for ReporterControlHandle {
361    fn shutdown(&self) {
362        self.inner.shutdown()
363    }
364    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
365        self.inner.shutdown_with_epitaph(status)
366    }
367
368    fn is_closed(&self) -> bool {
369        self.inner.channel().is_closed()
370    }
371    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
372        self.inner.channel().on_closed()
373    }
374
375    #[cfg(target_os = "fuchsia")]
376    fn signal_peer(
377        &self,
378        clear_mask: zx::Signals,
379        set_mask: zx::Signals,
380    ) -> Result<(), zx_status::Status> {
381        use fidl::Peered;
382        self.inner.channel().signal_peer(clear_mask, set_mask)
383    }
384}
385
386impl ReporterControlHandle {}
387
388#[must_use = "FIDL methods require a response to be sent"]
389#[derive(Debug)]
390pub struct ReporterGetParentProvidedConfigStringResponder {
391    control_handle: std::mem::ManuallyDrop<ReporterControlHandle>,
392    tx_id: u32,
393}
394
395/// Set the the channel to be shutdown (see [`ReporterControlHandle::shutdown`])
396/// if the responder is dropped without sending a response, so that the client
397/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
398impl std::ops::Drop for ReporterGetParentProvidedConfigStringResponder {
399    fn drop(&mut self) {
400        self.control_handle.shutdown();
401        // Safety: drops once, never accessed again
402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
403    }
404}
405
406impl fidl::endpoints::Responder for ReporterGetParentProvidedConfigStringResponder {
407    type ControlHandle = ReporterControlHandle;
408
409    fn control_handle(&self) -> &ReporterControlHandle {
410        &self.control_handle
411    }
412
413    fn drop_without_shutdown(mut self) {
414        // Safety: drops once, never accessed again due to mem::forget
415        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
416        // Prevent Drop from running (which would shut down the channel)
417        std::mem::forget(self);
418    }
419}
420
421impl ReporterGetParentProvidedConfigStringResponder {
422    /// Sends a response to the FIDL transaction.
423    ///
424    /// Sets the channel to shutdown if an error occurs.
425    pub fn send(self, mut value: &str) -> Result<(), fidl::Error> {
426        let _result = self.send_raw(value);
427        if _result.is_err() {
428            self.control_handle.shutdown();
429        }
430        self.drop_without_shutdown();
431        _result
432    }
433
434    /// Similar to "send" but does not shutdown the channel if an error occurs.
435    pub fn send_no_shutdown_on_err(self, mut value: &str) -> Result<(), fidl::Error> {
436        let _result = self.send_raw(value);
437        self.drop_without_shutdown();
438        _result
439    }
440
441    fn send_raw(&self, mut value: &str) -> Result<(), fidl::Error> {
442        self.control_handle.inner.send::<ReporterGetParentProvidedConfigStringResponse>(
443            (value,),
444            self.tx_id,
445            0x5fd767f67a6dd786,
446            fidl::encoding::DynamicFlags::empty(),
447        )
448    }
449}
450
451mod internal {
452    use super::*;
453}