Skip to main content

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