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