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
11pub type HeaderName = Vec<u8>;
13
14pub type HeaderValue = Vec<u8>;
16
17pub type Method = String;
18
19#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21#[repr(u32)]
22pub enum Error {
23 Internal = 1,
26 UnableToParse = 2,
28 ChannelClosed = 3,
30 Connect = 4,
32 DeadlineExceeded = 5,
34}
35
36impl Error {
37 #[inline]
38 pub fn from_primitive(prim: u32) -> Option<Self> {
39 match prim {
40 1 => Some(Self::Internal),
41 2 => Some(Self::UnableToParse),
42 3 => Some(Self::ChannelClosed),
43 4 => Some(Self::Connect),
44 5 => Some(Self::DeadlineExceeded),
45 _ => None,
46 }
47 }
48
49 #[inline]
50 pub const fn into_primitive(self) -> u32 {
51 self as u32
52 }
53
54 #[deprecated = "Strict enums should not use `is_unknown`"]
55 #[inline]
56 pub fn is_unknown(&self) -> bool {
57 false
58 }
59}
60
61#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
63pub struct Header {
64 pub name: Vec<u8>,
66 pub value: Vec<u8>,
68}
69
70impl fidl::Persistable for Header {}
71
72#[derive(Clone, Debug, Default, PartialEq)]
78pub struct RedirectTarget {
79 pub method: Option<String>,
81 pub url: Option<String>,
83 pub referrer: Option<String>,
85 #[doc(hidden)]
86 pub __source_breaking: fidl::marker::SourceBreaking,
87}
88
89impl fidl::Persistable for RedirectTarget {}
90
91mod internal {
92 use super::*;
93 unsafe impl fidl::encoding::TypeMarker for Error {
94 type Owned = Self;
95
96 #[inline(always)]
97 fn inline_align(_context: fidl::encoding::Context) -> usize {
98 std::mem::align_of::<u32>()
99 }
100
101 #[inline(always)]
102 fn inline_size(_context: fidl::encoding::Context) -> usize {
103 std::mem::size_of::<u32>()
104 }
105
106 #[inline(always)]
107 fn encode_is_copy() -> bool {
108 true
109 }
110
111 #[inline(always)]
112 fn decode_is_copy() -> bool {
113 false
114 }
115 }
116
117 impl fidl::encoding::ValueTypeMarker for Error {
118 type Borrowed<'a> = Self;
119 #[inline(always)]
120 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
121 *value
122 }
123 }
124
125 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
126 #[inline]
127 unsafe fn encode(
128 self,
129 encoder: &mut fidl::encoding::Encoder<'_, D>,
130 offset: usize,
131 _depth: fidl::encoding::Depth,
132 ) -> fidl::Result<()> {
133 encoder.debug_check_bounds::<Self>(offset);
134 encoder.write_num(self.into_primitive(), offset);
135 Ok(())
136 }
137 }
138
139 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
140 #[inline(always)]
141 fn new_empty() -> Self {
142 Self::Internal
143 }
144
145 #[inline]
146 unsafe fn decode(
147 &mut self,
148 decoder: &mut fidl::encoding::Decoder<'_, D>,
149 offset: usize,
150 _depth: fidl::encoding::Depth,
151 ) -> fidl::Result<()> {
152 decoder.debug_check_bounds::<Self>(offset);
153 let prim = decoder.read_num::<u32>(offset);
154
155 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
156 Ok(())
157 }
158 }
159
160 impl fidl::encoding::ValueTypeMarker for Header {
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 Header {
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 32
178 }
179 }
180
181 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Header, D> for &Header {
182 #[inline]
183 unsafe fn encode(
184 self,
185 encoder: &mut fidl::encoding::Encoder<'_, D>,
186 offset: usize,
187 _depth: fidl::encoding::Depth,
188 ) -> fidl::Result<()> {
189 encoder.debug_check_bounds::<Header>(offset);
190 fidl::encoding::Encode::<Header, D>::encode(
192 (
193 <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
194 <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
195 ),
196 encoder, offset, _depth
197 )
198 }
199 }
200 unsafe impl<
201 D: fidl::encoding::ResourceDialect,
202 T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
203 T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
204 > fidl::encoding::Encode<Header, D> for (T0, T1)
205 {
206 #[inline]
207 unsafe fn encode(
208 self,
209 encoder: &mut fidl::encoding::Encoder<'_, D>,
210 offset: usize,
211 depth: fidl::encoding::Depth,
212 ) -> fidl::Result<()> {
213 encoder.debug_check_bounds::<Header>(offset);
214 self.0.encode(encoder, offset + 0, depth)?;
218 self.1.encode(encoder, offset + 16, depth)?;
219 Ok(())
220 }
221 }
222
223 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Header {
224 #[inline(always)]
225 fn new_empty() -> Self {
226 Self {
227 name: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
228 value: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
229 }
230 }
231
232 #[inline]
233 unsafe fn decode(
234 &mut self,
235 decoder: &mut fidl::encoding::Decoder<'_, D>,
236 offset: usize,
237 _depth: fidl::encoding::Depth,
238 ) -> fidl::Result<()> {
239 decoder.debug_check_bounds::<Self>(offset);
240 fidl::decode!(
242 fidl::encoding::UnboundedVector<u8>,
243 D,
244 &mut self.name,
245 decoder,
246 offset + 0,
247 _depth
248 )?;
249 fidl::decode!(
250 fidl::encoding::UnboundedVector<u8>,
251 D,
252 &mut self.value,
253 decoder,
254 offset + 16,
255 _depth
256 )?;
257 Ok(())
258 }
259 }
260
261 impl RedirectTarget {
262 #[inline(always)]
263 fn max_ordinal_present(&self) -> u64 {
264 if let Some(_) = self.referrer {
265 return 3;
266 }
267 if let Some(_) = self.url {
268 return 2;
269 }
270 if let Some(_) = self.method {
271 return 1;
272 }
273 0
274 }
275 }
276
277 impl fidl::encoding::ValueTypeMarker for RedirectTarget {
278 type Borrowed<'a> = &'a Self;
279 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
280 value
281 }
282 }
283
284 unsafe impl fidl::encoding::TypeMarker for RedirectTarget {
285 type Owned = Self;
286
287 #[inline(always)]
288 fn inline_align(_context: fidl::encoding::Context) -> usize {
289 8
290 }
291
292 #[inline(always)]
293 fn inline_size(_context: fidl::encoding::Context) -> usize {
294 16
295 }
296 }
297
298 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RedirectTarget, D>
299 for &RedirectTarget
300 {
301 unsafe fn encode(
302 self,
303 encoder: &mut fidl::encoding::Encoder<'_, D>,
304 offset: usize,
305 mut depth: fidl::encoding::Depth,
306 ) -> fidl::Result<()> {
307 encoder.debug_check_bounds::<RedirectTarget>(offset);
308 let max_ordinal: u64 = self.max_ordinal_present();
310 encoder.write_num(max_ordinal, offset);
311 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
312 if max_ordinal == 0 {
314 return Ok(());
315 }
316 depth.increment()?;
317 let envelope_size = 8;
318 let bytes_len = max_ordinal as usize * envelope_size;
319 #[allow(unused_variables)]
320 let offset = encoder.out_of_line_offset(bytes_len);
321 let mut _prev_end_offset: usize = 0;
322 if 1 > max_ordinal {
323 return Ok(());
324 }
325
326 let cur_offset: usize = (1 - 1) * envelope_size;
329
330 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
332
333 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<1024>, D>(
338 self.method.as_ref().map(<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow),
339 encoder, offset + cur_offset, depth
340 )?;
341
342 _prev_end_offset = cur_offset + envelope_size;
343 if 2 > max_ordinal {
344 return Ok(());
345 }
346
347 let cur_offset: usize = (2 - 1) * envelope_size;
350
351 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
353
354 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
359 self.url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
360 encoder, offset + cur_offset, depth
361 )?;
362
363 _prev_end_offset = cur_offset + envelope_size;
364 if 3 > max_ordinal {
365 return Ok(());
366 }
367
368 let cur_offset: usize = (3 - 1) * envelope_size;
371
372 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
374
375 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
380 self.referrer.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
381 encoder, offset + cur_offset, depth
382 )?;
383
384 _prev_end_offset = cur_offset + envelope_size;
385
386 Ok(())
387 }
388 }
389
390 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RedirectTarget {
391 #[inline(always)]
392 fn new_empty() -> Self {
393 Self::default()
394 }
395
396 unsafe fn decode(
397 &mut self,
398 decoder: &mut fidl::encoding::Decoder<'_, D>,
399 offset: usize,
400 mut depth: fidl::encoding::Depth,
401 ) -> fidl::Result<()> {
402 decoder.debug_check_bounds::<Self>(offset);
403 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
404 None => return Err(fidl::Error::NotNullable),
405 Some(len) => len,
406 };
407 if len == 0 {
409 return Ok(());
410 };
411 depth.increment()?;
412 let envelope_size = 8;
413 let bytes_len = len * envelope_size;
414 let offset = decoder.out_of_line_offset(bytes_len)?;
415 let mut _next_ordinal_to_read = 0;
417 let mut next_offset = offset;
418 let end_offset = offset + bytes_len;
419 _next_ordinal_to_read += 1;
420 if next_offset >= end_offset {
421 return Ok(());
422 }
423
424 while _next_ordinal_to_read < 1 {
426 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
427 _next_ordinal_to_read += 1;
428 next_offset += envelope_size;
429 }
430
431 let next_out_of_line = decoder.next_out_of_line();
432 let handles_before = decoder.remaining_handles();
433 if let Some((inlined, num_bytes, num_handles)) =
434 fidl::encoding::decode_envelope_header(decoder, next_offset)?
435 {
436 let member_inline_size = <fidl::encoding::BoundedString<1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
437 if inlined != (member_inline_size <= 4) {
438 return Err(fidl::Error::InvalidInlineBitInEnvelope);
439 }
440 let inner_offset;
441 let mut inner_depth = depth.clone();
442 if inlined {
443 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
444 inner_offset = next_offset;
445 } else {
446 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
447 inner_depth.increment()?;
448 }
449 let val_ref = self.method.get_or_insert_with(|| {
450 fidl::new_empty!(fidl::encoding::BoundedString<1024>, D)
451 });
452 fidl::decode!(
453 fidl::encoding::BoundedString<1024>,
454 D,
455 val_ref,
456 decoder,
457 inner_offset,
458 inner_depth
459 )?;
460 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
461 {
462 return Err(fidl::Error::InvalidNumBytesInEnvelope);
463 }
464 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
465 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
466 }
467 }
468
469 next_offset += envelope_size;
470 _next_ordinal_to_read += 1;
471 if next_offset >= end_offset {
472 return Ok(());
473 }
474
475 while _next_ordinal_to_read < 2 {
477 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
478 _next_ordinal_to_read += 1;
479 next_offset += envelope_size;
480 }
481
482 let next_out_of_line = decoder.next_out_of_line();
483 let handles_before = decoder.remaining_handles();
484 if let Some((inlined, num_bytes, num_handles)) =
485 fidl::encoding::decode_envelope_header(decoder, next_offset)?
486 {
487 let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
488 if inlined != (member_inline_size <= 4) {
489 return Err(fidl::Error::InvalidInlineBitInEnvelope);
490 }
491 let inner_offset;
492 let mut inner_depth = depth.clone();
493 if inlined {
494 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
495 inner_offset = next_offset;
496 } else {
497 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
498 inner_depth.increment()?;
499 }
500 let val_ref = self.url.get_or_insert_with(|| {
501 fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
502 });
503 fidl::decode!(
504 fidl::encoding::BoundedString<4096>,
505 D,
506 val_ref,
507 decoder,
508 inner_offset,
509 inner_depth
510 )?;
511 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
512 {
513 return Err(fidl::Error::InvalidNumBytesInEnvelope);
514 }
515 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
516 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
517 }
518 }
519
520 next_offset += envelope_size;
521 _next_ordinal_to_read += 1;
522 if next_offset >= end_offset {
523 return Ok(());
524 }
525
526 while _next_ordinal_to_read < 3 {
528 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
529 _next_ordinal_to_read += 1;
530 next_offset += envelope_size;
531 }
532
533 let next_out_of_line = decoder.next_out_of_line();
534 let handles_before = decoder.remaining_handles();
535 if let Some((inlined, num_bytes, num_handles)) =
536 fidl::encoding::decode_envelope_header(decoder, next_offset)?
537 {
538 let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
539 if inlined != (member_inline_size <= 4) {
540 return Err(fidl::Error::InvalidInlineBitInEnvelope);
541 }
542 let inner_offset;
543 let mut inner_depth = depth.clone();
544 if inlined {
545 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
546 inner_offset = next_offset;
547 } else {
548 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
549 inner_depth.increment()?;
550 }
551 let val_ref = self.referrer.get_or_insert_with(|| {
552 fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
553 });
554 fidl::decode!(
555 fidl::encoding::BoundedString<4096>,
556 D,
557 val_ref,
558 decoder,
559 inner_offset,
560 inner_depth
561 )?;
562 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
563 {
564 return Err(fidl::Error::InvalidNumBytesInEnvelope);
565 }
566 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
567 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
568 }
569 }
570
571 next_offset += envelope_size;
572
573 while next_offset < end_offset {
575 _next_ordinal_to_read += 1;
576 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
577 next_offset += envelope_size;
578 }
579
580 Ok(())
581 }
582 }
583}