fidl_fuchsia_power_common/
fidl_fuchsia_power_common.rs1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Clone, Debug, Default, PartialEq)]
12pub struct CollaborativeRebootInitiatorPerformPendingRebootResponse {
13 pub rebooting: Option<bool>,
14 #[doc(hidden)]
15 pub __source_breaking: fidl::marker::SourceBreaking,
16}
17
18impl fidl::Persistable for CollaborativeRebootInitiatorPerformPendingRebootResponse {}
19
20mod internal {
21 use super::*;
22
23 impl CollaborativeRebootInitiatorPerformPendingRebootResponse {
24 #[inline(always)]
25 fn max_ordinal_present(&self) -> u64 {
26 if let Some(_) = self.rebooting {
27 return 1;
28 }
29 0
30 }
31 }
32
33 impl fidl::encoding::ValueTypeMarker for CollaborativeRebootInitiatorPerformPendingRebootResponse {
34 type Borrowed<'a> = &'a Self;
35 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
36 value
37 }
38 }
39
40 unsafe impl fidl::encoding::TypeMarker
41 for CollaborativeRebootInitiatorPerformPendingRebootResponse
42 {
43 type Owned = Self;
44
45 #[inline(always)]
46 fn inline_align(_context: fidl::encoding::Context) -> usize {
47 8
48 }
49
50 #[inline(always)]
51 fn inline_size(_context: fidl::encoding::Context) -> usize {
52 16
53 }
54 }
55
56 unsafe impl<D: fidl::encoding::ResourceDialect>
57 fidl::encoding::Encode<CollaborativeRebootInitiatorPerformPendingRebootResponse, D>
58 for &CollaborativeRebootInitiatorPerformPendingRebootResponse
59 {
60 unsafe fn encode(
61 self,
62 encoder: &mut fidl::encoding::Encoder<'_, D>,
63 offset: usize,
64 mut depth: fidl::encoding::Depth,
65 ) -> fidl::Result<()> {
66 encoder.debug_check_bounds::<CollaborativeRebootInitiatorPerformPendingRebootResponse>(
67 offset,
68 );
69 let max_ordinal: u64 = self.max_ordinal_present();
71 encoder.write_num(max_ordinal, offset);
72 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
73 if max_ordinal == 0 {
75 return Ok(());
76 }
77 depth.increment()?;
78 let envelope_size = 8;
79 let bytes_len = max_ordinal as usize * envelope_size;
80 #[allow(unused_variables)]
81 let offset = encoder.out_of_line_offset(bytes_len);
82 let mut _prev_end_offset: usize = 0;
83 if 1 > max_ordinal {
84 return Ok(());
85 }
86
87 let cur_offset: usize = (1 - 1) * envelope_size;
90
91 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
93
94 fidl::encoding::encode_in_envelope_optional::<bool, D>(
99 self.rebooting.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
100 encoder,
101 offset + cur_offset,
102 depth,
103 )?;
104
105 _prev_end_offset = cur_offset + envelope_size;
106
107 Ok(())
108 }
109 }
110
111 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
112 for CollaborativeRebootInitiatorPerformPendingRebootResponse
113 {
114 #[inline(always)]
115 fn new_empty() -> Self {
116 Self::default()
117 }
118
119 unsafe fn decode(
120 &mut self,
121 decoder: &mut fidl::encoding::Decoder<'_, D>,
122 offset: usize,
123 mut depth: fidl::encoding::Depth,
124 ) -> fidl::Result<()> {
125 decoder.debug_check_bounds::<Self>(offset);
126 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
127 None => return Err(fidl::Error::NotNullable),
128 Some(len) => len,
129 };
130 if len == 0 {
132 return Ok(());
133 };
134 depth.increment()?;
135 let envelope_size = 8;
136 let bytes_len = len * envelope_size;
137 let offset = decoder.out_of_line_offset(bytes_len)?;
138 let mut _next_ordinal_to_read = 0;
140 let mut next_offset = offset;
141 let end_offset = offset + bytes_len;
142 _next_ordinal_to_read += 1;
143 if next_offset >= end_offset {
144 return Ok(());
145 }
146
147 while _next_ordinal_to_read < 1 {
149 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
150 _next_ordinal_to_read += 1;
151 next_offset += envelope_size;
152 }
153
154 let next_out_of_line = decoder.next_out_of_line();
155 let handles_before = decoder.remaining_handles();
156 if let Some((inlined, num_bytes, num_handles)) =
157 fidl::encoding::decode_envelope_header(decoder, next_offset)?
158 {
159 let member_inline_size =
160 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
161 if inlined != (member_inline_size <= 4) {
162 return Err(fidl::Error::InvalidInlineBitInEnvelope);
163 }
164 let inner_offset;
165 let mut inner_depth = depth.clone();
166 if inlined {
167 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
168 inner_offset = next_offset;
169 } else {
170 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
171 inner_depth.increment()?;
172 }
173 let val_ref = self.rebooting.get_or_insert_with(|| fidl::new_empty!(bool, D));
174 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
175 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
176 {
177 return Err(fidl::Error::InvalidNumBytesInEnvelope);
178 }
179 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
180 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
181 }
182 }
183
184 next_offset += envelope_size;
185
186 while next_offset < end_offset {
188 _next_ordinal_to_read += 1;
189 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
190 next_offset += envelope_size;
191 }
192
193 Ok(())
194 }
195 }
196}