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