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_power__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct CollaborativeRebootInitiatorMarker;
16
17impl fidl::endpoints::ProtocolMarker for CollaborativeRebootInitiatorMarker {
18 type Proxy = CollaborativeRebootInitiatorProxy;
19 type RequestStream = CollaborativeRebootInitiatorRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = CollaborativeRebootInitiatorSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.power.CollaborativeRebootInitiator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for CollaborativeRebootInitiatorMarker {}
26
27pub trait CollaborativeRebootInitiatorProxyInterface: Send + Sync {
28 type PerformPendingRebootResponseFut: std::future::Future<
29 Output = Result<CollaborativeRebootInitiatorPerformPendingRebootResponse, fidl::Error>,
30 > + Send;
31 fn r#perform_pending_reboot(&self) -> Self::PerformPendingRebootResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct CollaborativeRebootInitiatorSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for CollaborativeRebootInitiatorSynchronousProxy {
41 type Proxy = CollaborativeRebootInitiatorProxy;
42 type Protocol = CollaborativeRebootInitiatorMarker;
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 CollaborativeRebootInitiatorSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 Self { client: fidl::client::sync::Client::new(channel) }
61 }
62
63 pub fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 pub fn wait_for_event(
70 &self,
71 deadline: zx::MonotonicInstant,
72 ) -> Result<CollaborativeRebootInitiatorEvent, fidl::Error> {
73 CollaborativeRebootInitiatorEvent::decode(
74 self.client.wait_for_event::<CollaborativeRebootInitiatorMarker>(deadline)?,
75 )
76 }
77
78 pub fn r#perform_pending_reboot(
88 &self,
89 ___deadline: zx::MonotonicInstant,
90 ) -> Result<CollaborativeRebootInitiatorPerformPendingRebootResponse, fidl::Error> {
91 let _response = self.client.send_query::<
92 fidl::encoding::EmptyPayload,
93 CollaborativeRebootInitiatorPerformPendingRebootResponse,
94 CollaborativeRebootInitiatorMarker,
95 >(
96 (),
97 0x6114c8f94a98f492,
98 fidl::encoding::DynamicFlags::empty(),
99 ___deadline,
100 )?;
101 Ok(_response)
102 }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<CollaborativeRebootInitiatorSynchronousProxy> for zx::NullableHandle {
107 fn from(value: CollaborativeRebootInitiatorSynchronousProxy) -> Self {
108 value.into_channel().into()
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<fidl::Channel> for CollaborativeRebootInitiatorSynchronousProxy {
114 fn from(value: fidl::Channel) -> Self {
115 Self::new(value)
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::FromClient for CollaborativeRebootInitiatorSynchronousProxy {
121 type Protocol = CollaborativeRebootInitiatorMarker;
122
123 fn from_client(value: fidl::endpoints::ClientEnd<CollaborativeRebootInitiatorMarker>) -> Self {
124 Self::new(value.into_channel())
125 }
126}
127
128#[derive(Debug, Clone)]
129pub struct CollaborativeRebootInitiatorProxy {
130 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
131}
132
133impl fidl::endpoints::Proxy for CollaborativeRebootInitiatorProxy {
134 type Protocol = CollaborativeRebootInitiatorMarker;
135
136 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
137 Self::new(inner)
138 }
139
140 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
141 self.client.into_channel().map_err(|client| Self { client })
142 }
143
144 fn as_channel(&self) -> &::fidl::AsyncChannel {
145 self.client.as_channel()
146 }
147}
148
149impl CollaborativeRebootInitiatorProxy {
150 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
152 let protocol_name =
153 <CollaborativeRebootInitiatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
154 Self { client: fidl::client::Client::new(channel, protocol_name) }
155 }
156
157 pub fn take_event_stream(&self) -> CollaborativeRebootInitiatorEventStream {
163 CollaborativeRebootInitiatorEventStream {
164 event_receiver: self.client.take_event_receiver(),
165 }
166 }
167
168 pub fn r#perform_pending_reboot(
178 &self,
179 ) -> fidl::client::QueryResponseFut<
180 CollaborativeRebootInitiatorPerformPendingRebootResponse,
181 fidl::encoding::DefaultFuchsiaResourceDialect,
182 > {
183 CollaborativeRebootInitiatorProxyInterface::r#perform_pending_reboot(self)
184 }
185}
186
187impl CollaborativeRebootInitiatorProxyInterface for CollaborativeRebootInitiatorProxy {
188 type PerformPendingRebootResponseFut = fidl::client::QueryResponseFut<
189 CollaborativeRebootInitiatorPerformPendingRebootResponse,
190 fidl::encoding::DefaultFuchsiaResourceDialect,
191 >;
192 fn r#perform_pending_reboot(&self) -> Self::PerformPendingRebootResponseFut {
193 fn _decode(
194 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
195 ) -> Result<CollaborativeRebootInitiatorPerformPendingRebootResponse, fidl::Error> {
196 let _response = fidl::client::decode_transaction_body::<
197 CollaborativeRebootInitiatorPerformPendingRebootResponse,
198 fidl::encoding::DefaultFuchsiaResourceDialect,
199 0x6114c8f94a98f492,
200 >(_buf?)?;
201 Ok(_response)
202 }
203 self.client.send_query_and_decode::<
204 fidl::encoding::EmptyPayload,
205 CollaborativeRebootInitiatorPerformPendingRebootResponse,
206 >(
207 (),
208 0x6114c8f94a98f492,
209 fidl::encoding::DynamicFlags::empty(),
210 _decode,
211 )
212 }
213}
214
215pub struct CollaborativeRebootInitiatorEventStream {
216 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl std::marker::Unpin for CollaborativeRebootInitiatorEventStream {}
220
221impl futures::stream::FusedStream for CollaborativeRebootInitiatorEventStream {
222 fn is_terminated(&self) -> bool {
223 self.event_receiver.is_terminated()
224 }
225}
226
227impl futures::Stream for CollaborativeRebootInitiatorEventStream {
228 type Item = Result<CollaborativeRebootInitiatorEvent, fidl::Error>;
229
230 fn poll_next(
231 mut self: std::pin::Pin<&mut Self>,
232 cx: &mut std::task::Context<'_>,
233 ) -> std::task::Poll<Option<Self::Item>> {
234 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
235 &mut self.event_receiver,
236 cx
237 )?) {
238 Some(buf) => {
239 std::task::Poll::Ready(Some(CollaborativeRebootInitiatorEvent::decode(buf)))
240 }
241 None => std::task::Poll::Ready(None),
242 }
243 }
244}
245
246#[derive(Debug)]
247pub enum CollaborativeRebootInitiatorEvent {}
248
249impl CollaborativeRebootInitiatorEvent {
250 fn decode(
252 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
253 ) -> Result<CollaborativeRebootInitiatorEvent, fidl::Error> {
254 let (bytes, _handles) = buf.split_mut();
255 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
256 debug_assert_eq!(tx_header.tx_id, 0);
257 match tx_header.ordinal {
258 _ => Err(fidl::Error::UnknownOrdinal {
259 ordinal: tx_header.ordinal,
260 protocol_name: <CollaborativeRebootInitiatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
261 })
262 }
263 }
264}
265
266pub struct CollaborativeRebootInitiatorRequestStream {
268 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
269 is_terminated: bool,
270}
271
272impl std::marker::Unpin for CollaborativeRebootInitiatorRequestStream {}
273
274impl futures::stream::FusedStream for CollaborativeRebootInitiatorRequestStream {
275 fn is_terminated(&self) -> bool {
276 self.is_terminated
277 }
278}
279
280impl fidl::endpoints::RequestStream for CollaborativeRebootInitiatorRequestStream {
281 type Protocol = CollaborativeRebootInitiatorMarker;
282 type ControlHandle = CollaborativeRebootInitiatorControlHandle;
283
284 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
285 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
286 }
287
288 fn control_handle(&self) -> Self::ControlHandle {
289 CollaborativeRebootInitiatorControlHandle { inner: self.inner.clone() }
290 }
291
292 fn into_inner(
293 self,
294 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
295 {
296 (self.inner, self.is_terminated)
297 }
298
299 fn from_inner(
300 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
301 is_terminated: bool,
302 ) -> Self {
303 Self { inner, is_terminated }
304 }
305}
306
307impl futures::Stream for CollaborativeRebootInitiatorRequestStream {
308 type Item = Result<CollaborativeRebootInitiatorRequest, fidl::Error>;
309
310 fn poll_next(
311 mut self: std::pin::Pin<&mut Self>,
312 cx: &mut std::task::Context<'_>,
313 ) -> std::task::Poll<Option<Self::Item>> {
314 let this = &mut *self;
315 if this.inner.check_shutdown(cx) {
316 this.is_terminated = true;
317 return std::task::Poll::Ready(None);
318 }
319 if this.is_terminated {
320 panic!("polled CollaborativeRebootInitiatorRequestStream after completion");
321 }
322 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
323 |bytes, handles| {
324 match this.inner.channel().read_etc(cx, bytes, handles) {
325 std::task::Poll::Ready(Ok(())) => {}
326 std::task::Poll::Pending => return std::task::Poll::Pending,
327 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
328 this.is_terminated = true;
329 return std::task::Poll::Ready(None);
330 }
331 std::task::Poll::Ready(Err(e)) => {
332 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
333 e.into(),
334 ))));
335 }
336 }
337
338 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
340
341 std::task::Poll::Ready(Some(match header.ordinal {
342 0x6114c8f94a98f492 => {
343 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
344 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
345 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
346 let control_handle = CollaborativeRebootInitiatorControlHandle {
347 inner: this.inner.clone(),
348 };
349 Ok(CollaborativeRebootInitiatorRequest::PerformPendingReboot {
350 responder: CollaborativeRebootInitiatorPerformPendingRebootResponder {
351 control_handle: std::mem::ManuallyDrop::new(control_handle),
352 tx_id: header.tx_id,
353 },
354 })
355 }
356 _ => Err(fidl::Error::UnknownOrdinal {
357 ordinal: header.ordinal,
358 protocol_name: <CollaborativeRebootInitiatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
359 }),
360 }))
361 },
362 )
363 }
364}
365
366#[derive(Debug)]
385pub enum CollaborativeRebootInitiatorRequest {
386 PerformPendingReboot { responder: CollaborativeRebootInitiatorPerformPendingRebootResponder },
396}
397
398impl CollaborativeRebootInitiatorRequest {
399 #[allow(irrefutable_let_patterns)]
400 pub fn into_perform_pending_reboot(
401 self,
402 ) -> Option<(CollaborativeRebootInitiatorPerformPendingRebootResponder)> {
403 if let CollaborativeRebootInitiatorRequest::PerformPendingReboot { responder } = self {
404 Some((responder))
405 } else {
406 None
407 }
408 }
409
410 pub fn method_name(&self) -> &'static str {
412 match *self {
413 CollaborativeRebootInitiatorRequest::PerformPendingReboot { .. } => {
414 "perform_pending_reboot"
415 }
416 }
417 }
418}
419
420#[derive(Debug, Clone)]
421pub struct CollaborativeRebootInitiatorControlHandle {
422 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
423}
424
425impl fidl::endpoints::ControlHandle for CollaborativeRebootInitiatorControlHandle {
426 fn shutdown(&self) {
427 self.inner.shutdown()
428 }
429
430 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
431 self.inner.shutdown_with_epitaph(status)
432 }
433
434 fn is_closed(&self) -> bool {
435 self.inner.channel().is_closed()
436 }
437 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
438 self.inner.channel().on_closed()
439 }
440
441 #[cfg(target_os = "fuchsia")]
442 fn signal_peer(
443 &self,
444 clear_mask: zx::Signals,
445 set_mask: zx::Signals,
446 ) -> Result<(), zx_status::Status> {
447 use fidl::Peered;
448 self.inner.channel().signal_peer(clear_mask, set_mask)
449 }
450}
451
452impl CollaborativeRebootInitiatorControlHandle {}
453
454#[must_use = "FIDL methods require a response to be sent"]
455#[derive(Debug)]
456pub struct CollaborativeRebootInitiatorPerformPendingRebootResponder {
457 control_handle: std::mem::ManuallyDrop<CollaborativeRebootInitiatorControlHandle>,
458 tx_id: u32,
459}
460
461impl std::ops::Drop for CollaborativeRebootInitiatorPerformPendingRebootResponder {
465 fn drop(&mut self) {
466 self.control_handle.shutdown();
467 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
469 }
470}
471
472impl fidl::endpoints::Responder for CollaborativeRebootInitiatorPerformPendingRebootResponder {
473 type ControlHandle = CollaborativeRebootInitiatorControlHandle;
474
475 fn control_handle(&self) -> &CollaborativeRebootInitiatorControlHandle {
476 &self.control_handle
477 }
478
479 fn drop_without_shutdown(mut self) {
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 std::mem::forget(self);
484 }
485}
486
487impl CollaborativeRebootInitiatorPerformPendingRebootResponder {
488 pub fn send(
492 self,
493 mut payload: &CollaborativeRebootInitiatorPerformPendingRebootResponse,
494 ) -> Result<(), fidl::Error> {
495 let _result = self.send_raw(payload);
496 if _result.is_err() {
497 self.control_handle.shutdown();
498 }
499 self.drop_without_shutdown();
500 _result
501 }
502
503 pub fn send_no_shutdown_on_err(
505 self,
506 mut payload: &CollaborativeRebootInitiatorPerformPendingRebootResponse,
507 ) -> Result<(), fidl::Error> {
508 let _result = self.send_raw(payload);
509 self.drop_without_shutdown();
510 _result
511 }
512
513 fn send_raw(
514 &self,
515 mut payload: &CollaborativeRebootInitiatorPerformPendingRebootResponse,
516 ) -> Result<(), fidl::Error> {
517 self.control_handle.inner.send::<CollaborativeRebootInitiatorPerformPendingRebootResponse>(
518 payload,
519 self.tx_id,
520 0x6114c8f94a98f492,
521 fidl::encoding::DynamicFlags::empty(),
522 )
523 }
524}
525
526mod internal {
527 use super::*;
528}