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_mockrebootcontroller__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct MockRebootControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for MockRebootControllerMarker {
18 type Proxy = MockRebootControllerProxy;
19 type RequestStream = MockRebootControllerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = MockRebootControllerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.mockrebootcontroller.MockRebootController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for MockRebootControllerMarker {}
26pub type MockRebootControllerTriggerRebootResult = Result<(), RebootError>;
27pub type MockRebootControllerCrashRebootChannelResult = Result<(), RebootError>;
28
29pub trait MockRebootControllerProxyInterface: Send + Sync {
30 type TriggerRebootResponseFut: std::future::Future<Output = Result<MockRebootControllerTriggerRebootResult, fidl::Error>>
31 + Send;
32 fn r#trigger_reboot(&self) -> Self::TriggerRebootResponseFut;
33 type CrashRebootChannelResponseFut: std::future::Future<
34 Output = Result<MockRebootControllerCrashRebootChannelResult, fidl::Error>,
35 > + Send;
36 fn r#crash_reboot_channel(&self) -> Self::CrashRebootChannelResponseFut;
37}
38#[derive(Debug)]
39#[cfg(target_os = "fuchsia")]
40pub struct MockRebootControllerSynchronousProxy {
41 client: fidl::client::sync::Client,
42}
43
44#[cfg(target_os = "fuchsia")]
45impl fidl::endpoints::SynchronousProxy for MockRebootControllerSynchronousProxy {
46 type Proxy = MockRebootControllerProxy;
47 type Protocol = MockRebootControllerMarker;
48
49 fn from_channel(inner: fidl::Channel) -> Self {
50 Self::new(inner)
51 }
52
53 fn into_channel(self) -> fidl::Channel {
54 self.client.into_channel()
55 }
56
57 fn as_channel(&self) -> &fidl::Channel {
58 self.client.as_channel()
59 }
60}
61
62#[cfg(target_os = "fuchsia")]
63impl MockRebootControllerSynchronousProxy {
64 pub fn new(channel: fidl::Channel) -> Self {
65 let protocol_name =
66 <MockRebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
67 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<MockRebootControllerEvent, fidl::Error> {
80 MockRebootControllerEvent::decode(self.client.wait_for_event(deadline)?)
81 }
82
83 pub fn r#trigger_reboot(
84 &self,
85 ___deadline: zx::MonotonicInstant,
86 ) -> Result<MockRebootControllerTriggerRebootResult, fidl::Error> {
87 let _response = self.client.send_query::<
88 fidl::encoding::EmptyPayload,
89 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RebootError>,
90 >(
91 (),
92 0x5e2a61aa7f881d13,
93 fidl::encoding::DynamicFlags::empty(),
94 ___deadline,
95 )?;
96 Ok(_response.map(|x| x))
97 }
98
99 pub fn r#crash_reboot_channel(
100 &self,
101 ___deadline: zx::MonotonicInstant,
102 ) -> Result<MockRebootControllerCrashRebootChannelResult, fidl::Error> {
103 let _response = self.client.send_query::<
104 fidl::encoding::EmptyPayload,
105 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RebootError>,
106 >(
107 (),
108 0x7d42f63d8d9ec3c3,
109 fidl::encoding::DynamicFlags::empty(),
110 ___deadline,
111 )?;
112 Ok(_response.map(|x| x))
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl From<MockRebootControllerSynchronousProxy> for zx::Handle {
118 fn from(value: MockRebootControllerSynchronousProxy) -> Self {
119 value.into_channel().into()
120 }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl From<fidl::Channel> for MockRebootControllerSynchronousProxy {
125 fn from(value: fidl::Channel) -> Self {
126 Self::new(value)
127 }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::FromClient for MockRebootControllerSynchronousProxy {
132 type Protocol = MockRebootControllerMarker;
133
134 fn from_client(value: fidl::endpoints::ClientEnd<MockRebootControllerMarker>) -> Self {
135 Self::new(value.into_channel())
136 }
137}
138
139#[derive(Debug, Clone)]
140pub struct MockRebootControllerProxy {
141 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
142}
143
144impl fidl::endpoints::Proxy for MockRebootControllerProxy {
145 type Protocol = MockRebootControllerMarker;
146
147 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
148 Self::new(inner)
149 }
150
151 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
152 self.client.into_channel().map_err(|client| Self { client })
153 }
154
155 fn as_channel(&self) -> &::fidl::AsyncChannel {
156 self.client.as_channel()
157 }
158}
159
160impl MockRebootControllerProxy {
161 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
163 let protocol_name =
164 <MockRebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
165 Self { client: fidl::client::Client::new(channel, protocol_name) }
166 }
167
168 pub fn take_event_stream(&self) -> MockRebootControllerEventStream {
174 MockRebootControllerEventStream { event_receiver: self.client.take_event_receiver() }
175 }
176
177 pub fn r#trigger_reboot(
178 &self,
179 ) -> fidl::client::QueryResponseFut<
180 MockRebootControllerTriggerRebootResult,
181 fidl::encoding::DefaultFuchsiaResourceDialect,
182 > {
183 MockRebootControllerProxyInterface::r#trigger_reboot(self)
184 }
185
186 pub fn r#crash_reboot_channel(
187 &self,
188 ) -> fidl::client::QueryResponseFut<
189 MockRebootControllerCrashRebootChannelResult,
190 fidl::encoding::DefaultFuchsiaResourceDialect,
191 > {
192 MockRebootControllerProxyInterface::r#crash_reboot_channel(self)
193 }
194}
195
196impl MockRebootControllerProxyInterface for MockRebootControllerProxy {
197 type TriggerRebootResponseFut = fidl::client::QueryResponseFut<
198 MockRebootControllerTriggerRebootResult,
199 fidl::encoding::DefaultFuchsiaResourceDialect,
200 >;
201 fn r#trigger_reboot(&self) -> Self::TriggerRebootResponseFut {
202 fn _decode(
203 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
204 ) -> Result<MockRebootControllerTriggerRebootResult, fidl::Error> {
205 let _response = fidl::client::decode_transaction_body::<
206 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RebootError>,
207 fidl::encoding::DefaultFuchsiaResourceDialect,
208 0x5e2a61aa7f881d13,
209 >(_buf?)?;
210 Ok(_response.map(|x| x))
211 }
212 self.client.send_query_and_decode::<
213 fidl::encoding::EmptyPayload,
214 MockRebootControllerTriggerRebootResult,
215 >(
216 (),
217 0x5e2a61aa7f881d13,
218 fidl::encoding::DynamicFlags::empty(),
219 _decode,
220 )
221 }
222
223 type CrashRebootChannelResponseFut = fidl::client::QueryResponseFut<
224 MockRebootControllerCrashRebootChannelResult,
225 fidl::encoding::DefaultFuchsiaResourceDialect,
226 >;
227 fn r#crash_reboot_channel(&self) -> Self::CrashRebootChannelResponseFut {
228 fn _decode(
229 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
230 ) -> Result<MockRebootControllerCrashRebootChannelResult, fidl::Error> {
231 let _response = fidl::client::decode_transaction_body::<
232 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RebootError>,
233 fidl::encoding::DefaultFuchsiaResourceDialect,
234 0x7d42f63d8d9ec3c3,
235 >(_buf?)?;
236 Ok(_response.map(|x| x))
237 }
238 self.client.send_query_and_decode::<
239 fidl::encoding::EmptyPayload,
240 MockRebootControllerCrashRebootChannelResult,
241 >(
242 (),
243 0x7d42f63d8d9ec3c3,
244 fidl::encoding::DynamicFlags::empty(),
245 _decode,
246 )
247 }
248}
249
250pub struct MockRebootControllerEventStream {
251 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
252}
253
254impl std::marker::Unpin for MockRebootControllerEventStream {}
255
256impl futures::stream::FusedStream for MockRebootControllerEventStream {
257 fn is_terminated(&self) -> bool {
258 self.event_receiver.is_terminated()
259 }
260}
261
262impl futures::Stream for MockRebootControllerEventStream {
263 type Item = Result<MockRebootControllerEvent, fidl::Error>;
264
265 fn poll_next(
266 mut self: std::pin::Pin<&mut Self>,
267 cx: &mut std::task::Context<'_>,
268 ) -> std::task::Poll<Option<Self::Item>> {
269 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
270 &mut self.event_receiver,
271 cx
272 )?) {
273 Some(buf) => std::task::Poll::Ready(Some(MockRebootControllerEvent::decode(buf))),
274 None => std::task::Poll::Ready(None),
275 }
276 }
277}
278
279#[derive(Debug)]
280pub enum MockRebootControllerEvent {}
281
282impl MockRebootControllerEvent {
283 fn decode(
285 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
286 ) -> Result<MockRebootControllerEvent, fidl::Error> {
287 let (bytes, _handles) = buf.split_mut();
288 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
289 debug_assert_eq!(tx_header.tx_id, 0);
290 match tx_header.ordinal {
291 _ => Err(fidl::Error::UnknownOrdinal {
292 ordinal: tx_header.ordinal,
293 protocol_name:
294 <MockRebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295 }),
296 }
297 }
298}
299
300pub struct MockRebootControllerRequestStream {
302 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303 is_terminated: bool,
304}
305
306impl std::marker::Unpin for MockRebootControllerRequestStream {}
307
308impl futures::stream::FusedStream for MockRebootControllerRequestStream {
309 fn is_terminated(&self) -> bool {
310 self.is_terminated
311 }
312}
313
314impl fidl::endpoints::RequestStream for MockRebootControllerRequestStream {
315 type Protocol = MockRebootControllerMarker;
316 type ControlHandle = MockRebootControllerControlHandle;
317
318 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
319 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
320 }
321
322 fn control_handle(&self) -> Self::ControlHandle {
323 MockRebootControllerControlHandle { inner: self.inner.clone() }
324 }
325
326 fn into_inner(
327 self,
328 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
329 {
330 (self.inner, self.is_terminated)
331 }
332
333 fn from_inner(
334 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335 is_terminated: bool,
336 ) -> Self {
337 Self { inner, is_terminated }
338 }
339}
340
341impl futures::Stream for MockRebootControllerRequestStream {
342 type Item = Result<MockRebootControllerRequest, fidl::Error>;
343
344 fn poll_next(
345 mut self: std::pin::Pin<&mut Self>,
346 cx: &mut std::task::Context<'_>,
347 ) -> std::task::Poll<Option<Self::Item>> {
348 let this = &mut *self;
349 if this.inner.check_shutdown(cx) {
350 this.is_terminated = true;
351 return std::task::Poll::Ready(None);
352 }
353 if this.is_terminated {
354 panic!("polled MockRebootControllerRequestStream after completion");
355 }
356 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
357 |bytes, handles| {
358 match this.inner.channel().read_etc(cx, bytes, handles) {
359 std::task::Poll::Ready(Ok(())) => {}
360 std::task::Poll::Pending => return std::task::Poll::Pending,
361 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
362 this.is_terminated = true;
363 return std::task::Poll::Ready(None);
364 }
365 std::task::Poll::Ready(Err(e)) => {
366 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
367 e.into(),
368 ))))
369 }
370 }
371
372 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375 std::task::Poll::Ready(Some(match header.ordinal {
376 0x5e2a61aa7f881d13 => {
377 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
378 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
379 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
380 let control_handle = MockRebootControllerControlHandle {
381 inner: this.inner.clone(),
382 };
383 Ok(MockRebootControllerRequest::TriggerReboot {
384 responder: MockRebootControllerTriggerRebootResponder {
385 control_handle: std::mem::ManuallyDrop::new(control_handle),
386 tx_id: header.tx_id,
387 },
388 })
389 }
390 0x7d42f63d8d9ec3c3 => {
391 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
392 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
393 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
394 let control_handle = MockRebootControllerControlHandle {
395 inner: this.inner.clone(),
396 };
397 Ok(MockRebootControllerRequest::CrashRebootChannel {
398 responder: MockRebootControllerCrashRebootChannelResponder {
399 control_handle: std::mem::ManuallyDrop::new(control_handle),
400 tx_id: header.tx_id,
401 },
402 })
403 }
404 _ => Err(fidl::Error::UnknownOrdinal {
405 ordinal: header.ordinal,
406 protocol_name: <MockRebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
407 }),
408 }))
409 },
410 )
411 }
412}
413
414#[derive(Debug)]
415pub enum MockRebootControllerRequest {
416 TriggerReboot { responder: MockRebootControllerTriggerRebootResponder },
417 CrashRebootChannel { responder: MockRebootControllerCrashRebootChannelResponder },
418}
419
420impl MockRebootControllerRequest {
421 #[allow(irrefutable_let_patterns)]
422 pub fn into_trigger_reboot(self) -> Option<(MockRebootControllerTriggerRebootResponder)> {
423 if let MockRebootControllerRequest::TriggerReboot { responder } = self {
424 Some((responder))
425 } else {
426 None
427 }
428 }
429
430 #[allow(irrefutable_let_patterns)]
431 pub fn into_crash_reboot_channel(
432 self,
433 ) -> Option<(MockRebootControllerCrashRebootChannelResponder)> {
434 if let MockRebootControllerRequest::CrashRebootChannel { responder } = self {
435 Some((responder))
436 } else {
437 None
438 }
439 }
440
441 pub fn method_name(&self) -> &'static str {
443 match *self {
444 MockRebootControllerRequest::TriggerReboot { .. } => "trigger_reboot",
445 MockRebootControllerRequest::CrashRebootChannel { .. } => "crash_reboot_channel",
446 }
447 }
448}
449
450#[derive(Debug, Clone)]
451pub struct MockRebootControllerControlHandle {
452 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
453}
454
455impl fidl::endpoints::ControlHandle for MockRebootControllerControlHandle {
456 fn shutdown(&self) {
457 self.inner.shutdown()
458 }
459 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
460 self.inner.shutdown_with_epitaph(status)
461 }
462
463 fn is_closed(&self) -> bool {
464 self.inner.channel().is_closed()
465 }
466 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
467 self.inner.channel().on_closed()
468 }
469
470 #[cfg(target_os = "fuchsia")]
471 fn signal_peer(
472 &self,
473 clear_mask: zx::Signals,
474 set_mask: zx::Signals,
475 ) -> Result<(), zx_status::Status> {
476 use fidl::Peered;
477 self.inner.channel().signal_peer(clear_mask, set_mask)
478 }
479}
480
481impl MockRebootControllerControlHandle {}
482
483#[must_use = "FIDL methods require a response to be sent"]
484#[derive(Debug)]
485pub struct MockRebootControllerTriggerRebootResponder {
486 control_handle: std::mem::ManuallyDrop<MockRebootControllerControlHandle>,
487 tx_id: u32,
488}
489
490impl std::ops::Drop for MockRebootControllerTriggerRebootResponder {
494 fn drop(&mut self) {
495 self.control_handle.shutdown();
496 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
498 }
499}
500
501impl fidl::endpoints::Responder for MockRebootControllerTriggerRebootResponder {
502 type ControlHandle = MockRebootControllerControlHandle;
503
504 fn control_handle(&self) -> &MockRebootControllerControlHandle {
505 &self.control_handle
506 }
507
508 fn drop_without_shutdown(mut self) {
509 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
511 std::mem::forget(self);
513 }
514}
515
516impl MockRebootControllerTriggerRebootResponder {
517 pub fn send(self, mut result: Result<(), RebootError>) -> Result<(), fidl::Error> {
521 let _result = self.send_raw(result);
522 if _result.is_err() {
523 self.control_handle.shutdown();
524 }
525 self.drop_without_shutdown();
526 _result
527 }
528
529 pub fn send_no_shutdown_on_err(
531 self,
532 mut result: Result<(), RebootError>,
533 ) -> Result<(), fidl::Error> {
534 let _result = self.send_raw(result);
535 self.drop_without_shutdown();
536 _result
537 }
538
539 fn send_raw(&self, mut result: Result<(), RebootError>) -> Result<(), fidl::Error> {
540 self.control_handle.inner.send::<fidl::encoding::ResultType<
541 fidl::encoding::EmptyStruct,
542 RebootError,
543 >>(
544 result,
545 self.tx_id,
546 0x5e2a61aa7f881d13,
547 fidl::encoding::DynamicFlags::empty(),
548 )
549 }
550}
551
552#[must_use = "FIDL methods require a response to be sent"]
553#[derive(Debug)]
554pub struct MockRebootControllerCrashRebootChannelResponder {
555 control_handle: std::mem::ManuallyDrop<MockRebootControllerControlHandle>,
556 tx_id: u32,
557}
558
559impl std::ops::Drop for MockRebootControllerCrashRebootChannelResponder {
563 fn drop(&mut self) {
564 self.control_handle.shutdown();
565 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
567 }
568}
569
570impl fidl::endpoints::Responder for MockRebootControllerCrashRebootChannelResponder {
571 type ControlHandle = MockRebootControllerControlHandle;
572
573 fn control_handle(&self) -> &MockRebootControllerControlHandle {
574 &self.control_handle
575 }
576
577 fn drop_without_shutdown(mut self) {
578 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
580 std::mem::forget(self);
582 }
583}
584
585impl MockRebootControllerCrashRebootChannelResponder {
586 pub fn send(self, mut result: Result<(), RebootError>) -> Result<(), fidl::Error> {
590 let _result = self.send_raw(result);
591 if _result.is_err() {
592 self.control_handle.shutdown();
593 }
594 self.drop_without_shutdown();
595 _result
596 }
597
598 pub fn send_no_shutdown_on_err(
600 self,
601 mut result: Result<(), RebootError>,
602 ) -> Result<(), fidl::Error> {
603 let _result = self.send_raw(result);
604 self.drop_without_shutdown();
605 _result
606 }
607
608 fn send_raw(&self, mut result: Result<(), RebootError>) -> Result<(), fidl::Error> {
609 self.control_handle.inner.send::<fidl::encoding::ResultType<
610 fidl::encoding::EmptyStruct,
611 RebootError,
612 >>(
613 result,
614 self.tx_id,
615 0x7d42f63d8d9ec3c3,
616 fidl::encoding::DynamicFlags::empty(),
617 )
618 }
619}
620
621mod internal {
622 use super::*;
623}