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_fuchsia_test_syscalls_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ControlMarker;
16
17impl fidl::endpoints::ProtocolMarker for ControlMarker {
18 type Proxy = ControlProxy;
19 type RequestStream = ControlRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ControlSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) Control";
24}
25
26pub trait ControlProxyInterface: Send + Sync {
27 type SetSuspendEnterResultResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
28 + Send;
29 fn r#set_suspend_enter_result(&self, status: i32) -> Self::SetSuspendEnterResultResponseFut;
30 type GetStateResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
31 fn r#get_state(&self) -> Self::GetStateResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct ControlSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
41 type Proxy = ControlProxy;
42 type Protocol = ControlMarker;
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 ControlSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 let protocol_name = <ControlMarker 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 pub fn wait_for_event(
71 &self,
72 deadline: zx::MonotonicInstant,
73 ) -> Result<ControlEvent, fidl::Error> {
74 ControlEvent::decode(self.client.wait_for_event(deadline)?)
75 }
76
77 pub fn r#set_suspend_enter_result(
80 &self,
81 mut status: i32,
82 ___deadline: zx::MonotonicInstant,
83 ) -> Result<(), fidl::Error> {
84 let _response = self
85 .client
86 .send_query::<ControlSetSuspendEnterResultRequest, fidl::encoding::EmptyPayload>(
87 (status,),
88 0x138f77664d2dcd4,
89 fidl::encoding::DynamicFlags::empty(),
90 ___deadline,
91 )?;
92 Ok(_response)
93 }
94
95 pub fn r#get_state(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
97 let _response = self.client.send_query::<fidl::encoding::EmptyPayload, State>(
98 (),
99 0x759e8e871c4a33d1,
100 fidl::encoding::DynamicFlags::empty(),
101 ___deadline,
102 )?;
103 Ok(_response.zx_system_suspend_enter_calls_count)
104 }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl From<ControlSynchronousProxy> for zx::Handle {
109 fn from(value: ControlSynchronousProxy) -> Self {
110 value.into_channel().into()
111 }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl From<fidl::Channel> for ControlSynchronousProxy {
116 fn from(value: fidl::Channel) -> Self {
117 Self::new(value)
118 }
119}
120
121#[derive(Debug, Clone)]
122pub struct ControlProxy {
123 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
124}
125
126impl fidl::endpoints::Proxy for ControlProxy {
127 type Protocol = ControlMarker;
128
129 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
130 Self::new(inner)
131 }
132
133 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
134 self.client.into_channel().map_err(|client| Self { client })
135 }
136
137 fn as_channel(&self) -> &::fidl::AsyncChannel {
138 self.client.as_channel()
139 }
140}
141
142impl ControlProxy {
143 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
145 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
146 Self { client: fidl::client::Client::new(channel, protocol_name) }
147 }
148
149 pub fn take_event_stream(&self) -> ControlEventStream {
155 ControlEventStream { event_receiver: self.client.take_event_receiver() }
156 }
157
158 pub fn r#set_suspend_enter_result(
161 &self,
162 mut status: i32,
163 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
164 ControlProxyInterface::r#set_suspend_enter_result(self, status)
165 }
166
167 pub fn r#get_state(
169 &self,
170 ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
171 ControlProxyInterface::r#get_state(self)
172 }
173}
174
175impl ControlProxyInterface for ControlProxy {
176 type SetSuspendEnterResultResponseFut =
177 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
178 fn r#set_suspend_enter_result(
179 &self,
180 mut status: i32,
181 ) -> Self::SetSuspendEnterResultResponseFut {
182 fn _decode(
183 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
184 ) -> Result<(), fidl::Error> {
185 let _response = fidl::client::decode_transaction_body::<
186 fidl::encoding::EmptyPayload,
187 fidl::encoding::DefaultFuchsiaResourceDialect,
188 0x138f77664d2dcd4,
189 >(_buf?)?;
190 Ok(_response)
191 }
192 self.client.send_query_and_decode::<ControlSetSuspendEnterResultRequest, ()>(
193 (status,),
194 0x138f77664d2dcd4,
195 fidl::encoding::DynamicFlags::empty(),
196 _decode,
197 )
198 }
199
200 type GetStateResponseFut =
201 fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
202 fn r#get_state(&self) -> Self::GetStateResponseFut {
203 fn _decode(
204 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
205 ) -> Result<u32, fidl::Error> {
206 let _response = fidl::client::decode_transaction_body::<
207 State,
208 fidl::encoding::DefaultFuchsiaResourceDialect,
209 0x759e8e871c4a33d1,
210 >(_buf?)?;
211 Ok(_response.zx_system_suspend_enter_calls_count)
212 }
213 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
214 (),
215 0x759e8e871c4a33d1,
216 fidl::encoding::DynamicFlags::empty(),
217 _decode,
218 )
219 }
220}
221
222pub struct ControlEventStream {
223 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
224}
225
226impl std::marker::Unpin for ControlEventStream {}
227
228impl futures::stream::FusedStream for ControlEventStream {
229 fn is_terminated(&self) -> bool {
230 self.event_receiver.is_terminated()
231 }
232}
233
234impl futures::Stream for ControlEventStream {
235 type Item = Result<ControlEvent, fidl::Error>;
236
237 fn poll_next(
238 mut self: std::pin::Pin<&mut Self>,
239 cx: &mut std::task::Context<'_>,
240 ) -> std::task::Poll<Option<Self::Item>> {
241 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
242 &mut self.event_receiver,
243 cx
244 )?) {
245 Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
246 None => std::task::Poll::Ready(None),
247 }
248 }
249}
250
251#[derive(Debug)]
252pub enum ControlEvent {}
253
254impl ControlEvent {
255 fn decode(
257 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
258 ) -> Result<ControlEvent, fidl::Error> {
259 let (bytes, _handles) = buf.split_mut();
260 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
261 debug_assert_eq!(tx_header.tx_id, 0);
262 match tx_header.ordinal {
263 _ => Err(fidl::Error::UnknownOrdinal {
264 ordinal: tx_header.ordinal,
265 protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
266 }),
267 }
268 }
269}
270
271pub struct ControlRequestStream {
273 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
274 is_terminated: bool,
275}
276
277impl std::marker::Unpin for ControlRequestStream {}
278
279impl futures::stream::FusedStream for ControlRequestStream {
280 fn is_terminated(&self) -> bool {
281 self.is_terminated
282 }
283}
284
285impl fidl::endpoints::RequestStream for ControlRequestStream {
286 type Protocol = ControlMarker;
287 type ControlHandle = ControlControlHandle;
288
289 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
290 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
291 }
292
293 fn control_handle(&self) -> Self::ControlHandle {
294 ControlControlHandle { inner: self.inner.clone() }
295 }
296
297 fn into_inner(
298 self,
299 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
300 {
301 (self.inner, self.is_terminated)
302 }
303
304 fn from_inner(
305 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
306 is_terminated: bool,
307 ) -> Self {
308 Self { inner, is_terminated }
309 }
310}
311
312impl futures::Stream for ControlRequestStream {
313 type Item = Result<ControlRequest, fidl::Error>;
314
315 fn poll_next(
316 mut self: std::pin::Pin<&mut Self>,
317 cx: &mut std::task::Context<'_>,
318 ) -> std::task::Poll<Option<Self::Item>> {
319 let this = &mut *self;
320 if this.inner.check_shutdown(cx) {
321 this.is_terminated = true;
322 return std::task::Poll::Ready(None);
323 }
324 if this.is_terminated {
325 panic!("polled ControlRequestStream after completion");
326 }
327 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
328 |bytes, handles| {
329 match this.inner.channel().read_etc(cx, bytes, handles) {
330 std::task::Poll::Ready(Ok(())) => {}
331 std::task::Poll::Pending => return std::task::Poll::Pending,
332 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
333 this.is_terminated = true;
334 return std::task::Poll::Ready(None);
335 }
336 std::task::Poll::Ready(Err(e)) => {
337 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
338 e.into(),
339 ))))
340 }
341 }
342
343 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
345
346 std::task::Poll::Ready(Some(match header.ordinal {
347 0x138f77664d2dcd4 => {
348 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
349 let mut req = fidl::new_empty!(
350 ControlSetSuspendEnterResultRequest,
351 fidl::encoding::DefaultFuchsiaResourceDialect
352 );
353 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetSuspendEnterResultRequest>(&header, _body_bytes, handles, &mut req)?;
354 let control_handle = ControlControlHandle { inner: this.inner.clone() };
355 Ok(ControlRequest::SetSuspendEnterResult {
356 status: req.status,
357
358 responder: ControlSetSuspendEnterResultResponder {
359 control_handle: std::mem::ManuallyDrop::new(control_handle),
360 tx_id: header.tx_id,
361 },
362 })
363 }
364 0x759e8e871c4a33d1 => {
365 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
366 let mut req = fidl::new_empty!(
367 fidl::encoding::EmptyPayload,
368 fidl::encoding::DefaultFuchsiaResourceDialect
369 );
370 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
371 let control_handle = ControlControlHandle { inner: this.inner.clone() };
372 Ok(ControlRequest::GetState {
373 responder: ControlGetStateResponder {
374 control_handle: std::mem::ManuallyDrop::new(control_handle),
375 tx_id: header.tx_id,
376 },
377 })
378 }
379 _ => Err(fidl::Error::UnknownOrdinal {
380 ordinal: header.ordinal,
381 protocol_name:
382 <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
383 }),
384 }))
385 },
386 )
387 }
388}
389
390#[derive(Debug)]
391pub enum ControlRequest {
392 SetSuspendEnterResult { status: i32, responder: ControlSetSuspendEnterResultResponder },
395 GetState { responder: ControlGetStateResponder },
397}
398
399impl ControlRequest {
400 #[allow(irrefutable_let_patterns)]
401 pub fn into_set_suspend_enter_result(
402 self,
403 ) -> Option<(i32, ControlSetSuspendEnterResultResponder)> {
404 if let ControlRequest::SetSuspendEnterResult { status, responder } = self {
405 Some((status, responder))
406 } else {
407 None
408 }
409 }
410
411 #[allow(irrefutable_let_patterns)]
412 pub fn into_get_state(self) -> Option<(ControlGetStateResponder)> {
413 if let ControlRequest::GetState { responder } = self {
414 Some((responder))
415 } else {
416 None
417 }
418 }
419
420 pub fn method_name(&self) -> &'static str {
422 match *self {
423 ControlRequest::SetSuspendEnterResult { .. } => "set_suspend_enter_result",
424 ControlRequest::GetState { .. } => "get_state",
425 }
426 }
427}
428
429#[derive(Debug, Clone)]
430pub struct ControlControlHandle {
431 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
432}
433
434impl fidl::endpoints::ControlHandle for ControlControlHandle {
435 fn shutdown(&self) {
436 self.inner.shutdown()
437 }
438 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
439 self.inner.shutdown_with_epitaph(status)
440 }
441
442 fn is_closed(&self) -> bool {
443 self.inner.channel().is_closed()
444 }
445 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
446 self.inner.channel().on_closed()
447 }
448
449 #[cfg(target_os = "fuchsia")]
450 fn signal_peer(
451 &self,
452 clear_mask: zx::Signals,
453 set_mask: zx::Signals,
454 ) -> Result<(), zx_status::Status> {
455 use fidl::Peered;
456 self.inner.channel().signal_peer(clear_mask, set_mask)
457 }
458}
459
460impl ControlControlHandle {}
461
462#[must_use = "FIDL methods require a response to be sent"]
463#[derive(Debug)]
464pub struct ControlSetSuspendEnterResultResponder {
465 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
466 tx_id: u32,
467}
468
469impl std::ops::Drop for ControlSetSuspendEnterResultResponder {
473 fn drop(&mut self) {
474 self.control_handle.shutdown();
475 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
477 }
478}
479
480impl fidl::endpoints::Responder for ControlSetSuspendEnterResultResponder {
481 type ControlHandle = ControlControlHandle;
482
483 fn control_handle(&self) -> &ControlControlHandle {
484 &self.control_handle
485 }
486
487 fn drop_without_shutdown(mut self) {
488 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
490 std::mem::forget(self);
492 }
493}
494
495impl ControlSetSuspendEnterResultResponder {
496 pub fn send(self) -> Result<(), fidl::Error> {
500 let _result = self.send_raw();
501 if _result.is_err() {
502 self.control_handle.shutdown();
503 }
504 self.drop_without_shutdown();
505 _result
506 }
507
508 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
510 let _result = self.send_raw();
511 self.drop_without_shutdown();
512 _result
513 }
514
515 fn send_raw(&self) -> Result<(), fidl::Error> {
516 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
517 (),
518 self.tx_id,
519 0x138f77664d2dcd4,
520 fidl::encoding::DynamicFlags::empty(),
521 )
522 }
523}
524
525#[must_use = "FIDL methods require a response to be sent"]
526#[derive(Debug)]
527pub struct ControlGetStateResponder {
528 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
529 tx_id: u32,
530}
531
532impl std::ops::Drop for ControlGetStateResponder {
536 fn drop(&mut self) {
537 self.control_handle.shutdown();
538 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
540 }
541}
542
543impl fidl::endpoints::Responder for ControlGetStateResponder {
544 type ControlHandle = ControlControlHandle;
545
546 fn control_handle(&self) -> &ControlControlHandle {
547 &self.control_handle
548 }
549
550 fn drop_without_shutdown(mut self) {
551 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553 std::mem::forget(self);
555 }
556}
557
558impl ControlGetStateResponder {
559 pub fn send(self, mut zx_system_suspend_enter_calls_count: u32) -> Result<(), fidl::Error> {
563 let _result = self.send_raw(zx_system_suspend_enter_calls_count);
564 if _result.is_err() {
565 self.control_handle.shutdown();
566 }
567 self.drop_without_shutdown();
568 _result
569 }
570
571 pub fn send_no_shutdown_on_err(
573 self,
574 mut zx_system_suspend_enter_calls_count: u32,
575 ) -> Result<(), fidl::Error> {
576 let _result = self.send_raw(zx_system_suspend_enter_calls_count);
577 self.drop_without_shutdown();
578 _result
579 }
580
581 fn send_raw(&self, mut zx_system_suspend_enter_calls_count: u32) -> Result<(), fidl::Error> {
582 self.control_handle.inner.send::<State>(
583 (zx_system_suspend_enter_calls_count,),
584 self.tx_id,
585 0x759e8e871c4a33d1,
586 fidl::encoding::DynamicFlags::empty(),
587 )
588 }
589}
590
591#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
592pub struct ControlServiceMarker;
593
594#[cfg(target_os = "fuchsia")]
595impl fidl::endpoints::ServiceMarker for ControlServiceMarker {
596 type Proxy = ControlServiceProxy;
597 type Request = ControlServiceRequest;
598 const SERVICE_NAME: &'static str = "fuchsia.test.syscalls.ControlService";
599}
600
601#[cfg(target_os = "fuchsia")]
606pub enum ControlServiceRequest {
607 Control(ControlRequestStream),
608}
609
610#[cfg(target_os = "fuchsia")]
611impl fidl::endpoints::ServiceRequest for ControlServiceRequest {
612 type Service = ControlServiceMarker;
613
614 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
615 match name {
616 "control" => Self::Control(
617 <ControlRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
618 ),
619 _ => panic!("no such member protocol name for service ControlService"),
620 }
621 }
622
623 fn member_names() -> &'static [&'static str] {
624 &["control"]
625 }
626}
627#[cfg(target_os = "fuchsia")]
630pub struct ControlServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
631
632#[cfg(target_os = "fuchsia")]
633impl fidl::endpoints::ServiceProxy for ControlServiceProxy {
634 type Service = ControlServiceMarker;
635
636 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
637 Self(opener)
638 }
639}
640
641#[cfg(target_os = "fuchsia")]
642impl ControlServiceProxy {
643 pub fn connect_to_control(&self) -> Result<ControlProxy, fidl::Error> {
644 let (proxy, server_end) = fidl::endpoints::create_proxy::<ControlMarker>();
645 self.connect_channel_to_control(server_end)?;
646 Ok(proxy)
647 }
648
649 pub fn connect_to_control_sync(&self) -> Result<ControlSynchronousProxy, fidl::Error> {
652 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControlMarker>();
653 self.connect_channel_to_control(server_end)?;
654 Ok(proxy)
655 }
656
657 pub fn connect_channel_to_control(
660 &self,
661 server_end: fidl::endpoints::ServerEnd<ControlMarker>,
662 ) -> Result<(), fidl::Error> {
663 self.0.open_member("control", server_end.into_channel())
664 }
665
666 pub fn instance_name(&self) -> &str {
667 self.0.instance_name()
668 }
669}
670
671mod internal {
672 use super::*;
673}