fidl_fuchsia_ui_focus__common/
fidl_fuchsia_ui_focus__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 FocusChainProviderWatchFocusKoidChainRequest {
13 #[doc(hidden)]
14 pub __source_breaking: fidl::marker::SourceBreaking,
15}
16
17impl fidl::Persistable for FocusChainProviderWatchFocusKoidChainRequest {}
18
19#[derive(Clone, Debug, Default, PartialEq)]
23pub struct FocusKoidChain {
24 pub focus_chain: Option<Vec<u64>>,
25 #[doc(hidden)]
26 pub __source_breaking: fidl::marker::SourceBreaking,
27}
28
29impl fidl::Persistable for FocusKoidChain {}
30
31pub mod focus_chain_listener_ordinals {
32 pub const ON_FOCUS_CHANGE: u64 = 0x2ffe3dec9ff7a04a;
33}
34
35pub mod focus_chain_listener_registry_ordinals {
36 pub const REGISTER: u64 = 0x177be5ba0da6faa3;
37}
38
39pub mod focus_chain_provider_ordinals {
40 pub const WATCH_FOCUS_KOID_CHAIN: u64 = 0x726d2fdae53c1ab7;
41}
42
43mod internal {
44 use super::*;
45
46 impl FocusChainProviderWatchFocusKoidChainRequest {
47 #[inline(always)]
48 fn max_ordinal_present(&self) -> u64 {
49 0
50 }
51 }
52
53 impl fidl::encoding::ValueTypeMarker for FocusChainProviderWatchFocusKoidChainRequest {
54 type Borrowed<'a> = &'a Self;
55 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
56 value
57 }
58 }
59
60 unsafe impl fidl::encoding::TypeMarker for FocusChainProviderWatchFocusKoidChainRequest {
61 type Owned = Self;
62
63 #[inline(always)]
64 fn inline_align(_context: fidl::encoding::Context) -> usize {
65 8
66 }
67
68 #[inline(always)]
69 fn inline_size(_context: fidl::encoding::Context) -> usize {
70 16
71 }
72 }
73
74 unsafe impl<D: fidl::encoding::ResourceDialect>
75 fidl::encoding::Encode<FocusChainProviderWatchFocusKoidChainRequest, D>
76 for &FocusChainProviderWatchFocusKoidChainRequest
77 {
78 unsafe fn encode(
79 self,
80 encoder: &mut fidl::encoding::Encoder<'_, D>,
81 offset: usize,
82 mut depth: fidl::encoding::Depth,
83 ) -> fidl::Result<()> {
84 encoder.debug_check_bounds::<FocusChainProviderWatchFocusKoidChainRequest>(offset);
85 let max_ordinal: u64 = self.max_ordinal_present();
87 encoder.write_num(max_ordinal, offset);
88 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
89 if max_ordinal == 0 {
91 return Ok(());
92 }
93 depth.increment()?;
94 let envelope_size = 8;
95 let bytes_len = max_ordinal as usize * envelope_size;
96 #[allow(unused_variables)]
97 let offset = encoder.out_of_line_offset(bytes_len);
98 let mut _prev_end_offset: usize = 0;
99
100 Ok(())
101 }
102 }
103
104 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
105 for FocusChainProviderWatchFocusKoidChainRequest
106 {
107 #[inline(always)]
108 fn new_empty() -> Self {
109 Self::default()
110 }
111
112 unsafe fn decode(
113 &mut self,
114 decoder: &mut fidl::encoding::Decoder<'_, D>,
115 offset: usize,
116 mut depth: fidl::encoding::Depth,
117 ) -> fidl::Result<()> {
118 decoder.debug_check_bounds::<Self>(offset);
119 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
120 None => return Err(fidl::Error::NotNullable),
121 Some(len) => len,
122 };
123 if len == 0 {
125 return Ok(());
126 };
127 depth.increment()?;
128 let envelope_size = 8;
129 let bytes_len = len * envelope_size;
130 let offset = decoder.out_of_line_offset(bytes_len)?;
131 let mut _next_ordinal_to_read = 0;
133 let mut next_offset = offset;
134 let end_offset = offset + bytes_len;
135
136 while next_offset < end_offset {
138 _next_ordinal_to_read += 1;
139 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
140 next_offset += envelope_size;
141 }
142
143 Ok(())
144 }
145 }
146
147 impl FocusKoidChain {
148 #[inline(always)]
149 fn max_ordinal_present(&self) -> u64 {
150 if let Some(_) = self.focus_chain {
151 return 1;
152 }
153 0
154 }
155 }
156
157 impl fidl::encoding::ValueTypeMarker for FocusKoidChain {
158 type Borrowed<'a> = &'a Self;
159 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
160 value
161 }
162 }
163
164 unsafe impl fidl::encoding::TypeMarker for FocusKoidChain {
165 type Owned = Self;
166
167 #[inline(always)]
168 fn inline_align(_context: fidl::encoding::Context) -> usize {
169 8
170 }
171
172 #[inline(always)]
173 fn inline_size(_context: fidl::encoding::Context) -> usize {
174 16
175 }
176 }
177
178 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FocusKoidChain, D>
179 for &FocusKoidChain
180 {
181 unsafe fn encode(
182 self,
183 encoder: &mut fidl::encoding::Encoder<'_, D>,
184 offset: usize,
185 mut depth: fidl::encoding::Depth,
186 ) -> fidl::Result<()> {
187 encoder.debug_check_bounds::<FocusKoidChain>(offset);
188 let max_ordinal: u64 = self.max_ordinal_present();
190 encoder.write_num(max_ordinal, offset);
191 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
192 if max_ordinal == 0 {
194 return Ok(());
195 }
196 depth.increment()?;
197 let envelope_size = 8;
198 let bytes_len = max_ordinal as usize * envelope_size;
199 #[allow(unused_variables)]
200 let offset = encoder.out_of_line_offset(bytes_len);
201 let mut _prev_end_offset: usize = 0;
202 if 1 > max_ordinal {
203 return Ok(());
204 }
205
206 let cur_offset: usize = (1 - 1) * envelope_size;
209
210 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
212
213 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u64>, D>(
218 self.focus_chain.as_ref().map(<fidl::encoding::UnboundedVector<u64> as fidl::encoding::ValueTypeMarker>::borrow),
219 encoder, offset + cur_offset, depth
220 )?;
221
222 _prev_end_offset = cur_offset + envelope_size;
223
224 Ok(())
225 }
226 }
227
228 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FocusKoidChain {
229 #[inline(always)]
230 fn new_empty() -> Self {
231 Self::default()
232 }
233
234 unsafe fn decode(
235 &mut self,
236 decoder: &mut fidl::encoding::Decoder<'_, D>,
237 offset: usize,
238 mut depth: fidl::encoding::Depth,
239 ) -> fidl::Result<()> {
240 decoder.debug_check_bounds::<Self>(offset);
241 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
242 None => return Err(fidl::Error::NotNullable),
243 Some(len) => len,
244 };
245 if len == 0 {
247 return Ok(());
248 };
249 depth.increment()?;
250 let envelope_size = 8;
251 let bytes_len = len * envelope_size;
252 let offset = decoder.out_of_line_offset(bytes_len)?;
253 let mut _next_ordinal_to_read = 0;
255 let mut next_offset = offset;
256 let end_offset = offset + bytes_len;
257 _next_ordinal_to_read += 1;
258 if next_offset >= end_offset {
259 return Ok(());
260 }
261
262 while _next_ordinal_to_read < 1 {
264 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
265 _next_ordinal_to_read += 1;
266 next_offset += envelope_size;
267 }
268
269 let next_out_of_line = decoder.next_out_of_line();
270 let handles_before = decoder.remaining_handles();
271 if let Some((inlined, num_bytes, num_handles)) =
272 fidl::encoding::decode_envelope_header(decoder, next_offset)?
273 {
274 let member_inline_size = <fidl::encoding::UnboundedVector<u64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
275 if inlined != (member_inline_size <= 4) {
276 return Err(fidl::Error::InvalidInlineBitInEnvelope);
277 }
278 let inner_offset;
279 let mut inner_depth = depth.clone();
280 if inlined {
281 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
282 inner_offset = next_offset;
283 } else {
284 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
285 inner_depth.increment()?;
286 }
287 let val_ref = self.focus_chain.get_or_insert_with(|| {
288 fidl::new_empty!(fidl::encoding::UnboundedVector<u64>, D)
289 });
290 fidl::decode!(
291 fidl::encoding::UnboundedVector<u64>,
292 D,
293 val_ref,
294 decoder,
295 inner_offset,
296 inner_depth
297 )?;
298 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
299 {
300 return Err(fidl::Error::InvalidNumBytesInEnvelope);
301 }
302 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
303 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
304 }
305 }
306
307 next_offset += envelope_size;
308
309 while next_offset < end_offset {
311 _next_ordinal_to_read += 1;
312 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
313 next_offset += envelope_size;
314 }
315
316 Ok(())
317 }
318 }
319}