Skip to main content

fdomain_fuchsia_net_resources/
fdomain_fuchsia_net_resources.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_net_resources_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// An authorization credential for an interface, which allows the caller to
14/// prove ownership of the interface (e.g. by converting the credential into a
15/// [`ProofOfInterfaceAuthorization`].
16#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct GrantForInterfaceAuthorization {
18    /// The ID of the interface this credential is authenticating.
19    pub interface_id: u64,
20    /// The EVENT providing authentication over this interface.
21    pub token: fdomain_client::Event,
22}
23
24impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
25    for GrantForInterfaceAuthorization
26{
27}
28
29/// A credential passed into the `fuchsia.net.*` family of APIs to authenticate
30/// access to a particular interface. The Netstack only needs the ability to
31/// inspect the token's basic info when proving that the client is authorized
32/// to access a resource.
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct ProofOfInterfaceAuthorization {
35    /// The ID of the interface this credential is authenticating.
36    pub interface_id: u64,
37    /// The EVENT providing authentication over this interface.
38    pub token: fdomain_client::Event,
39}
40
41impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
42    for ProofOfInterfaceAuthorization
43{
44}
45
46/// A token representing a wake group that can be provided to networking
47/// resources (such as sockets) to add them to the group, and waited upon to
48/// receive wake signals.
49#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct WakeGroupToken {
51    pub token: fdomain_client::Event,
52}
53
54impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for WakeGroupToken {}
55
56mod internal {
57    use super::*;
58
59    impl fidl::encoding::ResourceTypeMarker for GrantForInterfaceAuthorization {
60        type Borrowed<'a> = &'a mut Self;
61        fn take_or_borrow<'a>(
62            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
63        ) -> Self::Borrowed<'a> {
64            value
65        }
66    }
67
68    unsafe impl fidl::encoding::TypeMarker for GrantForInterfaceAuthorization {
69        type Owned = Self;
70
71        #[inline(always)]
72        fn inline_align(_context: fidl::encoding::Context) -> usize {
73            8
74        }
75
76        #[inline(always)]
77        fn inline_size(_context: fidl::encoding::Context) -> usize {
78            16
79        }
80    }
81
82    unsafe impl
83        fidl::encoding::Encode<
84            GrantForInterfaceAuthorization,
85            fdomain_client::fidl::FDomainResourceDialect,
86        > for &mut GrantForInterfaceAuthorization
87    {
88        #[inline]
89        unsafe fn encode(
90            self,
91            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
92            offset: usize,
93            _depth: fidl::encoding::Depth,
94        ) -> fidl::Result<()> {
95            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
96            // Delegate to tuple encoding.
97            fidl::encoding::Encode::<
98                GrantForInterfaceAuthorization,
99                fdomain_client::fidl::FDomainResourceDialect,
100            >::encode(
101                (
102                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
103                    <fidl::encoding::HandleType<
104                        fdomain_client::Event,
105                        { fidl::ObjectType::EVENT.into_raw() },
106                        3,
107                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
108                        &mut self.token
109                    ),
110                ),
111                encoder,
112                offset,
113                _depth,
114            )
115        }
116    }
117    unsafe impl<
118        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
119        T1: fidl::encoding::Encode<
120                fidl::encoding::HandleType<
121                    fdomain_client::Event,
122                    { fidl::ObjectType::EVENT.into_raw() },
123                    3,
124                >,
125                fdomain_client::fidl::FDomainResourceDialect,
126            >,
127    >
128        fidl::encoding::Encode<
129            GrantForInterfaceAuthorization,
130            fdomain_client::fidl::FDomainResourceDialect,
131        > for (T0, T1)
132    {
133        #[inline]
134        unsafe fn encode(
135            self,
136            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
137            offset: usize,
138            depth: fidl::encoding::Depth,
139        ) -> fidl::Result<()> {
140            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
141            // Zero out padding regions. There's no need to apply masks
142            // because the unmasked parts will be overwritten by fields.
143            unsafe {
144                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
145                (ptr as *mut u64).write_unaligned(0);
146            }
147            // Write the fields.
148            self.0.encode(encoder, offset + 0, depth)?;
149            self.1.encode(encoder, offset + 8, depth)?;
150            Ok(())
151        }
152    }
153
154    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
155        for GrantForInterfaceAuthorization
156    {
157        #[inline(always)]
158        fn new_empty() -> Self {
159            Self {
160                interface_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
161                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect),
162            }
163        }
164
165        #[inline]
166        unsafe fn decode(
167            &mut self,
168            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
169            offset: usize,
170            _depth: fidl::encoding::Depth,
171        ) -> fidl::Result<()> {
172            decoder.debug_check_bounds::<Self>(offset);
173            // Verify that padding bytes are zero.
174            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
175            let padval = unsafe { (ptr as *const u64).read_unaligned() };
176            let mask = 0xffffffff00000000u64;
177            let maskedval = padval & mask;
178            if maskedval != 0 {
179                return Err(fidl::Error::NonZeroPadding {
180                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
181                });
182            }
183            fidl::decode!(
184                u64,
185                fdomain_client::fidl::FDomainResourceDialect,
186                &mut self.interface_id,
187                decoder,
188                offset + 0,
189                _depth
190            )?;
191            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect, &mut self.token, decoder, offset + 8, _depth)?;
192            Ok(())
193        }
194    }
195
196    impl fidl::encoding::ResourceTypeMarker for ProofOfInterfaceAuthorization {
197        type Borrowed<'a> = &'a mut Self;
198        fn take_or_borrow<'a>(
199            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
200        ) -> Self::Borrowed<'a> {
201            value
202        }
203    }
204
205    unsafe impl fidl::encoding::TypeMarker for ProofOfInterfaceAuthorization {
206        type Owned = Self;
207
208        #[inline(always)]
209        fn inline_align(_context: fidl::encoding::Context) -> usize {
210            8
211        }
212
213        #[inline(always)]
214        fn inline_size(_context: fidl::encoding::Context) -> usize {
215            16
216        }
217    }
218
219    unsafe impl
220        fidl::encoding::Encode<
221            ProofOfInterfaceAuthorization,
222            fdomain_client::fidl::FDomainResourceDialect,
223        > for &mut ProofOfInterfaceAuthorization
224    {
225        #[inline]
226        unsafe fn encode(
227            self,
228            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
229            offset: usize,
230            _depth: fidl::encoding::Depth,
231        ) -> fidl::Result<()> {
232            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
233            // Delegate to tuple encoding.
234            fidl::encoding::Encode::<
235                ProofOfInterfaceAuthorization,
236                fdomain_client::fidl::FDomainResourceDialect,
237            >::encode(
238                (
239                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
240                    <fidl::encoding::HandleType<
241                        fdomain_client::Event,
242                        { fidl::ObjectType::EVENT.into_raw() },
243                        0,
244                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
245                        &mut self.token
246                    ),
247                ),
248                encoder,
249                offset,
250                _depth,
251            )
252        }
253    }
254    unsafe impl<
255        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
256        T1: fidl::encoding::Encode<
257                fidl::encoding::HandleType<
258                    fdomain_client::Event,
259                    { fidl::ObjectType::EVENT.into_raw() },
260                    0,
261                >,
262                fdomain_client::fidl::FDomainResourceDialect,
263            >,
264    >
265        fidl::encoding::Encode<
266            ProofOfInterfaceAuthorization,
267            fdomain_client::fidl::FDomainResourceDialect,
268        > for (T0, T1)
269    {
270        #[inline]
271        unsafe fn encode(
272            self,
273            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
274            offset: usize,
275            depth: fidl::encoding::Depth,
276        ) -> fidl::Result<()> {
277            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
278            // Zero out padding regions. There's no need to apply masks
279            // because the unmasked parts will be overwritten by fields.
280            unsafe {
281                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
282                (ptr as *mut u64).write_unaligned(0);
283            }
284            // Write the fields.
285            self.0.encode(encoder, offset + 0, depth)?;
286            self.1.encode(encoder, offset + 8, depth)?;
287            Ok(())
288        }
289    }
290
291    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
292        for ProofOfInterfaceAuthorization
293    {
294        #[inline(always)]
295        fn new_empty() -> Self {
296            Self {
297                interface_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
298                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>, fdomain_client::fidl::FDomainResourceDialect),
299            }
300        }
301
302        #[inline]
303        unsafe fn decode(
304            &mut self,
305            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
306            offset: usize,
307            _depth: fidl::encoding::Depth,
308        ) -> fidl::Result<()> {
309            decoder.debug_check_bounds::<Self>(offset);
310            // Verify that padding bytes are zero.
311            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
312            let padval = unsafe { (ptr as *const u64).read_unaligned() };
313            let mask = 0xffffffff00000000u64;
314            let maskedval = padval & mask;
315            if maskedval != 0 {
316                return Err(fidl::Error::NonZeroPadding {
317                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
318                });
319            }
320            fidl::decode!(
321                u64,
322                fdomain_client::fidl::FDomainResourceDialect,
323                &mut self.interface_id,
324                decoder,
325                offset + 0,
326                _depth
327            )?;
328            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>, fdomain_client::fidl::FDomainResourceDialect, &mut self.token, decoder, offset + 8, _depth)?;
329            Ok(())
330        }
331    }
332
333    impl fidl::encoding::ResourceTypeMarker for WakeGroupToken {
334        type Borrowed<'a> = &'a mut Self;
335        fn take_or_borrow<'a>(
336            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
337        ) -> Self::Borrowed<'a> {
338            value
339        }
340    }
341
342    unsafe impl fidl::encoding::TypeMarker for WakeGroupToken {
343        type Owned = Self;
344
345        #[inline(always)]
346        fn inline_align(_context: fidl::encoding::Context) -> usize {
347            4
348        }
349
350        #[inline(always)]
351        fn inline_size(_context: fidl::encoding::Context) -> usize {
352            4
353        }
354    }
355
356    unsafe impl fidl::encoding::Encode<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>
357        for &mut WakeGroupToken
358    {
359        #[inline]
360        unsafe fn encode(
361            self,
362            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
363            offset: usize,
364            _depth: fidl::encoding::Depth,
365        ) -> fidl::Result<()> {
366            encoder.debug_check_bounds::<WakeGroupToken>(offset);
367            // Delegate to tuple encoding.
368            fidl::encoding::Encode::<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>::encode(
369                (
370                    <fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 16387> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
371                ),
372                encoder, offset, _depth
373            )
374        }
375    }
376    unsafe impl<
377        T0: fidl::encoding::Encode<
378                fidl::encoding::HandleType<
379                    fdomain_client::Event,
380                    { fidl::ObjectType::EVENT.into_raw() },
381                    16387,
382                >,
383                fdomain_client::fidl::FDomainResourceDialect,
384            >,
385    > fidl::encoding::Encode<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>
386        for (T0,)
387    {
388        #[inline]
389        unsafe fn encode(
390            self,
391            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
392            offset: usize,
393            depth: fidl::encoding::Depth,
394        ) -> fidl::Result<()> {
395            encoder.debug_check_bounds::<WakeGroupToken>(offset);
396            // Zero out padding regions. There's no need to apply masks
397            // because the unmasked parts will be overwritten by fields.
398            // Write the fields.
399            self.0.encode(encoder, offset + 0, depth)?;
400            Ok(())
401        }
402    }
403
404    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for WakeGroupToken {
405        #[inline(always)]
406        fn new_empty() -> Self {
407            Self {
408                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 16387>, fdomain_client::fidl::FDomainResourceDialect),
409            }
410        }
411
412        #[inline]
413        unsafe fn decode(
414            &mut self,
415            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
416            offset: usize,
417            _depth: fidl::encoding::Depth,
418        ) -> fidl::Result<()> {
419            decoder.debug_check_bounds::<Self>(offset);
420            // Verify that padding bytes are zero.
421            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 16387>, fdomain_client::fidl::FDomainResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
422            Ok(())
423        }
424    }
425}