1#![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_policy__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ExitControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for ExitControllerMarker {
18 type Proxy = ExitControllerProxy;
19 type RequestStream = ExitControllerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ExitControllerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "test.policy.ExitController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ExitControllerMarker {}
26
27pub trait ExitControllerProxyInterface: Send + Sync {
28 fn r#exit(&self, code: i32) -> Result<(), fidl::Error>;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct ExitControllerSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for ExitControllerSynchronousProxy {
38 type Proxy = ExitControllerProxy;
39 type Protocol = ExitControllerMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl ExitControllerSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 Self { client: fidl::client::sync::Client::new(channel) }
58 }
59
60 pub fn into_channel(self) -> fidl::Channel {
61 self.client.into_channel()
62 }
63
64 pub fn wait_for_event(
67 &self,
68 deadline: zx::MonotonicInstant,
69 ) -> Result<ExitControllerEvent, fidl::Error> {
70 ExitControllerEvent::decode(self.client.wait_for_event::<ExitControllerMarker>(deadline)?)
71 }
72
73 pub fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
74 self.client.send::<ExitControllerExitRequest>(
75 (code,),
76 0x38305e3f46968321,
77 fidl::encoding::DynamicFlags::empty(),
78 )
79 }
80}
81
82#[cfg(target_os = "fuchsia")]
83impl From<ExitControllerSynchronousProxy> for zx::NullableHandle {
84 fn from(value: ExitControllerSynchronousProxy) -> Self {
85 value.into_channel().into()
86 }
87}
88
89#[cfg(target_os = "fuchsia")]
90impl From<fidl::Channel> for ExitControllerSynchronousProxy {
91 fn from(value: fidl::Channel) -> Self {
92 Self::new(value)
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl fidl::endpoints::FromClient for ExitControllerSynchronousProxy {
98 type Protocol = ExitControllerMarker;
99
100 fn from_client(value: fidl::endpoints::ClientEnd<ExitControllerMarker>) -> Self {
101 Self::new(value.into_channel())
102 }
103}
104
105#[derive(Debug, Clone)]
106pub struct ExitControllerProxy {
107 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
108}
109
110impl fidl::endpoints::Proxy for ExitControllerProxy {
111 type Protocol = ExitControllerMarker;
112
113 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
114 Self::new(inner)
115 }
116
117 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
118 self.client.into_channel().map_err(|client| Self { client })
119 }
120
121 fn as_channel(&self) -> &::fidl::AsyncChannel {
122 self.client.as_channel()
123 }
124}
125
126impl ExitControllerProxy {
127 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
129 let protocol_name = <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130 Self { client: fidl::client::Client::new(channel, protocol_name) }
131 }
132
133 pub fn take_event_stream(&self) -> ExitControllerEventStream {
139 ExitControllerEventStream { event_receiver: self.client.take_event_receiver() }
140 }
141
142 pub fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
143 ExitControllerProxyInterface::r#exit(self, code)
144 }
145}
146
147impl ExitControllerProxyInterface for ExitControllerProxy {
148 fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
149 self.client.send::<ExitControllerExitRequest>(
150 (code,),
151 0x38305e3f46968321,
152 fidl::encoding::DynamicFlags::empty(),
153 )
154 }
155}
156
157pub struct ExitControllerEventStream {
158 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
159}
160
161impl std::marker::Unpin for ExitControllerEventStream {}
162
163impl futures::stream::FusedStream for ExitControllerEventStream {
164 fn is_terminated(&self) -> bool {
165 self.event_receiver.is_terminated()
166 }
167}
168
169impl futures::Stream for ExitControllerEventStream {
170 type Item = Result<ExitControllerEvent, fidl::Error>;
171
172 fn poll_next(
173 mut self: std::pin::Pin<&mut Self>,
174 cx: &mut std::task::Context<'_>,
175 ) -> std::task::Poll<Option<Self::Item>> {
176 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
177 &mut self.event_receiver,
178 cx
179 )?) {
180 Some(buf) => std::task::Poll::Ready(Some(ExitControllerEvent::decode(buf))),
181 None => std::task::Poll::Ready(None),
182 }
183 }
184}
185
186#[derive(Debug)]
187pub enum ExitControllerEvent {}
188
189impl ExitControllerEvent {
190 fn decode(
192 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
193 ) -> Result<ExitControllerEvent, fidl::Error> {
194 let (bytes, _handles) = buf.split_mut();
195 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
196 debug_assert_eq!(tx_header.tx_id, 0);
197 match tx_header.ordinal {
198 _ => Err(fidl::Error::UnknownOrdinal {
199 ordinal: tx_header.ordinal,
200 protocol_name:
201 <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
202 }),
203 }
204 }
205}
206
207pub struct ExitControllerRequestStream {
209 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
210 is_terminated: bool,
211}
212
213impl std::marker::Unpin for ExitControllerRequestStream {}
214
215impl futures::stream::FusedStream for ExitControllerRequestStream {
216 fn is_terminated(&self) -> bool {
217 self.is_terminated
218 }
219}
220
221impl fidl::endpoints::RequestStream for ExitControllerRequestStream {
222 type Protocol = ExitControllerMarker;
223 type ControlHandle = ExitControllerControlHandle;
224
225 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
226 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
227 }
228
229 fn control_handle(&self) -> Self::ControlHandle {
230 ExitControllerControlHandle { inner: self.inner.clone() }
231 }
232
233 fn into_inner(
234 self,
235 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
236 {
237 (self.inner, self.is_terminated)
238 }
239
240 fn from_inner(
241 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
242 is_terminated: bool,
243 ) -> Self {
244 Self { inner, is_terminated }
245 }
246}
247
248impl futures::Stream for ExitControllerRequestStream {
249 type Item = Result<ExitControllerRequest, fidl::Error>;
250
251 fn poll_next(
252 mut self: std::pin::Pin<&mut Self>,
253 cx: &mut std::task::Context<'_>,
254 ) -> std::task::Poll<Option<Self::Item>> {
255 let this = &mut *self;
256 if this.inner.check_shutdown(cx) {
257 this.is_terminated = true;
258 return std::task::Poll::Ready(None);
259 }
260 if this.is_terminated {
261 panic!("polled ExitControllerRequestStream after completion");
262 }
263 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
264 |bytes, handles| {
265 match this.inner.channel().read_etc(cx, bytes, handles) {
266 std::task::Poll::Ready(Ok(())) => {}
267 std::task::Poll::Pending => return std::task::Poll::Pending,
268 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
269 this.is_terminated = true;
270 return std::task::Poll::Ready(None);
271 }
272 std::task::Poll::Ready(Err(e)) => {
273 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
274 e.into(),
275 ))));
276 }
277 }
278
279 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
281
282 std::task::Poll::Ready(Some(match header.ordinal {
283 0x38305e3f46968321 => {
284 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
285 let mut req = fidl::new_empty!(
286 ExitControllerExitRequest,
287 fidl::encoding::DefaultFuchsiaResourceDialect
288 );
289 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ExitControllerExitRequest>(&header, _body_bytes, handles, &mut req)?;
290 let control_handle =
291 ExitControllerControlHandle { inner: this.inner.clone() };
292 Ok(ExitControllerRequest::Exit { code: req.code, control_handle })
293 }
294 _ => Err(fidl::Error::UnknownOrdinal {
295 ordinal: header.ordinal,
296 protocol_name:
297 <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
298 }),
299 }))
300 },
301 )
302 }
303}
304
305#[derive(Debug)]
306pub enum ExitControllerRequest {
307 Exit { code: i32, control_handle: ExitControllerControlHandle },
308}
309
310impl ExitControllerRequest {
311 #[allow(irrefutable_let_patterns)]
312 pub fn into_exit(self) -> Option<(i32, ExitControllerControlHandle)> {
313 if let ExitControllerRequest::Exit { code, control_handle } = self {
314 Some((code, control_handle))
315 } else {
316 None
317 }
318 }
319
320 pub fn method_name(&self) -> &'static str {
322 match *self {
323 ExitControllerRequest::Exit { .. } => "exit",
324 }
325 }
326}
327
328#[derive(Debug, Clone)]
329pub struct ExitControllerControlHandle {
330 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
331}
332
333impl fidl::endpoints::ControlHandle for ExitControllerControlHandle {
334 fn shutdown(&self) {
335 self.inner.shutdown()
336 }
337
338 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
339 self.inner.shutdown_with_epitaph(status)
340 }
341
342 fn is_closed(&self) -> bool {
343 self.inner.channel().is_closed()
344 }
345 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
346 self.inner.channel().on_closed()
347 }
348
349 #[cfg(target_os = "fuchsia")]
350 fn signal_peer(
351 &self,
352 clear_mask: zx::Signals,
353 set_mask: zx::Signals,
354 ) -> Result<(), zx_status::Status> {
355 use fidl::Peered;
356 self.inner.channel().signal_peer(clear_mask, set_mask)
357 }
358}
359
360impl ExitControllerControlHandle {}
361
362mod internal {
363 use super::*;
364}