fidl_fuchsia_power_internal/
fidl_fuchsia_power_internal.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_internal__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CollaborativeRebootSchedulerScheduleRebootRequest {
16    pub reason: CollaborativeRebootReason,
17    pub cancel: Option<fidl::EventPair>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for CollaborativeRebootSchedulerScheduleRebootRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct CollaborativeRebootSchedulerMarker;
27
28impl fidl::endpoints::ProtocolMarker for CollaborativeRebootSchedulerMarker {
29    type Proxy = CollaborativeRebootSchedulerProxy;
30    type RequestStream = CollaborativeRebootSchedulerRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = CollaborativeRebootSchedulerSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.power.internal.CollaborativeRebootScheduler";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for CollaborativeRebootSchedulerMarker {}
37
38pub trait CollaborativeRebootSchedulerProxyInterface: Send + Sync {
39    type ScheduleRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
40    fn r#schedule_reboot(
41        &self,
42        reason: CollaborativeRebootReason,
43        cancel: Option<fidl::EventPair>,
44    ) -> Self::ScheduleRebootResponseFut;
45}
46#[derive(Debug)]
47#[cfg(target_os = "fuchsia")]
48pub struct CollaborativeRebootSchedulerSynchronousProxy {
49    client: fidl::client::sync::Client,
50}
51
52#[cfg(target_os = "fuchsia")]
53impl fidl::endpoints::SynchronousProxy for CollaborativeRebootSchedulerSynchronousProxy {
54    type Proxy = CollaborativeRebootSchedulerProxy;
55    type Protocol = CollaborativeRebootSchedulerMarker;
56
57    fn from_channel(inner: fidl::Channel) -> Self {
58        Self::new(inner)
59    }
60
61    fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    fn as_channel(&self) -> &fidl::Channel {
66        self.client.as_channel()
67    }
68}
69
70#[cfg(target_os = "fuchsia")]
71impl CollaborativeRebootSchedulerSynchronousProxy {
72    pub fn new(channel: fidl::Channel) -> Self {
73        let protocol_name =
74            <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
88        CollaborativeRebootSchedulerEvent::decode(self.client.wait_for_event(deadline)?)
89    }
90
91    /// Schedules a collaborative reboot.
92    ///
93    /// Notifies the server of a new reason to perform collaborative reboot.
94    /// This method may be called multiple times, by multiple actors for a
95    /// single collaborative reboot.
96    ///
97    /// The server will not respond to the method until the request has been
98    /// scheduled.
99    ///
100    /// Arguments:
101    ///  - reason: The reason for requesting the collaborative reboot.
102    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
103    ///            cancel their request by signaling the event's peer. A
104    ///            canceled request will not cause a future call to
105    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
106    ///            to initiate a reboot.
107    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
108    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
109    ///            the client dropped the event pair), it will be interpretted
110    ///            as a cancellation.
111    pub fn r#schedule_reboot(
112        &self,
113        mut reason: CollaborativeRebootReason,
114        mut cancel: Option<fidl::EventPair>,
115        ___deadline: zx::MonotonicInstant,
116    ) -> Result<(), fidl::Error> {
117        let _response = self.client.send_query::<
118            CollaborativeRebootSchedulerScheduleRebootRequest,
119            fidl::encoding::EmptyPayload,
120        >(
121            (reason, cancel,),
122            0x439c89c2c4b101ab,
123            fidl::encoding::DynamicFlags::empty(),
124            ___deadline,
125        )?;
126        Ok(_response)
127    }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl From<CollaborativeRebootSchedulerSynchronousProxy> for zx::Handle {
132    fn from(value: CollaborativeRebootSchedulerSynchronousProxy) -> Self {
133        value.into_channel().into()
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<fidl::Channel> for CollaborativeRebootSchedulerSynchronousProxy {
139    fn from(value: fidl::Channel) -> Self {
140        Self::new(value)
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl fidl::endpoints::FromClient for CollaborativeRebootSchedulerSynchronousProxy {
146    type Protocol = CollaborativeRebootSchedulerMarker;
147
148    fn from_client(value: fidl::endpoints::ClientEnd<CollaborativeRebootSchedulerMarker>) -> Self {
149        Self::new(value.into_channel())
150    }
151}
152
153#[derive(Debug, Clone)]
154pub struct CollaborativeRebootSchedulerProxy {
155    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
156}
157
158impl fidl::endpoints::Proxy for CollaborativeRebootSchedulerProxy {
159    type Protocol = CollaborativeRebootSchedulerMarker;
160
161    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
162        Self::new(inner)
163    }
164
165    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
166        self.client.into_channel().map_err(|client| Self { client })
167    }
168
169    fn as_channel(&self) -> &::fidl::AsyncChannel {
170        self.client.as_channel()
171    }
172}
173
174impl CollaborativeRebootSchedulerProxy {
175    /// Create a new Proxy for fuchsia.power.internal/CollaborativeRebootScheduler.
176    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
177        let protocol_name =
178            <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
179        Self { client: fidl::client::Client::new(channel, protocol_name) }
180    }
181
182    /// Get a Stream of events from the remote end of the protocol.
183    ///
184    /// # Panics
185    ///
186    /// Panics if the event stream was already taken.
187    pub fn take_event_stream(&self) -> CollaborativeRebootSchedulerEventStream {
188        CollaborativeRebootSchedulerEventStream {
189            event_receiver: self.client.take_event_receiver(),
190        }
191    }
192
193    /// Schedules a collaborative reboot.
194    ///
195    /// Notifies the server of a new reason to perform collaborative reboot.
196    /// This method may be called multiple times, by multiple actors for a
197    /// single collaborative reboot.
198    ///
199    /// The server will not respond to the method until the request has been
200    /// scheduled.
201    ///
202    /// Arguments:
203    ///  - reason: The reason for requesting the collaborative reboot.
204    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
205    ///            cancel their request by signaling the event's peer. A
206    ///            canceled request will not cause a future call to
207    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
208    ///            to initiate a reboot.
209    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
210    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
211    ///            the client dropped the event pair), it will be interpretted
212    ///            as a cancellation.
213    pub fn r#schedule_reboot(
214        &self,
215        mut reason: CollaborativeRebootReason,
216        mut cancel: Option<fidl::EventPair>,
217    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
218        CollaborativeRebootSchedulerProxyInterface::r#schedule_reboot(self, reason, cancel)
219    }
220}
221
222impl CollaborativeRebootSchedulerProxyInterface for CollaborativeRebootSchedulerProxy {
223    type ScheduleRebootResponseFut =
224        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
225    fn r#schedule_reboot(
226        &self,
227        mut reason: CollaborativeRebootReason,
228        mut cancel: Option<fidl::EventPair>,
229    ) -> Self::ScheduleRebootResponseFut {
230        fn _decode(
231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
232        ) -> Result<(), fidl::Error> {
233            let _response = fidl::client::decode_transaction_body::<
234                fidl::encoding::EmptyPayload,
235                fidl::encoding::DefaultFuchsiaResourceDialect,
236                0x439c89c2c4b101ab,
237            >(_buf?)?;
238            Ok(_response)
239        }
240        self.client.send_query_and_decode::<CollaborativeRebootSchedulerScheduleRebootRequest, ()>(
241            (reason, cancel),
242            0x439c89c2c4b101ab,
243            fidl::encoding::DynamicFlags::empty(),
244            _decode,
245        )
246    }
247}
248
249pub struct CollaborativeRebootSchedulerEventStream {
250    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
251}
252
253impl std::marker::Unpin for CollaborativeRebootSchedulerEventStream {}
254
255impl futures::stream::FusedStream for CollaborativeRebootSchedulerEventStream {
256    fn is_terminated(&self) -> bool {
257        self.event_receiver.is_terminated()
258    }
259}
260
261impl futures::Stream for CollaborativeRebootSchedulerEventStream {
262    type Item = Result<CollaborativeRebootSchedulerEvent, fidl::Error>;
263
264    fn poll_next(
265        mut self: std::pin::Pin<&mut Self>,
266        cx: &mut std::task::Context<'_>,
267    ) -> std::task::Poll<Option<Self::Item>> {
268        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
269            &mut self.event_receiver,
270            cx
271        )?) {
272            Some(buf) => {
273                std::task::Poll::Ready(Some(CollaborativeRebootSchedulerEvent::decode(buf)))
274            }
275            None => std::task::Poll::Ready(None),
276        }
277    }
278}
279
280#[derive(Debug)]
281pub enum CollaborativeRebootSchedulerEvent {}
282
283impl CollaborativeRebootSchedulerEvent {
284    /// Decodes a message buffer as a [`CollaborativeRebootSchedulerEvent`].
285    fn decode(
286        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
287    ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
288        let (bytes, _handles) = buf.split_mut();
289        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
290        debug_assert_eq!(tx_header.tx_id, 0);
291        match tx_header.ordinal {
292            _ => Err(fidl::Error::UnknownOrdinal {
293                ordinal: tx_header.ordinal,
294                protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295            })
296        }
297    }
298}
299
300/// A Stream of incoming requests for fuchsia.power.internal/CollaborativeRebootScheduler.
301pub struct CollaborativeRebootSchedulerRequestStream {
302    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303    is_terminated: bool,
304}
305
306impl std::marker::Unpin for CollaborativeRebootSchedulerRequestStream {}
307
308impl futures::stream::FusedStream for CollaborativeRebootSchedulerRequestStream {
309    fn is_terminated(&self) -> bool {
310        self.is_terminated
311    }
312}
313
314impl fidl::endpoints::RequestStream for CollaborativeRebootSchedulerRequestStream {
315    type Protocol = CollaborativeRebootSchedulerMarker;
316    type ControlHandle = CollaborativeRebootSchedulerControlHandle;
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        CollaborativeRebootSchedulerControlHandle { 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 CollaborativeRebootSchedulerRequestStream {
342    type Item = Result<CollaborativeRebootSchedulerRequest, 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 CollaborativeRebootSchedulerRequestStream 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                // A message has been received from the channel
373                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375                std::task::Poll::Ready(Some(match header.ordinal {
376                0x439c89c2c4b101ab => {
377                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
378                    let mut req = fidl::new_empty!(CollaborativeRebootSchedulerScheduleRebootRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
379                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollaborativeRebootSchedulerScheduleRebootRequest>(&header, _body_bytes, handles, &mut req)?;
380                    let control_handle = CollaborativeRebootSchedulerControlHandle {
381                        inner: this.inner.clone(),
382                    };
383                    Ok(CollaborativeRebootSchedulerRequest::ScheduleReboot {reason: req.reason,
384cancel: req.cancel,
385
386                        responder: CollaborativeRebootSchedulerScheduleRebootResponder {
387                            control_handle: std::mem::ManuallyDrop::new(control_handle),
388                            tx_id: header.tx_id,
389                        },
390                    })
391                }
392                _ => Err(fidl::Error::UnknownOrdinal {
393                    ordinal: header.ordinal,
394                    protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
395                }),
396            }))
397            },
398        )
399    }
400}
401
402/// A scheduler of collaborative device reboots.
403///
404/// Collaborative reboot is a mechanism that allows multiple actors to work
405/// together to schedule a device reboot at a time that avoids user disruption.
406/// Actors fulfill one of two roles: Scheduler or Initiator. The scheduler
407/// registers the desire to reboot the device at a later point in time, while
408/// the initiator identifies appropriate times to perform a reboot and actuates
409/// any scheduled requests. This protocol fulfills the scheduler role. For the
410/// initiator role's protocol, see
411/// [`fuchsia.power/CollaborativeRebootInitiator`].
412///
413/// Collaborative reboot can be used when the platform is configured to let the
414/// product drive reboot scheduling.
415///
416/// As a concrete example, this mechanism can be used to drive software updates.
417/// When the platform identifies that there is an outstanding software update to
418/// apply, it can download the update, and schedule a collaborative reboot.
419/// Later, when the product identifies that it is an appropriate time for the
420/// device to reboot (say, after it's observed a sufficient period of user
421/// inactivity), it can initate the collaborative reboot.
422#[derive(Debug)]
423pub enum CollaborativeRebootSchedulerRequest {
424    /// Schedules a collaborative reboot.
425    ///
426    /// Notifies the server of a new reason to perform collaborative reboot.
427    /// This method may be called multiple times, by multiple actors for a
428    /// single collaborative reboot.
429    ///
430    /// The server will not respond to the method until the request has been
431    /// scheduled.
432    ///
433    /// Arguments:
434    ///  - reason: The reason for requesting the collaborative reboot.
435    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
436    ///            cancel their request by signaling the event's peer. A
437    ///            canceled request will not cause a future call to
438    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
439    ///            to initiate a reboot.
440    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
441    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
442    ///            the client dropped the event pair), it will be interpretted
443    ///            as a cancellation.
444    ScheduleReboot {
445        reason: CollaborativeRebootReason,
446        cancel: Option<fidl::EventPair>,
447        responder: CollaborativeRebootSchedulerScheduleRebootResponder,
448    },
449}
450
451impl CollaborativeRebootSchedulerRequest {
452    #[allow(irrefutable_let_patterns)]
453    pub fn into_schedule_reboot(
454        self,
455    ) -> Option<(
456        CollaborativeRebootReason,
457        Option<fidl::EventPair>,
458        CollaborativeRebootSchedulerScheduleRebootResponder,
459    )> {
460        if let CollaborativeRebootSchedulerRequest::ScheduleReboot { reason, cancel, responder } =
461            self
462        {
463            Some((reason, cancel, responder))
464        } else {
465            None
466        }
467    }
468
469    /// Name of the method defined in FIDL
470    pub fn method_name(&self) -> &'static str {
471        match *self {
472            CollaborativeRebootSchedulerRequest::ScheduleReboot { .. } => "schedule_reboot",
473        }
474    }
475}
476
477#[derive(Debug, Clone)]
478pub struct CollaborativeRebootSchedulerControlHandle {
479    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
480}
481
482impl fidl::endpoints::ControlHandle for CollaborativeRebootSchedulerControlHandle {
483    fn shutdown(&self) {
484        self.inner.shutdown()
485    }
486    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
487        self.inner.shutdown_with_epitaph(status)
488    }
489
490    fn is_closed(&self) -> bool {
491        self.inner.channel().is_closed()
492    }
493    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
494        self.inner.channel().on_closed()
495    }
496
497    #[cfg(target_os = "fuchsia")]
498    fn signal_peer(
499        &self,
500        clear_mask: zx::Signals,
501        set_mask: zx::Signals,
502    ) -> Result<(), zx_status::Status> {
503        use fidl::Peered;
504        self.inner.channel().signal_peer(clear_mask, set_mask)
505    }
506}
507
508impl CollaborativeRebootSchedulerControlHandle {}
509
510#[must_use = "FIDL methods require a response to be sent"]
511#[derive(Debug)]
512pub struct CollaborativeRebootSchedulerScheduleRebootResponder {
513    control_handle: std::mem::ManuallyDrop<CollaborativeRebootSchedulerControlHandle>,
514    tx_id: u32,
515}
516
517/// Set the the channel to be shutdown (see [`CollaborativeRebootSchedulerControlHandle::shutdown`])
518/// if the responder is dropped without sending a response, so that the client
519/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
520impl std::ops::Drop for CollaborativeRebootSchedulerScheduleRebootResponder {
521    fn drop(&mut self) {
522        self.control_handle.shutdown();
523        // Safety: drops once, never accessed again
524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
525    }
526}
527
528impl fidl::endpoints::Responder for CollaborativeRebootSchedulerScheduleRebootResponder {
529    type ControlHandle = CollaborativeRebootSchedulerControlHandle;
530
531    fn control_handle(&self) -> &CollaborativeRebootSchedulerControlHandle {
532        &self.control_handle
533    }
534
535    fn drop_without_shutdown(mut self) {
536        // Safety: drops once, never accessed again due to mem::forget
537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
538        // Prevent Drop from running (which would shut down the channel)
539        std::mem::forget(self);
540    }
541}
542
543impl CollaborativeRebootSchedulerScheduleRebootResponder {
544    /// Sends a response to the FIDL transaction.
545    ///
546    /// Sets the channel to shutdown if an error occurs.
547    pub fn send(self) -> Result<(), fidl::Error> {
548        let _result = self.send_raw();
549        if _result.is_err() {
550            self.control_handle.shutdown();
551        }
552        self.drop_without_shutdown();
553        _result
554    }
555
556    /// Similar to "send" but does not shutdown the channel if an error occurs.
557    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
558        let _result = self.send_raw();
559        self.drop_without_shutdown();
560        _result
561    }
562
563    fn send_raw(&self) -> Result<(), fidl::Error> {
564        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
565            (),
566            self.tx_id,
567            0x439c89c2c4b101ab,
568            fidl::encoding::DynamicFlags::empty(),
569        )
570    }
571}
572
573mod internal {
574    use super::*;
575
576    impl fidl::encoding::ResourceTypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
577        type Borrowed<'a> = &'a mut Self;
578        fn take_or_borrow<'a>(
579            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
580        ) -> Self::Borrowed<'a> {
581            value
582        }
583    }
584
585    unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
586        type Owned = Self;
587
588        #[inline(always)]
589        fn inline_align(_context: fidl::encoding::Context) -> usize {
590            4
591        }
592
593        #[inline(always)]
594        fn inline_size(_context: fidl::encoding::Context) -> usize {
595            8
596        }
597    }
598
599    unsafe impl
600        fidl::encoding::Encode<
601            CollaborativeRebootSchedulerScheduleRebootRequest,
602            fidl::encoding::DefaultFuchsiaResourceDialect,
603        > for &mut CollaborativeRebootSchedulerScheduleRebootRequest
604    {
605        #[inline]
606        unsafe fn encode(
607            self,
608            encoder: &mut fidl::encoding::Encoder<
609                '_,
610                fidl::encoding::DefaultFuchsiaResourceDialect,
611            >,
612            offset: usize,
613            _depth: fidl::encoding::Depth,
614        ) -> fidl::Result<()> {
615            encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
616            // Delegate to tuple encoding.
617            fidl::encoding::Encode::<
618                CollaborativeRebootSchedulerScheduleRebootRequest,
619                fidl::encoding::DefaultFuchsiaResourceDialect,
620            >::encode(
621                (
622                    <CollaborativeRebootReason as fidl::encoding::ValueTypeMarker>::borrow(
623                        &self.reason,
624                    ),
625                    <fidl::encoding::Optional<
626                        fidl::encoding::HandleType<
627                            fidl::EventPair,
628                            { fidl::ObjectType::EVENTPAIR.into_raw() },
629                            16384,
630                        >,
631                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
632                        &mut self.cancel
633                    ),
634                ),
635                encoder,
636                offset,
637                _depth,
638            )
639        }
640    }
641    unsafe impl<
642            T0: fidl::encoding::Encode<
643                CollaborativeRebootReason,
644                fidl::encoding::DefaultFuchsiaResourceDialect,
645            >,
646            T1: fidl::encoding::Encode<
647                fidl::encoding::Optional<
648                    fidl::encoding::HandleType<
649                        fidl::EventPair,
650                        { fidl::ObjectType::EVENTPAIR.into_raw() },
651                        16384,
652                    >,
653                >,
654                fidl::encoding::DefaultFuchsiaResourceDialect,
655            >,
656        >
657        fidl::encoding::Encode<
658            CollaborativeRebootSchedulerScheduleRebootRequest,
659            fidl::encoding::DefaultFuchsiaResourceDialect,
660        > for (T0, T1)
661    {
662        #[inline]
663        unsafe fn encode(
664            self,
665            encoder: &mut fidl::encoding::Encoder<
666                '_,
667                fidl::encoding::DefaultFuchsiaResourceDialect,
668            >,
669            offset: usize,
670            depth: fidl::encoding::Depth,
671        ) -> fidl::Result<()> {
672            encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
673            // Zero out padding regions. There's no need to apply masks
674            // because the unmasked parts will be overwritten by fields.
675            // Write the fields.
676            self.0.encode(encoder, offset + 0, depth)?;
677            self.1.encode(encoder, offset + 4, depth)?;
678            Ok(())
679        }
680    }
681
682    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
683        for CollaborativeRebootSchedulerScheduleRebootRequest
684    {
685        #[inline(always)]
686        fn new_empty() -> Self {
687            Self {
688                reason: fidl::new_empty!(
689                    CollaborativeRebootReason,
690                    fidl::encoding::DefaultFuchsiaResourceDialect
691                ),
692                cancel: fidl::new_empty!(
693                    fidl::encoding::Optional<
694                        fidl::encoding::HandleType<
695                            fidl::EventPair,
696                            { fidl::ObjectType::EVENTPAIR.into_raw() },
697                            16384,
698                        >,
699                    >,
700                    fidl::encoding::DefaultFuchsiaResourceDialect
701                ),
702            }
703        }
704
705        #[inline]
706        unsafe fn decode(
707            &mut self,
708            decoder: &mut fidl::encoding::Decoder<
709                '_,
710                fidl::encoding::DefaultFuchsiaResourceDialect,
711            >,
712            offset: usize,
713            _depth: fidl::encoding::Depth,
714        ) -> fidl::Result<()> {
715            decoder.debug_check_bounds::<Self>(offset);
716            // Verify that padding bytes are zero.
717            fidl::decode!(
718                CollaborativeRebootReason,
719                fidl::encoding::DefaultFuchsiaResourceDialect,
720                &mut self.reason,
721                decoder,
722                offset + 0,
723                _depth
724            )?;
725            fidl::decode!(
726                fidl::encoding::Optional<
727                    fidl::encoding::HandleType<
728                        fidl::EventPair,
729                        { fidl::ObjectType::EVENTPAIR.into_raw() },
730                        16384,
731                    >,
732                >,
733                fidl::encoding::DefaultFuchsiaResourceDialect,
734                &mut self.cancel,
735                decoder,
736                offset + 4,
737                _depth
738            )?;
739            Ok(())
740        }
741    }
742}