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 let protocol_name = <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<ExitControllerEvent, fidl::Error> {
71 ExitControllerEvent::decode(self.client.wait_for_event(deadline)?)
72 }
73
74 pub fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
75 self.client.send::<ExitControllerExitRequest>(
76 (code,),
77 0x38305e3f46968321,
78 fidl::encoding::DynamicFlags::empty(),
79 )
80 }
81}
82
83#[cfg(target_os = "fuchsia")]
84impl From<ExitControllerSynchronousProxy> for zx::Handle {
85 fn from(value: ExitControllerSynchronousProxy) -> Self {
86 value.into_channel().into()
87 }
88}
89
90#[cfg(target_os = "fuchsia")]
91impl From<fidl::Channel> for ExitControllerSynchronousProxy {
92 fn from(value: fidl::Channel) -> Self {
93 Self::new(value)
94 }
95}
96
97#[cfg(target_os = "fuchsia")]
98impl fidl::endpoints::FromClient for ExitControllerSynchronousProxy {
99 type Protocol = ExitControllerMarker;
100
101 fn from_client(value: fidl::endpoints::ClientEnd<ExitControllerMarker>) -> Self {
102 Self::new(value.into_channel())
103 }
104}
105
106#[derive(Debug, Clone)]
107pub struct ExitControllerProxy {
108 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
109}
110
111impl fidl::endpoints::Proxy for ExitControllerProxy {
112 type Protocol = ExitControllerMarker;
113
114 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
115 Self::new(inner)
116 }
117
118 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
119 self.client.into_channel().map_err(|client| Self { client })
120 }
121
122 fn as_channel(&self) -> &::fidl::AsyncChannel {
123 self.client.as_channel()
124 }
125}
126
127impl ExitControllerProxy {
128 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
130 let protocol_name = <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
131 Self { client: fidl::client::Client::new(channel, protocol_name) }
132 }
133
134 pub fn take_event_stream(&self) -> ExitControllerEventStream {
140 ExitControllerEventStream { event_receiver: self.client.take_event_receiver() }
141 }
142
143 pub fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
144 ExitControllerProxyInterface::r#exit(self, code)
145 }
146}
147
148impl ExitControllerProxyInterface for ExitControllerProxy {
149 fn r#exit(&self, mut code: i32) -> Result<(), fidl::Error> {
150 self.client.send::<ExitControllerExitRequest>(
151 (code,),
152 0x38305e3f46968321,
153 fidl::encoding::DynamicFlags::empty(),
154 )
155 }
156}
157
158pub struct ExitControllerEventStream {
159 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
160}
161
162impl std::marker::Unpin for ExitControllerEventStream {}
163
164impl futures::stream::FusedStream for ExitControllerEventStream {
165 fn is_terminated(&self) -> bool {
166 self.event_receiver.is_terminated()
167 }
168}
169
170impl futures::Stream for ExitControllerEventStream {
171 type Item = Result<ExitControllerEvent, fidl::Error>;
172
173 fn poll_next(
174 mut self: std::pin::Pin<&mut Self>,
175 cx: &mut std::task::Context<'_>,
176 ) -> std::task::Poll<Option<Self::Item>> {
177 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
178 &mut self.event_receiver,
179 cx
180 )?) {
181 Some(buf) => std::task::Poll::Ready(Some(ExitControllerEvent::decode(buf))),
182 None => std::task::Poll::Ready(None),
183 }
184 }
185}
186
187#[derive(Debug)]
188pub enum ExitControllerEvent {}
189
190impl ExitControllerEvent {
191 fn decode(
193 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
194 ) -> Result<ExitControllerEvent, fidl::Error> {
195 let (bytes, _handles) = buf.split_mut();
196 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
197 debug_assert_eq!(tx_header.tx_id, 0);
198 match tx_header.ordinal {
199 _ => Err(fidl::Error::UnknownOrdinal {
200 ordinal: tx_header.ordinal,
201 protocol_name:
202 <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
203 }),
204 }
205 }
206}
207
208pub struct ExitControllerRequestStream {
210 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
211 is_terminated: bool,
212}
213
214impl std::marker::Unpin for ExitControllerRequestStream {}
215
216impl futures::stream::FusedStream for ExitControllerRequestStream {
217 fn is_terminated(&self) -> bool {
218 self.is_terminated
219 }
220}
221
222impl fidl::endpoints::RequestStream for ExitControllerRequestStream {
223 type Protocol = ExitControllerMarker;
224 type ControlHandle = ExitControllerControlHandle;
225
226 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
227 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
228 }
229
230 fn control_handle(&self) -> Self::ControlHandle {
231 ExitControllerControlHandle { inner: self.inner.clone() }
232 }
233
234 fn into_inner(
235 self,
236 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
237 {
238 (self.inner, self.is_terminated)
239 }
240
241 fn from_inner(
242 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
243 is_terminated: bool,
244 ) -> Self {
245 Self { inner, is_terminated }
246 }
247}
248
249impl futures::Stream for ExitControllerRequestStream {
250 type Item = Result<ExitControllerRequest, fidl::Error>;
251
252 fn poll_next(
253 mut self: std::pin::Pin<&mut Self>,
254 cx: &mut std::task::Context<'_>,
255 ) -> std::task::Poll<Option<Self::Item>> {
256 let this = &mut *self;
257 if this.inner.check_shutdown(cx) {
258 this.is_terminated = true;
259 return std::task::Poll::Ready(None);
260 }
261 if this.is_terminated {
262 panic!("polled ExitControllerRequestStream after completion");
263 }
264 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
265 |bytes, handles| {
266 match this.inner.channel().read_etc(cx, bytes, handles) {
267 std::task::Poll::Ready(Ok(())) => {}
268 std::task::Poll::Pending => return std::task::Poll::Pending,
269 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
270 this.is_terminated = true;
271 return std::task::Poll::Ready(None);
272 }
273 std::task::Poll::Ready(Err(e)) => {
274 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
275 e.into(),
276 ))))
277 }
278 }
279
280 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
282
283 std::task::Poll::Ready(Some(match header.ordinal {
284 0x38305e3f46968321 => {
285 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
286 let mut req = fidl::new_empty!(
287 ExitControllerExitRequest,
288 fidl::encoding::DefaultFuchsiaResourceDialect
289 );
290 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ExitControllerExitRequest>(&header, _body_bytes, handles, &mut req)?;
291 let control_handle =
292 ExitControllerControlHandle { inner: this.inner.clone() };
293 Ok(ExitControllerRequest::Exit { code: req.code, control_handle })
294 }
295 _ => Err(fidl::Error::UnknownOrdinal {
296 ordinal: header.ordinal,
297 protocol_name:
298 <ExitControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
299 }),
300 }))
301 },
302 )
303 }
304}
305
306#[derive(Debug)]
307pub enum ExitControllerRequest {
308 Exit { code: i32, control_handle: ExitControllerControlHandle },
309}
310
311impl ExitControllerRequest {
312 #[allow(irrefutable_let_patterns)]
313 pub fn into_exit(self) -> Option<(i32, ExitControllerControlHandle)> {
314 if let ExitControllerRequest::Exit { code, control_handle } = self {
315 Some((code, control_handle))
316 } else {
317 None
318 }
319 }
320
321 pub fn method_name(&self) -> &'static str {
323 match *self {
324 ExitControllerRequest::Exit { .. } => "exit",
325 }
326 }
327}
328
329#[derive(Debug, Clone)]
330pub struct ExitControllerControlHandle {
331 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
332}
333
334impl fidl::endpoints::ControlHandle for ExitControllerControlHandle {
335 fn shutdown(&self) {
336 self.inner.shutdown()
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}