fidl_fuchsia_net_reachability_common/
fidl_fuchsia_net_reachability_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 MonitorOptions {
13 #[doc(hidden)]
14 pub __source_breaking: fidl::marker::SourceBreaking,
15}
16
17impl fidl::Persistable for MonitorOptions {}
18
19#[derive(Clone, Debug, Default, PartialEq)]
22pub struct Snapshot {
23 pub internet_available: Option<bool>,
25 pub gateway_reachable: Option<bool>,
28 pub dns_active: Option<bool>,
31 pub http_active: Option<bool>,
34 #[doc(hidden)]
35 pub __source_breaking: fidl::marker::SourceBreaking,
36}
37
38impl fidl::Persistable for Snapshot {}
39
40mod internal {
41 use super::*;
42
43 impl MonitorOptions {
44 #[inline(always)]
45 fn max_ordinal_present(&self) -> u64 {
46 0
47 }
48 }
49
50 impl fidl::encoding::ValueTypeMarker for MonitorOptions {
51 type Borrowed<'a> = &'a Self;
52 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
53 value
54 }
55 }
56
57 unsafe impl fidl::encoding::TypeMarker for MonitorOptions {
58 type Owned = Self;
59
60 #[inline(always)]
61 fn inline_align(_context: fidl::encoding::Context) -> usize {
62 8
63 }
64
65 #[inline(always)]
66 fn inline_size(_context: fidl::encoding::Context) -> usize {
67 16
68 }
69 }
70
71 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MonitorOptions, D>
72 for &MonitorOptions
73 {
74 unsafe fn encode(
75 self,
76 encoder: &mut fidl::encoding::Encoder<'_, D>,
77 offset: usize,
78 mut depth: fidl::encoding::Depth,
79 ) -> fidl::Result<()> {
80 encoder.debug_check_bounds::<MonitorOptions>(offset);
81 let max_ordinal: u64 = self.max_ordinal_present();
83 encoder.write_num(max_ordinal, offset);
84 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
85 if max_ordinal == 0 {
87 return Ok(());
88 }
89 depth.increment()?;
90 let envelope_size = 8;
91 let bytes_len = max_ordinal as usize * envelope_size;
92 #[allow(unused_variables)]
93 let offset = encoder.out_of_line_offset(bytes_len);
94 let mut _prev_end_offset: usize = 0;
95
96 Ok(())
97 }
98 }
99
100 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MonitorOptions {
101 #[inline(always)]
102 fn new_empty() -> Self {
103 Self::default()
104 }
105
106 unsafe fn decode(
107 &mut self,
108 decoder: &mut fidl::encoding::Decoder<'_, D>,
109 offset: usize,
110 mut depth: fidl::encoding::Depth,
111 ) -> fidl::Result<()> {
112 decoder.debug_check_bounds::<Self>(offset);
113 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
114 None => return Err(fidl::Error::NotNullable),
115 Some(len) => len,
116 };
117 if len == 0 {
119 return Ok(());
120 };
121 depth.increment()?;
122 let envelope_size = 8;
123 let bytes_len = len * envelope_size;
124 let offset = decoder.out_of_line_offset(bytes_len)?;
125 let mut _next_ordinal_to_read = 0;
127 let mut next_offset = offset;
128 let end_offset = offset + bytes_len;
129
130 while next_offset < end_offset {
132 _next_ordinal_to_read += 1;
133 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
134 next_offset += envelope_size;
135 }
136
137 Ok(())
138 }
139 }
140
141 impl Snapshot {
142 #[inline(always)]
143 fn max_ordinal_present(&self) -> u64 {
144 if let Some(_) = self.http_active {
145 return 4;
146 }
147 if let Some(_) = self.dns_active {
148 return 3;
149 }
150 if let Some(_) = self.gateway_reachable {
151 return 2;
152 }
153 if let Some(_) = self.internet_available {
154 return 1;
155 }
156 0
157 }
158 }
159
160 impl fidl::encoding::ValueTypeMarker for Snapshot {
161 type Borrowed<'a> = &'a Self;
162 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
163 value
164 }
165 }
166
167 unsafe impl fidl::encoding::TypeMarker for Snapshot {
168 type Owned = Self;
169
170 #[inline(always)]
171 fn inline_align(_context: fidl::encoding::Context) -> usize {
172 8
173 }
174
175 #[inline(always)]
176 fn inline_size(_context: fidl::encoding::Context) -> usize {
177 16
178 }
179 }
180
181 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Snapshot, D> for &Snapshot {
182 unsafe fn encode(
183 self,
184 encoder: &mut fidl::encoding::Encoder<'_, D>,
185 offset: usize,
186 mut depth: fidl::encoding::Depth,
187 ) -> fidl::Result<()> {
188 encoder.debug_check_bounds::<Snapshot>(offset);
189 let max_ordinal: u64 = self.max_ordinal_present();
191 encoder.write_num(max_ordinal, offset);
192 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
193 if max_ordinal == 0 {
195 return Ok(());
196 }
197 depth.increment()?;
198 let envelope_size = 8;
199 let bytes_len = max_ordinal as usize * envelope_size;
200 #[allow(unused_variables)]
201 let offset = encoder.out_of_line_offset(bytes_len);
202 let mut _prev_end_offset: usize = 0;
203 if 1 > max_ordinal {
204 return Ok(());
205 }
206
207 let cur_offset: usize = (1 - 1) * envelope_size;
210
211 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
213
214 fidl::encoding::encode_in_envelope_optional::<bool, D>(
219 self.internet_available
220 .as_ref()
221 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
222 encoder,
223 offset + cur_offset,
224 depth,
225 )?;
226
227 _prev_end_offset = cur_offset + envelope_size;
228 if 2 > max_ordinal {
229 return Ok(());
230 }
231
232 let cur_offset: usize = (2 - 1) * envelope_size;
235
236 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
238
239 fidl::encoding::encode_in_envelope_optional::<bool, D>(
244 self.gateway_reachable
245 .as_ref()
246 .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
247 encoder,
248 offset + cur_offset,
249 depth,
250 )?;
251
252 _prev_end_offset = cur_offset + envelope_size;
253 if 3 > max_ordinal {
254 return Ok(());
255 }
256
257 let cur_offset: usize = (3 - 1) * envelope_size;
260
261 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
263
264 fidl::encoding::encode_in_envelope_optional::<bool, D>(
269 self.dns_active.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
270 encoder,
271 offset + cur_offset,
272 depth,
273 )?;
274
275 _prev_end_offset = cur_offset + envelope_size;
276 if 4 > max_ordinal {
277 return Ok(());
278 }
279
280 let cur_offset: usize = (4 - 1) * envelope_size;
283
284 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
286
287 fidl::encoding::encode_in_envelope_optional::<bool, D>(
292 self.http_active.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
293 encoder,
294 offset + cur_offset,
295 depth,
296 )?;
297
298 _prev_end_offset = cur_offset + envelope_size;
299
300 Ok(())
301 }
302 }
303
304 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Snapshot {
305 #[inline(always)]
306 fn new_empty() -> Self {
307 Self::default()
308 }
309
310 unsafe fn decode(
311 &mut self,
312 decoder: &mut fidl::encoding::Decoder<'_, D>,
313 offset: usize,
314 mut depth: fidl::encoding::Depth,
315 ) -> fidl::Result<()> {
316 decoder.debug_check_bounds::<Self>(offset);
317 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
318 None => return Err(fidl::Error::NotNullable),
319 Some(len) => len,
320 };
321 if len == 0 {
323 return Ok(());
324 };
325 depth.increment()?;
326 let envelope_size = 8;
327 let bytes_len = len * envelope_size;
328 let offset = decoder.out_of_line_offset(bytes_len)?;
329 let mut _next_ordinal_to_read = 0;
331 let mut next_offset = offset;
332 let end_offset = offset + bytes_len;
333 _next_ordinal_to_read += 1;
334 if next_offset >= end_offset {
335 return Ok(());
336 }
337
338 while _next_ordinal_to_read < 1 {
340 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
341 _next_ordinal_to_read += 1;
342 next_offset += envelope_size;
343 }
344
345 let next_out_of_line = decoder.next_out_of_line();
346 let handles_before = decoder.remaining_handles();
347 if let Some((inlined, num_bytes, num_handles)) =
348 fidl::encoding::decode_envelope_header(decoder, next_offset)?
349 {
350 let member_inline_size =
351 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
352 if inlined != (member_inline_size <= 4) {
353 return Err(fidl::Error::InvalidInlineBitInEnvelope);
354 }
355 let inner_offset;
356 let mut inner_depth = depth.clone();
357 if inlined {
358 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
359 inner_offset = next_offset;
360 } else {
361 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
362 inner_depth.increment()?;
363 }
364 let val_ref =
365 self.internet_available.get_or_insert_with(|| fidl::new_empty!(bool, D));
366 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
367 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
368 {
369 return Err(fidl::Error::InvalidNumBytesInEnvelope);
370 }
371 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
372 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
373 }
374 }
375
376 next_offset += envelope_size;
377 _next_ordinal_to_read += 1;
378 if next_offset >= end_offset {
379 return Ok(());
380 }
381
382 while _next_ordinal_to_read < 2 {
384 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
385 _next_ordinal_to_read += 1;
386 next_offset += envelope_size;
387 }
388
389 let next_out_of_line = decoder.next_out_of_line();
390 let handles_before = decoder.remaining_handles();
391 if let Some((inlined, num_bytes, num_handles)) =
392 fidl::encoding::decode_envelope_header(decoder, next_offset)?
393 {
394 let member_inline_size =
395 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
396 if inlined != (member_inline_size <= 4) {
397 return Err(fidl::Error::InvalidInlineBitInEnvelope);
398 }
399 let inner_offset;
400 let mut inner_depth = depth.clone();
401 if inlined {
402 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
403 inner_offset = next_offset;
404 } else {
405 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
406 inner_depth.increment()?;
407 }
408 let val_ref =
409 self.gateway_reachable.get_or_insert_with(|| fidl::new_empty!(bool, D));
410 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
411 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
412 {
413 return Err(fidl::Error::InvalidNumBytesInEnvelope);
414 }
415 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
416 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
417 }
418 }
419
420 next_offset += envelope_size;
421 _next_ordinal_to_read += 1;
422 if next_offset >= end_offset {
423 return Ok(());
424 }
425
426 while _next_ordinal_to_read < 3 {
428 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
429 _next_ordinal_to_read += 1;
430 next_offset += envelope_size;
431 }
432
433 let next_out_of_line = decoder.next_out_of_line();
434 let handles_before = decoder.remaining_handles();
435 if let Some((inlined, num_bytes, num_handles)) =
436 fidl::encoding::decode_envelope_header(decoder, next_offset)?
437 {
438 let member_inline_size =
439 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
440 if inlined != (member_inline_size <= 4) {
441 return Err(fidl::Error::InvalidInlineBitInEnvelope);
442 }
443 let inner_offset;
444 let mut inner_depth = depth.clone();
445 if inlined {
446 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
447 inner_offset = next_offset;
448 } else {
449 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
450 inner_depth.increment()?;
451 }
452 let val_ref = self.dns_active.get_or_insert_with(|| fidl::new_empty!(bool, D));
453 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
454 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
455 {
456 return Err(fidl::Error::InvalidNumBytesInEnvelope);
457 }
458 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
459 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
460 }
461 }
462
463 next_offset += envelope_size;
464 _next_ordinal_to_read += 1;
465 if next_offset >= end_offset {
466 return Ok(());
467 }
468
469 while _next_ordinal_to_read < 4 {
471 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
472 _next_ordinal_to_read += 1;
473 next_offset += envelope_size;
474 }
475
476 let next_out_of_line = decoder.next_out_of_line();
477 let handles_before = decoder.remaining_handles();
478 if let Some((inlined, num_bytes, num_handles)) =
479 fidl::encoding::decode_envelope_header(decoder, next_offset)?
480 {
481 let member_inline_size =
482 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
483 if inlined != (member_inline_size <= 4) {
484 return Err(fidl::Error::InvalidInlineBitInEnvelope);
485 }
486 let inner_offset;
487 let mut inner_depth = depth.clone();
488 if inlined {
489 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
490 inner_offset = next_offset;
491 } else {
492 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
493 inner_depth.increment()?;
494 }
495 let val_ref = self.http_active.get_or_insert_with(|| fidl::new_empty!(bool, D));
496 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
497 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
498 {
499 return Err(fidl::Error::InvalidNumBytesInEnvelope);
500 }
501 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
502 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
503 }
504 }
505
506 next_offset += envelope_size;
507
508 while next_offset < end_offset {
510 _next_ordinal_to_read += 1;
511 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
512 next_offset += envelope_size;
513 }
514
515 Ok(())
516 }
517 }
518}