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_recovery_policy_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18 type Proxy = DeviceProxy;
19 type RequestStream = DeviceRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DeviceSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.recovery.policy.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26
27pub trait DeviceProxyInterface: Send + Sync {
28 fn r#set_is_local_reset_allowed(&self, allowed: bool) -> Result<(), fidl::Error>;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct DeviceSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
38 type Proxy = DeviceProxy;
39 type Protocol = DeviceMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl DeviceSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 Self { client: fidl::client::sync::Client::new(channel) }
58 }
59
60 pub fn into_channel(self) -> fidl::Channel {
61 self.client.into_channel()
62 }
63
64 pub fn wait_for_event(
67 &self,
68 deadline: zx::MonotonicInstant,
69 ) -> Result<DeviceEvent, fidl::Error> {
70 DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
71 }
72
73 pub fn r#set_is_local_reset_allowed(&self, mut allowed: bool) -> Result<(), fidl::Error> {
78 self.client.send::<DeviceSetIsLocalResetAllowedRequest>(
79 (allowed,),
80 0x7a0343d0fccb7ac7,
81 fidl::encoding::DynamicFlags::empty(),
82 )
83 }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl From<DeviceSynchronousProxy> for zx::NullableHandle {
88 fn from(value: DeviceSynchronousProxy) -> Self {
89 value.into_channel().into()
90 }
91}
92
93#[cfg(target_os = "fuchsia")]
94impl From<fidl::Channel> for DeviceSynchronousProxy {
95 fn from(value: fidl::Channel) -> Self {
96 Self::new(value)
97 }
98}
99
100#[cfg(target_os = "fuchsia")]
101impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
102 type Protocol = DeviceMarker;
103
104 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
105 Self::new(value.into_channel())
106 }
107}
108
109#[derive(Debug, Clone)]
110pub struct DeviceProxy {
111 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
112}
113
114impl fidl::endpoints::Proxy for DeviceProxy {
115 type Protocol = DeviceMarker;
116
117 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
118 Self::new(inner)
119 }
120
121 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
122 self.client.into_channel().map_err(|client| Self { client })
123 }
124
125 fn as_channel(&self) -> &::fidl::AsyncChannel {
126 self.client.as_channel()
127 }
128}
129
130impl DeviceProxy {
131 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
133 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
134 Self { client: fidl::client::Client::new(channel, protocol_name) }
135 }
136
137 pub fn take_event_stream(&self) -> DeviceEventStream {
143 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
144 }
145
146 pub fn r#set_is_local_reset_allowed(&self, mut allowed: bool) -> Result<(), fidl::Error> {
151 DeviceProxyInterface::r#set_is_local_reset_allowed(self, allowed)
152 }
153}
154
155impl DeviceProxyInterface for DeviceProxy {
156 fn r#set_is_local_reset_allowed(&self, mut allowed: bool) -> Result<(), fidl::Error> {
157 self.client.send::<DeviceSetIsLocalResetAllowedRequest>(
158 (allowed,),
159 0x7a0343d0fccb7ac7,
160 fidl::encoding::DynamicFlags::empty(),
161 )
162 }
163}
164
165pub struct DeviceEventStream {
166 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
167}
168
169impl std::marker::Unpin for DeviceEventStream {}
170
171impl futures::stream::FusedStream for DeviceEventStream {
172 fn is_terminated(&self) -> bool {
173 self.event_receiver.is_terminated()
174 }
175}
176
177impl futures::Stream for DeviceEventStream {
178 type Item = Result<DeviceEvent, fidl::Error>;
179
180 fn poll_next(
181 mut self: std::pin::Pin<&mut Self>,
182 cx: &mut std::task::Context<'_>,
183 ) -> std::task::Poll<Option<Self::Item>> {
184 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
185 &mut self.event_receiver,
186 cx
187 )?) {
188 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
189 None => std::task::Poll::Ready(None),
190 }
191 }
192}
193
194#[derive(Debug)]
195pub enum DeviceEvent {}
196
197impl DeviceEvent {
198 fn decode(
200 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
201 ) -> Result<DeviceEvent, fidl::Error> {
202 let (bytes, _handles) = buf.split_mut();
203 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
204 debug_assert_eq!(tx_header.tx_id, 0);
205 match tx_header.ordinal {
206 _ => Err(fidl::Error::UnknownOrdinal {
207 ordinal: tx_header.ordinal,
208 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
209 }),
210 }
211 }
212}
213
214pub struct DeviceRequestStream {
216 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
217 is_terminated: bool,
218}
219
220impl std::marker::Unpin for DeviceRequestStream {}
221
222impl futures::stream::FusedStream for DeviceRequestStream {
223 fn is_terminated(&self) -> bool {
224 self.is_terminated
225 }
226}
227
228impl fidl::endpoints::RequestStream for DeviceRequestStream {
229 type Protocol = DeviceMarker;
230 type ControlHandle = DeviceControlHandle;
231
232 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
233 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
234 }
235
236 fn control_handle(&self) -> Self::ControlHandle {
237 DeviceControlHandle { inner: self.inner.clone() }
238 }
239
240 fn into_inner(
241 self,
242 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
243 {
244 (self.inner, self.is_terminated)
245 }
246
247 fn from_inner(
248 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
249 is_terminated: bool,
250 ) -> Self {
251 Self { inner, is_terminated }
252 }
253}
254
255impl futures::Stream for DeviceRequestStream {
256 type Item = Result<DeviceRequest, fidl::Error>;
257
258 fn poll_next(
259 mut self: std::pin::Pin<&mut Self>,
260 cx: &mut std::task::Context<'_>,
261 ) -> std::task::Poll<Option<Self::Item>> {
262 let this = &mut *self;
263 if this.inner.check_shutdown(cx) {
264 this.is_terminated = true;
265 return std::task::Poll::Ready(None);
266 }
267 if this.is_terminated {
268 panic!("polled DeviceRequestStream after completion");
269 }
270 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
271 |bytes, handles| {
272 match this.inner.channel().read_etc(cx, bytes, handles) {
273 std::task::Poll::Ready(Ok(())) => {}
274 std::task::Poll::Pending => return std::task::Poll::Pending,
275 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
276 this.is_terminated = true;
277 return std::task::Poll::Ready(None);
278 }
279 std::task::Poll::Ready(Err(e)) => {
280 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
281 e.into(),
282 ))));
283 }
284 }
285
286 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
288
289 std::task::Poll::Ready(Some(match header.ordinal {
290 0x7a0343d0fccb7ac7 => {
291 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
292 let mut req = fidl::new_empty!(
293 DeviceSetIsLocalResetAllowedRequest,
294 fidl::encoding::DefaultFuchsiaResourceDialect
295 );
296 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetIsLocalResetAllowedRequest>(&header, _body_bytes, handles, &mut req)?;
297 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
298 Ok(DeviceRequest::SetIsLocalResetAllowed {
299 allowed: req.allowed,
300
301 control_handle,
302 })
303 }
304 _ => Err(fidl::Error::UnknownOrdinal {
305 ordinal: header.ordinal,
306 protocol_name:
307 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
308 }),
309 }))
310 },
311 )
312 }
313}
314
315#[derive(Debug)]
320pub enum DeviceRequest {
321 SetIsLocalResetAllowed { allowed: bool, control_handle: DeviceControlHandle },
326}
327
328impl DeviceRequest {
329 #[allow(irrefutable_let_patterns)]
330 pub fn into_set_is_local_reset_allowed(self) -> Option<(bool, DeviceControlHandle)> {
331 if let DeviceRequest::SetIsLocalResetAllowed { allowed, control_handle } = self {
332 Some((allowed, control_handle))
333 } else {
334 None
335 }
336 }
337
338 pub fn method_name(&self) -> &'static str {
340 match *self {
341 DeviceRequest::SetIsLocalResetAllowed { .. } => "set_is_local_reset_allowed",
342 }
343 }
344}
345
346#[derive(Debug, Clone)]
347pub struct DeviceControlHandle {
348 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
349}
350
351impl DeviceControlHandle {
352 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
353 self.inner.shutdown_with_epitaph(status.into())
354 }
355}
356
357impl fidl::endpoints::ControlHandle for DeviceControlHandle {
358 fn shutdown(&self) {
359 self.inner.shutdown()
360 }
361
362 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
363 self.inner.shutdown_with_epitaph(status)
364 }
365
366 fn is_closed(&self) -> bool {
367 self.inner.channel().is_closed()
368 }
369 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
370 self.inner.channel().on_closed()
371 }
372
373 #[cfg(target_os = "fuchsia")]
374 fn signal_peer(
375 &self,
376 clear_mask: zx::Signals,
377 set_mask: zx::Signals,
378 ) -> Result<(), zx_status::Status> {
379 use fidl::Peered;
380 self.inner.channel().signal_peer(clear_mask, set_mask)
381 }
382}
383
384impl DeviceControlHandle {}
385
386#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
387pub struct FactoryResetMarker;
388
389impl fidl::endpoints::ProtocolMarker for FactoryResetMarker {
390 type Proxy = FactoryResetProxy;
391 type RequestStream = FactoryResetRequestStream;
392 #[cfg(target_os = "fuchsia")]
393 type SynchronousProxy = FactoryResetSynchronousProxy;
394
395 const DEBUG_NAME: &'static str = "fuchsia.recovery.policy.FactoryReset";
396}
397impl fidl::endpoints::DiscoverableProtocolMarker for FactoryResetMarker {}
398
399pub trait FactoryResetProxyInterface: Send + Sync {
400 type GetEnabledResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
401 fn r#get_enabled(&self) -> Self::GetEnabledResponseFut;
402}
403#[derive(Debug)]
404#[cfg(target_os = "fuchsia")]
405pub struct FactoryResetSynchronousProxy {
406 client: fidl::client::sync::Client,
407}
408
409#[cfg(target_os = "fuchsia")]
410impl fidl::endpoints::SynchronousProxy for FactoryResetSynchronousProxy {
411 type Proxy = FactoryResetProxy;
412 type Protocol = FactoryResetMarker;
413
414 fn from_channel(inner: fidl::Channel) -> Self {
415 Self::new(inner)
416 }
417
418 fn into_channel(self) -> fidl::Channel {
419 self.client.into_channel()
420 }
421
422 fn as_channel(&self) -> &fidl::Channel {
423 self.client.as_channel()
424 }
425}
426
427#[cfg(target_os = "fuchsia")]
428impl FactoryResetSynchronousProxy {
429 pub fn new(channel: fidl::Channel) -> Self {
430 Self { client: fidl::client::sync::Client::new(channel) }
431 }
432
433 pub fn into_channel(self) -> fidl::Channel {
434 self.client.into_channel()
435 }
436
437 pub fn wait_for_event(
440 &self,
441 deadline: zx::MonotonicInstant,
442 ) -> Result<FactoryResetEvent, fidl::Error> {
443 FactoryResetEvent::decode(self.client.wait_for_event::<FactoryResetMarker>(deadline)?)
444 }
445
446 pub fn r#get_enabled(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
449 let _response = self.client.send_query::<
450 fidl::encoding::EmptyPayload,
451 FactoryResetGetEnabledResponse,
452 FactoryResetMarker,
453 >(
454 (),
455 0x46b4c73b3d6be123,
456 fidl::encoding::DynamicFlags::empty(),
457 ___deadline,
458 )?;
459 Ok(_response.fdr_enabled)
460 }
461}
462
463#[cfg(target_os = "fuchsia")]
464impl From<FactoryResetSynchronousProxy> for zx::NullableHandle {
465 fn from(value: FactoryResetSynchronousProxy) -> Self {
466 value.into_channel().into()
467 }
468}
469
470#[cfg(target_os = "fuchsia")]
471impl From<fidl::Channel> for FactoryResetSynchronousProxy {
472 fn from(value: fidl::Channel) -> Self {
473 Self::new(value)
474 }
475}
476
477#[cfg(target_os = "fuchsia")]
478impl fidl::endpoints::FromClient for FactoryResetSynchronousProxy {
479 type Protocol = FactoryResetMarker;
480
481 fn from_client(value: fidl::endpoints::ClientEnd<FactoryResetMarker>) -> Self {
482 Self::new(value.into_channel())
483 }
484}
485
486#[derive(Debug, Clone)]
487pub struct FactoryResetProxy {
488 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
489}
490
491impl fidl::endpoints::Proxy for FactoryResetProxy {
492 type Protocol = FactoryResetMarker;
493
494 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
495 Self::new(inner)
496 }
497
498 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
499 self.client.into_channel().map_err(|client| Self { client })
500 }
501
502 fn as_channel(&self) -> &::fidl::AsyncChannel {
503 self.client.as_channel()
504 }
505}
506
507impl FactoryResetProxy {
508 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
510 let protocol_name = <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
511 Self { client: fidl::client::Client::new(channel, protocol_name) }
512 }
513
514 pub fn take_event_stream(&self) -> FactoryResetEventStream {
520 FactoryResetEventStream { event_receiver: self.client.take_event_receiver() }
521 }
522
523 pub fn r#get_enabled(
526 &self,
527 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
528 FactoryResetProxyInterface::r#get_enabled(self)
529 }
530}
531
532impl FactoryResetProxyInterface for FactoryResetProxy {
533 type GetEnabledResponseFut =
534 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
535 fn r#get_enabled(&self) -> Self::GetEnabledResponseFut {
536 fn _decode(
537 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
538 ) -> Result<bool, fidl::Error> {
539 let _response = fidl::client::decode_transaction_body::<
540 FactoryResetGetEnabledResponse,
541 fidl::encoding::DefaultFuchsiaResourceDialect,
542 0x46b4c73b3d6be123,
543 >(_buf?)?;
544 Ok(_response.fdr_enabled)
545 }
546 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
547 (),
548 0x46b4c73b3d6be123,
549 fidl::encoding::DynamicFlags::empty(),
550 _decode,
551 )
552 }
553}
554
555pub struct FactoryResetEventStream {
556 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
557}
558
559impl std::marker::Unpin for FactoryResetEventStream {}
560
561impl futures::stream::FusedStream for FactoryResetEventStream {
562 fn is_terminated(&self) -> bool {
563 self.event_receiver.is_terminated()
564 }
565}
566
567impl futures::Stream for FactoryResetEventStream {
568 type Item = Result<FactoryResetEvent, fidl::Error>;
569
570 fn poll_next(
571 mut self: std::pin::Pin<&mut Self>,
572 cx: &mut std::task::Context<'_>,
573 ) -> std::task::Poll<Option<Self::Item>> {
574 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
575 &mut self.event_receiver,
576 cx
577 )?) {
578 Some(buf) => std::task::Poll::Ready(Some(FactoryResetEvent::decode(buf))),
579 None => std::task::Poll::Ready(None),
580 }
581 }
582}
583
584#[derive(Debug)]
585pub enum FactoryResetEvent {}
586
587impl FactoryResetEvent {
588 fn decode(
590 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
591 ) -> Result<FactoryResetEvent, fidl::Error> {
592 let (bytes, _handles) = buf.split_mut();
593 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
594 debug_assert_eq!(tx_header.tx_id, 0);
595 match tx_header.ordinal {
596 _ => Err(fidl::Error::UnknownOrdinal {
597 ordinal: tx_header.ordinal,
598 protocol_name: <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
599 }),
600 }
601 }
602}
603
604pub struct FactoryResetRequestStream {
606 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
607 is_terminated: bool,
608}
609
610impl std::marker::Unpin for FactoryResetRequestStream {}
611
612impl futures::stream::FusedStream for FactoryResetRequestStream {
613 fn is_terminated(&self) -> bool {
614 self.is_terminated
615 }
616}
617
618impl fidl::endpoints::RequestStream for FactoryResetRequestStream {
619 type Protocol = FactoryResetMarker;
620 type ControlHandle = FactoryResetControlHandle;
621
622 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
623 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
624 }
625
626 fn control_handle(&self) -> Self::ControlHandle {
627 FactoryResetControlHandle { inner: self.inner.clone() }
628 }
629
630 fn into_inner(
631 self,
632 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
633 {
634 (self.inner, self.is_terminated)
635 }
636
637 fn from_inner(
638 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
639 is_terminated: bool,
640 ) -> Self {
641 Self { inner, is_terminated }
642 }
643}
644
645impl futures::Stream for FactoryResetRequestStream {
646 type Item = Result<FactoryResetRequest, fidl::Error>;
647
648 fn poll_next(
649 mut self: std::pin::Pin<&mut Self>,
650 cx: &mut std::task::Context<'_>,
651 ) -> std::task::Poll<Option<Self::Item>> {
652 let this = &mut *self;
653 if this.inner.check_shutdown(cx) {
654 this.is_terminated = true;
655 return std::task::Poll::Ready(None);
656 }
657 if this.is_terminated {
658 panic!("polled FactoryResetRequestStream after completion");
659 }
660 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
661 |bytes, handles| {
662 match this.inner.channel().read_etc(cx, bytes, handles) {
663 std::task::Poll::Ready(Ok(())) => {}
664 std::task::Poll::Pending => return std::task::Poll::Pending,
665 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
666 this.is_terminated = true;
667 return std::task::Poll::Ready(None);
668 }
669 std::task::Poll::Ready(Err(e)) => {
670 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
671 e.into(),
672 ))));
673 }
674 }
675
676 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
678
679 std::task::Poll::Ready(Some(match header.ordinal {
680 0x46b4c73b3d6be123 => {
681 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
682 let mut req = fidl::new_empty!(
683 fidl::encoding::EmptyPayload,
684 fidl::encoding::DefaultFuchsiaResourceDialect
685 );
686 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
687 let control_handle =
688 FactoryResetControlHandle { inner: this.inner.clone() };
689 Ok(FactoryResetRequest::GetEnabled {
690 responder: FactoryResetGetEnabledResponder {
691 control_handle: std::mem::ManuallyDrop::new(control_handle),
692 tx_id: header.tx_id,
693 },
694 })
695 }
696 _ => Err(fidl::Error::UnknownOrdinal {
697 ordinal: header.ordinal,
698 protocol_name:
699 <FactoryResetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
700 }),
701 }))
702 },
703 )
704 }
705}
706
707#[derive(Debug)]
709pub enum FactoryResetRequest {
710 GetEnabled { responder: FactoryResetGetEnabledResponder },
713}
714
715impl FactoryResetRequest {
716 #[allow(irrefutable_let_patterns)]
717 pub fn into_get_enabled(self) -> Option<(FactoryResetGetEnabledResponder)> {
718 if let FactoryResetRequest::GetEnabled { responder } = self {
719 Some((responder))
720 } else {
721 None
722 }
723 }
724
725 pub fn method_name(&self) -> &'static str {
727 match *self {
728 FactoryResetRequest::GetEnabled { .. } => "get_enabled",
729 }
730 }
731}
732
733#[derive(Debug, Clone)]
734pub struct FactoryResetControlHandle {
735 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
736}
737
738impl FactoryResetControlHandle {
739 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
740 self.inner.shutdown_with_epitaph(status.into())
741 }
742}
743
744impl fidl::endpoints::ControlHandle for FactoryResetControlHandle {
745 fn shutdown(&self) {
746 self.inner.shutdown()
747 }
748
749 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
750 self.inner.shutdown_with_epitaph(status)
751 }
752
753 fn is_closed(&self) -> bool {
754 self.inner.channel().is_closed()
755 }
756 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
757 self.inner.channel().on_closed()
758 }
759
760 #[cfg(target_os = "fuchsia")]
761 fn signal_peer(
762 &self,
763 clear_mask: zx::Signals,
764 set_mask: zx::Signals,
765 ) -> Result<(), zx_status::Status> {
766 use fidl::Peered;
767 self.inner.channel().signal_peer(clear_mask, set_mask)
768 }
769}
770
771impl FactoryResetControlHandle {}
772
773#[must_use = "FIDL methods require a response to be sent"]
774#[derive(Debug)]
775pub struct FactoryResetGetEnabledResponder {
776 control_handle: std::mem::ManuallyDrop<FactoryResetControlHandle>,
777 tx_id: u32,
778}
779
780impl std::ops::Drop for FactoryResetGetEnabledResponder {
784 fn drop(&mut self) {
785 self.control_handle.shutdown();
786 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788 }
789}
790
791impl fidl::endpoints::Responder for FactoryResetGetEnabledResponder {
792 type ControlHandle = FactoryResetControlHandle;
793
794 fn control_handle(&self) -> &FactoryResetControlHandle {
795 &self.control_handle
796 }
797
798 fn drop_without_shutdown(mut self) {
799 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801 std::mem::forget(self);
803 }
804}
805
806impl FactoryResetGetEnabledResponder {
807 pub fn send(self, mut fdr_enabled: bool) -> Result<(), fidl::Error> {
811 let _result = self.send_raw(fdr_enabled);
812 if _result.is_err() {
813 self.control_handle.shutdown();
814 }
815 self.drop_without_shutdown();
816 _result
817 }
818
819 pub fn send_no_shutdown_on_err(self, mut fdr_enabled: bool) -> Result<(), fidl::Error> {
821 let _result = self.send_raw(fdr_enabled);
822 self.drop_without_shutdown();
823 _result
824 }
825
826 fn send_raw(&self, mut fdr_enabled: bool) -> Result<(), fidl::Error> {
827 self.control_handle.inner.send::<FactoryResetGetEnabledResponse>(
828 (fdr_enabled,),
829 self.tx_id,
830 0x46b4c73b3d6be123,
831 fidl::encoding::DynamicFlags::empty(),
832 )
833 }
834}
835
836mod internal {
837 use super::*;
838}