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