1#![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, Eq, Hash, Ord, PartialEq, PartialOrd)]
13pub struct DispatcherInfo {
14 pub driver: String,
15 pub name: String,
16 pub options: u32,
17 pub scheduler_role: String,
18}
19
20impl fidl::Persistable for DispatcherInfo {}
21
22#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct ProcessInfo {
25 pub job_koid: u64,
26 pub process_koid: u64,
27 pub threads: Vec<ThreadInfo>,
28 pub dispatchers: Vec<DispatcherInfo>,
29}
30
31impl fidl::Persistable for ProcessInfo {}
32
33#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct ThreadInfo {
36 pub koid: u64,
37 pub name: String,
38 pub scheduler_role: String,
39}
40
41impl fidl::Persistable for ThreadInfo {}
42
43mod internal {
44 use super::*;
45
46 impl fidl::encoding::ValueTypeMarker for DispatcherInfo {
47 type Borrowed<'a> = &'a Self;
48 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
49 value
50 }
51 }
52
53 unsafe impl fidl::encoding::TypeMarker for DispatcherInfo {
54 type Owned = Self;
55
56 #[inline(always)]
57 fn inline_align(_context: fidl::encoding::Context) -> usize {
58 8
59 }
60
61 #[inline(always)]
62 fn inline_size(_context: fidl::encoding::Context) -> usize {
63 56
64 }
65 }
66
67 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DispatcherInfo, D>
68 for &DispatcherInfo
69 {
70 #[inline]
71 unsafe fn encode(
72 self,
73 encoder: &mut fidl::encoding::Encoder<'_, D>,
74 offset: usize,
75 _depth: fidl::encoding::Depth,
76 ) -> fidl::Result<()> {
77 encoder.debug_check_bounds::<DispatcherInfo>(offset);
78 fidl::encoding::Encode::<DispatcherInfo, D>::encode(
80 (
81 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
82 &self.driver,
83 ),
84 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
85 &self.name,
86 ),
87 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
88 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
89 &self.scheduler_role,
90 ),
91 ),
92 encoder,
93 offset,
94 _depth,
95 )
96 }
97 }
98 unsafe impl<
99 D: fidl::encoding::ResourceDialect,
100 T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
101 T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
102 T2: fidl::encoding::Encode<u32, D>,
103 T3: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
104 > fidl::encoding::Encode<DispatcherInfo, D> for (T0, T1, T2, T3)
105 {
106 #[inline]
107 unsafe fn encode(
108 self,
109 encoder: &mut fidl::encoding::Encoder<'_, D>,
110 offset: usize,
111 depth: fidl::encoding::Depth,
112 ) -> fidl::Result<()> {
113 encoder.debug_check_bounds::<DispatcherInfo>(offset);
114 unsafe {
117 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
118 (ptr as *mut u64).write_unaligned(0);
119 }
120 self.0.encode(encoder, offset + 0, depth)?;
122 self.1.encode(encoder, offset + 16, depth)?;
123 self.2.encode(encoder, offset + 32, depth)?;
124 self.3.encode(encoder, offset + 40, depth)?;
125 Ok(())
126 }
127 }
128
129 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DispatcherInfo {
130 #[inline(always)]
131 fn new_empty() -> Self {
132 Self {
133 driver: fidl::new_empty!(fidl::encoding::UnboundedString, D),
134 name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
135 options: fidl::new_empty!(u32, D),
136 scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
137 }
138 }
139
140 #[inline]
141 unsafe fn decode(
142 &mut self,
143 decoder: &mut fidl::encoding::Decoder<'_, D>,
144 offset: usize,
145 _depth: fidl::encoding::Depth,
146 ) -> fidl::Result<()> {
147 decoder.debug_check_bounds::<Self>(offset);
148 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
150 let padval = unsafe { (ptr as *const u64).read_unaligned() };
151 let mask = 0xffffffff00000000u64;
152 let maskedval = padval & mask;
153 if maskedval != 0 {
154 return Err(fidl::Error::NonZeroPadding {
155 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
156 });
157 }
158 fidl::decode!(
159 fidl::encoding::UnboundedString,
160 D,
161 &mut self.driver,
162 decoder,
163 offset + 0,
164 _depth
165 )?;
166 fidl::decode!(
167 fidl::encoding::UnboundedString,
168 D,
169 &mut self.name,
170 decoder,
171 offset + 16,
172 _depth
173 )?;
174 fidl::decode!(u32, D, &mut self.options, decoder, offset + 32, _depth)?;
175 fidl::decode!(
176 fidl::encoding::UnboundedString,
177 D,
178 &mut self.scheduler_role,
179 decoder,
180 offset + 40,
181 _depth
182 )?;
183 Ok(())
184 }
185 }
186
187 impl fidl::encoding::ValueTypeMarker for ProcessInfo {
188 type Borrowed<'a> = &'a Self;
189 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
190 value
191 }
192 }
193
194 unsafe impl fidl::encoding::TypeMarker for ProcessInfo {
195 type Owned = Self;
196
197 #[inline(always)]
198 fn inline_align(_context: fidl::encoding::Context) -> usize {
199 8
200 }
201
202 #[inline(always)]
203 fn inline_size(_context: fidl::encoding::Context) -> usize {
204 48
205 }
206 }
207
208 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProcessInfo, D>
209 for &ProcessInfo
210 {
211 #[inline]
212 unsafe fn encode(
213 self,
214 encoder: &mut fidl::encoding::Encoder<'_, D>,
215 offset: usize,
216 _depth: fidl::encoding::Depth,
217 ) -> fidl::Result<()> {
218 encoder.debug_check_bounds::<ProcessInfo>(offset);
219 fidl::encoding::Encode::<ProcessInfo, D>::encode(
221 (
222 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.job_koid),
223 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.process_koid),
224 <fidl::encoding::UnboundedVector<ThreadInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.threads),
225 <fidl::encoding::UnboundedVector<DispatcherInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.dispatchers),
226 ),
227 encoder, offset, _depth
228 )
229 }
230 }
231 unsafe impl<
232 D: fidl::encoding::ResourceDialect,
233 T0: fidl::encoding::Encode<u64, D>,
234 T1: fidl::encoding::Encode<u64, D>,
235 T2: fidl::encoding::Encode<fidl::encoding::UnboundedVector<ThreadInfo>, D>,
236 T3: fidl::encoding::Encode<fidl::encoding::UnboundedVector<DispatcherInfo>, D>,
237 > fidl::encoding::Encode<ProcessInfo, D> for (T0, T1, T2, T3)
238 {
239 #[inline]
240 unsafe fn encode(
241 self,
242 encoder: &mut fidl::encoding::Encoder<'_, D>,
243 offset: usize,
244 depth: fidl::encoding::Depth,
245 ) -> fidl::Result<()> {
246 encoder.debug_check_bounds::<ProcessInfo>(offset);
247 self.0.encode(encoder, offset + 0, depth)?;
251 self.1.encode(encoder, offset + 8, depth)?;
252 self.2.encode(encoder, offset + 16, depth)?;
253 self.3.encode(encoder, offset + 32, depth)?;
254 Ok(())
255 }
256 }
257
258 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProcessInfo {
259 #[inline(always)]
260 fn new_empty() -> Self {
261 Self {
262 job_koid: fidl::new_empty!(u64, D),
263 process_koid: fidl::new_empty!(u64, D),
264 threads: fidl::new_empty!(fidl::encoding::UnboundedVector<ThreadInfo>, D),
265 dispatchers: fidl::new_empty!(fidl::encoding::UnboundedVector<DispatcherInfo>, D),
266 }
267 }
268
269 #[inline]
270 unsafe fn decode(
271 &mut self,
272 decoder: &mut fidl::encoding::Decoder<'_, D>,
273 offset: usize,
274 _depth: fidl::encoding::Depth,
275 ) -> fidl::Result<()> {
276 decoder.debug_check_bounds::<Self>(offset);
277 fidl::decode!(u64, D, &mut self.job_koid, decoder, offset + 0, _depth)?;
279 fidl::decode!(u64, D, &mut self.process_koid, decoder, offset + 8, _depth)?;
280 fidl::decode!(
281 fidl::encoding::UnboundedVector<ThreadInfo>,
282 D,
283 &mut self.threads,
284 decoder,
285 offset + 16,
286 _depth
287 )?;
288 fidl::decode!(
289 fidl::encoding::UnboundedVector<DispatcherInfo>,
290 D,
291 &mut self.dispatchers,
292 decoder,
293 offset + 32,
294 _depth
295 )?;
296 Ok(())
297 }
298 }
299
300 impl fidl::encoding::ValueTypeMarker for ThreadInfo {
301 type Borrowed<'a> = &'a Self;
302 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
303 value
304 }
305 }
306
307 unsafe impl fidl::encoding::TypeMarker for ThreadInfo {
308 type Owned = Self;
309
310 #[inline(always)]
311 fn inline_align(_context: fidl::encoding::Context) -> usize {
312 8
313 }
314
315 #[inline(always)]
316 fn inline_size(_context: fidl::encoding::Context) -> usize {
317 40
318 }
319 }
320
321 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ThreadInfo, D>
322 for &ThreadInfo
323 {
324 #[inline]
325 unsafe fn encode(
326 self,
327 encoder: &mut fidl::encoding::Encoder<'_, D>,
328 offset: usize,
329 _depth: fidl::encoding::Depth,
330 ) -> fidl::Result<()> {
331 encoder.debug_check_bounds::<ThreadInfo>(offset);
332 fidl::encoding::Encode::<ThreadInfo, D>::encode(
334 (
335 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.koid),
336 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
337 &self.name,
338 ),
339 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
340 &self.scheduler_role,
341 ),
342 ),
343 encoder,
344 offset,
345 _depth,
346 )
347 }
348 }
349 unsafe impl<
350 D: fidl::encoding::ResourceDialect,
351 T0: fidl::encoding::Encode<u64, D>,
352 T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
353 T2: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
354 > fidl::encoding::Encode<ThreadInfo, D> for (T0, T1, T2)
355 {
356 #[inline]
357 unsafe fn encode(
358 self,
359 encoder: &mut fidl::encoding::Encoder<'_, D>,
360 offset: usize,
361 depth: fidl::encoding::Depth,
362 ) -> fidl::Result<()> {
363 encoder.debug_check_bounds::<ThreadInfo>(offset);
364 self.0.encode(encoder, offset + 0, depth)?;
368 self.1.encode(encoder, offset + 8, depth)?;
369 self.2.encode(encoder, offset + 24, depth)?;
370 Ok(())
371 }
372 }
373
374 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ThreadInfo {
375 #[inline(always)]
376 fn new_empty() -> Self {
377 Self {
378 koid: fidl::new_empty!(u64, D),
379 name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
380 scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
381 }
382 }
383
384 #[inline]
385 unsafe fn decode(
386 &mut self,
387 decoder: &mut fidl::encoding::Decoder<'_, D>,
388 offset: usize,
389 _depth: fidl::encoding::Depth,
390 ) -> fidl::Result<()> {
391 decoder.debug_check_bounds::<Self>(offset);
392 fidl::decode!(u64, D, &mut self.koid, decoder, offset + 0, _depth)?;
394 fidl::decode!(
395 fidl::encoding::UnboundedString,
396 D,
397 &mut self.name,
398 decoder,
399 offset + 8,
400 _depth
401 )?;
402 fidl::decode!(
403 fidl::encoding::UnboundedString,
404 D,
405 &mut self.scheduler_role,
406 decoder,
407 offset + 24,
408 _depth
409 )?;
410 Ok(())
411 }
412 }
413}