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_checker__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct CheckerMarker;
16
17impl fidl::endpoints::ProtocolMarker for CheckerMarker {
18 type Proxy = CheckerProxy;
19 type RequestStream = CheckerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = CheckerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "test.checker.Checker";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for CheckerMarker {}
26
27pub trait CheckerProxyInterface: Send + Sync {
28 type SentinelFileContentsResponseFut: std::future::Future<Output = Result<String, fidl::Error>>
29 + Send;
30 fn r#sentinel_file_contents(&self) -> Self::SentinelFileContentsResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct CheckerSynchronousProxy {
35 client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for CheckerSynchronousProxy {
40 type Proxy = CheckerProxy;
41 type Protocol = CheckerMarker;
42
43 fn from_channel(inner: fidl::Channel) -> Self {
44 Self::new(inner)
45 }
46
47 fn into_channel(self) -> fidl::Channel {
48 self.client.into_channel()
49 }
50
51 fn as_channel(&self) -> &fidl::Channel {
52 self.client.as_channel()
53 }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl CheckerSynchronousProxy {
58 pub fn new(channel: fidl::Channel) -> Self {
59 Self { client: fidl::client::sync::Client::new(channel) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<CheckerEvent, fidl::Error> {
72 CheckerEvent::decode(self.client.wait_for_event::<CheckerMarker>(deadline)?)
73 }
74
75 pub fn r#sentinel_file_contents(
79 &self,
80 ___deadline: zx::MonotonicInstant,
81 ) -> Result<String, fidl::Error> {
82 let _response = self.client.send_query::<
83 fidl::encoding::EmptyPayload,
84 CheckerSentinelFileContentsResponse,
85 CheckerMarker,
86 >(
87 (),
88 0x4733f9bf9988f3d9,
89 fidl::encoding::DynamicFlags::empty(),
90 ___deadline,
91 )?;
92 Ok(_response.contents)
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl From<CheckerSynchronousProxy> for zx::NullableHandle {
98 fn from(value: CheckerSynchronousProxy) -> Self {
99 value.into_channel().into()
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<fidl::Channel> for CheckerSynchronousProxy {
105 fn from(value: fidl::Channel) -> Self {
106 Self::new(value)
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl fidl::endpoints::FromClient for CheckerSynchronousProxy {
112 type Protocol = CheckerMarker;
113
114 fn from_client(value: fidl::endpoints::ClientEnd<CheckerMarker>) -> Self {
115 Self::new(value.into_channel())
116 }
117}
118
119#[derive(Debug, Clone)]
120pub struct CheckerProxy {
121 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
122}
123
124impl fidl::endpoints::Proxy for CheckerProxy {
125 type Protocol = CheckerMarker;
126
127 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
128 Self::new(inner)
129 }
130
131 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
132 self.client.into_channel().map_err(|client| Self { client })
133 }
134
135 fn as_channel(&self) -> &::fidl::AsyncChannel {
136 self.client.as_channel()
137 }
138}
139
140impl CheckerProxy {
141 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
143 let protocol_name = <CheckerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144 Self { client: fidl::client::Client::new(channel, protocol_name) }
145 }
146
147 pub fn take_event_stream(&self) -> CheckerEventStream {
153 CheckerEventStream { event_receiver: self.client.take_event_receiver() }
154 }
155
156 pub fn r#sentinel_file_contents(
160 &self,
161 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
162 CheckerProxyInterface::r#sentinel_file_contents(self)
163 }
164}
165
166impl CheckerProxyInterface for CheckerProxy {
167 type SentinelFileContentsResponseFut =
168 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
169 fn r#sentinel_file_contents(&self) -> Self::SentinelFileContentsResponseFut {
170 fn _decode(
171 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
172 ) -> Result<String, fidl::Error> {
173 let _response = fidl::client::decode_transaction_body::<
174 CheckerSentinelFileContentsResponse,
175 fidl::encoding::DefaultFuchsiaResourceDialect,
176 0x4733f9bf9988f3d9,
177 >(_buf?)?;
178 Ok(_response.contents)
179 }
180 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
181 (),
182 0x4733f9bf9988f3d9,
183 fidl::encoding::DynamicFlags::empty(),
184 _decode,
185 )
186 }
187}
188
189pub struct CheckerEventStream {
190 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
191}
192
193impl std::marker::Unpin for CheckerEventStream {}
194
195impl futures::stream::FusedStream for CheckerEventStream {
196 fn is_terminated(&self) -> bool {
197 self.event_receiver.is_terminated()
198 }
199}
200
201impl futures::Stream for CheckerEventStream {
202 type Item = Result<CheckerEvent, fidl::Error>;
203
204 fn poll_next(
205 mut self: std::pin::Pin<&mut Self>,
206 cx: &mut std::task::Context<'_>,
207 ) -> std::task::Poll<Option<Self::Item>> {
208 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
209 &mut self.event_receiver,
210 cx
211 )?) {
212 Some(buf) => std::task::Poll::Ready(Some(CheckerEvent::decode(buf))),
213 None => std::task::Poll::Ready(None),
214 }
215 }
216}
217
218#[derive(Debug)]
219pub enum CheckerEvent {}
220
221impl CheckerEvent {
222 fn decode(
224 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
225 ) -> Result<CheckerEvent, fidl::Error> {
226 let (bytes, _handles) = buf.split_mut();
227 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
228 debug_assert_eq!(tx_header.tx_id, 0);
229 match tx_header.ordinal {
230 _ => Err(fidl::Error::UnknownOrdinal {
231 ordinal: tx_header.ordinal,
232 protocol_name: <CheckerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
233 }),
234 }
235 }
236}
237
238pub struct CheckerRequestStream {
240 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
241 is_terminated: bool,
242}
243
244impl std::marker::Unpin for CheckerRequestStream {}
245
246impl futures::stream::FusedStream for CheckerRequestStream {
247 fn is_terminated(&self) -> bool {
248 self.is_terminated
249 }
250}
251
252impl fidl::endpoints::RequestStream for CheckerRequestStream {
253 type Protocol = CheckerMarker;
254 type ControlHandle = CheckerControlHandle;
255
256 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
257 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
258 }
259
260 fn control_handle(&self) -> Self::ControlHandle {
261 CheckerControlHandle { inner: self.inner.clone() }
262 }
263
264 fn into_inner(
265 self,
266 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
267 {
268 (self.inner, self.is_terminated)
269 }
270
271 fn from_inner(
272 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
273 is_terminated: bool,
274 ) -> Self {
275 Self { inner, is_terminated }
276 }
277}
278
279impl futures::Stream for CheckerRequestStream {
280 type Item = Result<CheckerRequest, fidl::Error>;
281
282 fn poll_next(
283 mut self: std::pin::Pin<&mut Self>,
284 cx: &mut std::task::Context<'_>,
285 ) -> std::task::Poll<Option<Self::Item>> {
286 let this = &mut *self;
287 if this.inner.check_shutdown(cx) {
288 this.is_terminated = true;
289 return std::task::Poll::Ready(None);
290 }
291 if this.is_terminated {
292 panic!("polled CheckerRequestStream after completion");
293 }
294 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
295 |bytes, handles| {
296 match this.inner.channel().read_etc(cx, bytes, handles) {
297 std::task::Poll::Ready(Ok(())) => {}
298 std::task::Poll::Pending => return std::task::Poll::Pending,
299 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
300 this.is_terminated = true;
301 return std::task::Poll::Ready(None);
302 }
303 std::task::Poll::Ready(Err(e)) => {
304 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
305 e.into(),
306 ))));
307 }
308 }
309
310 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
312
313 std::task::Poll::Ready(Some(match header.ordinal {
314 0x4733f9bf9988f3d9 => {
315 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
316 let mut req = fidl::new_empty!(
317 fidl::encoding::EmptyPayload,
318 fidl::encoding::DefaultFuchsiaResourceDialect
319 );
320 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
321 let control_handle = CheckerControlHandle { inner: this.inner.clone() };
322 Ok(CheckerRequest::SentinelFileContents {
323 responder: CheckerSentinelFileContentsResponder {
324 control_handle: std::mem::ManuallyDrop::new(control_handle),
325 tx_id: header.tx_id,
326 },
327 })
328 }
329 _ => Err(fidl::Error::UnknownOrdinal {
330 ordinal: header.ordinal,
331 protocol_name:
332 <CheckerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
333 }),
334 }))
335 },
336 )
337 }
338}
339
340#[derive(Debug)]
341pub enum CheckerRequest {
342 SentinelFileContents { responder: CheckerSentinelFileContentsResponder },
346}
347
348impl CheckerRequest {
349 #[allow(irrefutable_let_patterns)]
350 pub fn into_sentinel_file_contents(self) -> Option<(CheckerSentinelFileContentsResponder)> {
351 if let CheckerRequest::SentinelFileContents { responder } = self {
352 Some((responder))
353 } else {
354 None
355 }
356 }
357
358 pub fn method_name(&self) -> &'static str {
360 match *self {
361 CheckerRequest::SentinelFileContents { .. } => "sentinel_file_contents",
362 }
363 }
364}
365
366#[derive(Debug, Clone)]
367pub struct CheckerControlHandle {
368 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
369}
370
371impl fidl::endpoints::ControlHandle for CheckerControlHandle {
372 fn shutdown(&self) {
373 self.inner.shutdown()
374 }
375
376 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
377 self.inner.shutdown_with_epitaph(status)
378 }
379
380 fn is_closed(&self) -> bool {
381 self.inner.channel().is_closed()
382 }
383 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
384 self.inner.channel().on_closed()
385 }
386
387 #[cfg(target_os = "fuchsia")]
388 fn signal_peer(
389 &self,
390 clear_mask: zx::Signals,
391 set_mask: zx::Signals,
392 ) -> Result<(), zx_status::Status> {
393 use fidl::Peered;
394 self.inner.channel().signal_peer(clear_mask, set_mask)
395 }
396}
397
398impl CheckerControlHandle {}
399
400#[must_use = "FIDL methods require a response to be sent"]
401#[derive(Debug)]
402pub struct CheckerSentinelFileContentsResponder {
403 control_handle: std::mem::ManuallyDrop<CheckerControlHandle>,
404 tx_id: u32,
405}
406
407impl std::ops::Drop for CheckerSentinelFileContentsResponder {
411 fn drop(&mut self) {
412 self.control_handle.shutdown();
413 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
415 }
416}
417
418impl fidl::endpoints::Responder for CheckerSentinelFileContentsResponder {
419 type ControlHandle = CheckerControlHandle;
420
421 fn control_handle(&self) -> &CheckerControlHandle {
422 &self.control_handle
423 }
424
425 fn drop_without_shutdown(mut self) {
426 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
428 std::mem::forget(self);
430 }
431}
432
433impl CheckerSentinelFileContentsResponder {
434 pub fn send(self, mut contents: &str) -> Result<(), fidl::Error> {
438 let _result = self.send_raw(contents);
439 if _result.is_err() {
440 self.control_handle.shutdown();
441 }
442 self.drop_without_shutdown();
443 _result
444 }
445
446 pub fn send_no_shutdown_on_err(self, mut contents: &str) -> Result<(), fidl::Error> {
448 let _result = self.send_raw(contents);
449 self.drop_without_shutdown();
450 _result
451 }
452
453 fn send_raw(&self, mut contents: &str) -> Result<(), fidl::Error> {
454 self.control_handle.inner.send::<CheckerSentinelFileContentsResponse>(
455 (contents,),
456 self.tx_id,
457 0x4733f9bf9988f3d9,
458 fidl::encoding::DynamicFlags::empty(),
459 )
460 }
461}
462
463mod internal {
464 use super::*;
465}