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.
48#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49pub struct WakeGroupToken {
50    pub token: fdomain_client::Event,
51}
52
53impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for WakeGroupToken {}
54
55mod internal {
56    use super::*;
57
58    impl fidl::encoding::ResourceTypeMarker for GrantForInterfaceAuthorization {
59        type Borrowed<'a> = &'a mut Self;
60        fn take_or_borrow<'a>(
61            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
62        ) -> Self::Borrowed<'a> {
63            value
64        }
65    }
66
67    unsafe impl fidl::encoding::TypeMarker for GrantForInterfaceAuthorization {
68        type Owned = Self;
69
70        #[inline(always)]
71        fn inline_align(_context: fidl::encoding::Context) -> usize {
72            8
73        }
74
75        #[inline(always)]
76        fn inline_size(_context: fidl::encoding::Context) -> usize {
77            16
78        }
79    }
80
81    unsafe impl
82        fidl::encoding::Encode<
83            GrantForInterfaceAuthorization,
84            fdomain_client::fidl::FDomainResourceDialect,
85        > for &mut GrantForInterfaceAuthorization
86    {
87        #[inline]
88        unsafe fn encode(
89            self,
90            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
91            offset: usize,
92            _depth: fidl::encoding::Depth,
93        ) -> fidl::Result<()> {
94            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
95            // Delegate to tuple encoding.
96            fidl::encoding::Encode::<
97                GrantForInterfaceAuthorization,
98                fdomain_client::fidl::FDomainResourceDialect,
99            >::encode(
100                (
101                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
102                    <fidl::encoding::HandleType<
103                        fdomain_client::Event,
104                        { fidl::ObjectType::EVENT.into_raw() },
105                        3,
106                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
107                        &mut self.token
108                    ),
109                ),
110                encoder,
111                offset,
112                _depth,
113            )
114        }
115    }
116    unsafe impl<
117        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
118        T1: fidl::encoding::Encode<
119                fidl::encoding::HandleType<
120                    fdomain_client::Event,
121                    { fidl::ObjectType::EVENT.into_raw() },
122                    3,
123                >,
124                fdomain_client::fidl::FDomainResourceDialect,
125            >,
126    >
127        fidl::encoding::Encode<
128            GrantForInterfaceAuthorization,
129            fdomain_client::fidl::FDomainResourceDialect,
130        > for (T0, T1)
131    {
132        #[inline]
133        unsafe fn encode(
134            self,
135            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
136            offset: usize,
137            depth: fidl::encoding::Depth,
138        ) -> fidl::Result<()> {
139            encoder.debug_check_bounds::<GrantForInterfaceAuthorization>(offset);
140            // Zero out padding regions. There's no need to apply masks
141            // because the unmasked parts will be overwritten by fields.
142            unsafe {
143                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
144                (ptr as *mut u64).write_unaligned(0);
145            }
146            // Write the fields.
147            self.0.encode(encoder, offset + 0, depth)?;
148            self.1.encode(encoder, offset + 8, depth)?;
149            Ok(())
150        }
151    }
152
153    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
154        for GrantForInterfaceAuthorization
155    {
156        #[inline(always)]
157        fn new_empty() -> Self {
158            Self {
159                interface_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
160                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect),
161            }
162        }
163
164        #[inline]
165        unsafe fn decode(
166            &mut self,
167            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
168            offset: usize,
169            _depth: fidl::encoding::Depth,
170        ) -> fidl::Result<()> {
171            decoder.debug_check_bounds::<Self>(offset);
172            // Verify that padding bytes are zero.
173            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
174            let padval = unsafe { (ptr as *const u64).read_unaligned() };
175            let mask = 0xffffffff00000000u64;
176            let maskedval = padval & mask;
177            if maskedval != 0 {
178                return Err(fidl::Error::NonZeroPadding {
179                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
180                });
181            }
182            fidl::decode!(
183                u64,
184                fdomain_client::fidl::FDomainResourceDialect,
185                &mut self.interface_id,
186                decoder,
187                offset + 0,
188                _depth
189            )?;
190            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)?;
191            Ok(())
192        }
193    }
194
195    impl fidl::encoding::ResourceTypeMarker for ProofOfInterfaceAuthorization {
196        type Borrowed<'a> = &'a mut Self;
197        fn take_or_borrow<'a>(
198            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
199        ) -> Self::Borrowed<'a> {
200            value
201        }
202    }
203
204    unsafe impl fidl::encoding::TypeMarker for ProofOfInterfaceAuthorization {
205        type Owned = Self;
206
207        #[inline(always)]
208        fn inline_align(_context: fidl::encoding::Context) -> usize {
209            8
210        }
211
212        #[inline(always)]
213        fn inline_size(_context: fidl::encoding::Context) -> usize {
214            16
215        }
216    }
217
218    unsafe impl
219        fidl::encoding::Encode<
220            ProofOfInterfaceAuthorization,
221            fdomain_client::fidl::FDomainResourceDialect,
222        > for &mut ProofOfInterfaceAuthorization
223    {
224        #[inline]
225        unsafe fn encode(
226            self,
227            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
228            offset: usize,
229            _depth: fidl::encoding::Depth,
230        ) -> fidl::Result<()> {
231            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
232            // Delegate to tuple encoding.
233            fidl::encoding::Encode::<
234                ProofOfInterfaceAuthorization,
235                fdomain_client::fidl::FDomainResourceDialect,
236            >::encode(
237                (
238                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
239                    <fidl::encoding::HandleType<
240                        fdomain_client::Event,
241                        { fidl::ObjectType::EVENT.into_raw() },
242                        0,
243                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
244                        &mut self.token
245                    ),
246                ),
247                encoder,
248                offset,
249                _depth,
250            )
251        }
252    }
253    unsafe impl<
254        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
255        T1: fidl::encoding::Encode<
256                fidl::encoding::HandleType<
257                    fdomain_client::Event,
258                    { fidl::ObjectType::EVENT.into_raw() },
259                    0,
260                >,
261                fdomain_client::fidl::FDomainResourceDialect,
262            >,
263    >
264        fidl::encoding::Encode<
265            ProofOfInterfaceAuthorization,
266            fdomain_client::fidl::FDomainResourceDialect,
267        > for (T0, T1)
268    {
269        #[inline]
270        unsafe fn encode(
271            self,
272            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
273            offset: usize,
274            depth: fidl::encoding::Depth,
275        ) -> fidl::Result<()> {
276            encoder.debug_check_bounds::<ProofOfInterfaceAuthorization>(offset);
277            // Zero out padding regions. There's no need to apply masks
278            // because the unmasked parts will be overwritten by fields.
279            unsafe {
280                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
281                (ptr as *mut u64).write_unaligned(0);
282            }
283            // Write the fields.
284            self.0.encode(encoder, offset + 0, depth)?;
285            self.1.encode(encoder, offset + 8, depth)?;
286            Ok(())
287        }
288    }
289
290    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
291        for ProofOfInterfaceAuthorization
292    {
293        #[inline(always)]
294        fn new_empty() -> Self {
295            Self {
296                interface_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
297                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 0>, fdomain_client::fidl::FDomainResourceDialect),
298            }
299        }
300
301        #[inline]
302        unsafe fn decode(
303            &mut self,
304            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
305            offset: usize,
306            _depth: fidl::encoding::Depth,
307        ) -> fidl::Result<()> {
308            decoder.debug_check_bounds::<Self>(offset);
309            // Verify that padding bytes are zero.
310            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
311            let padval = unsafe { (ptr as *const u64).read_unaligned() };
312            let mask = 0xffffffff00000000u64;
313            let maskedval = padval & mask;
314            if maskedval != 0 {
315                return Err(fidl::Error::NonZeroPadding {
316                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
317                });
318            }
319            fidl::decode!(
320                u64,
321                fdomain_client::fidl::FDomainResourceDialect,
322                &mut self.interface_id,
323                decoder,
324                offset + 0,
325                _depth
326            )?;
327            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)?;
328            Ok(())
329        }
330    }
331
332    impl fidl::encoding::ResourceTypeMarker for WakeGroupToken {
333        type Borrowed<'a> = &'a mut Self;
334        fn take_or_borrow<'a>(
335            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
336        ) -> Self::Borrowed<'a> {
337            value
338        }
339    }
340
341    unsafe impl fidl::encoding::TypeMarker for WakeGroupToken {
342        type Owned = Self;
343
344        #[inline(always)]
345        fn inline_align(_context: fidl::encoding::Context) -> usize {
346            4
347        }
348
349        #[inline(always)]
350        fn inline_size(_context: fidl::encoding::Context) -> usize {
351            4
352        }
353    }
354
355    unsafe impl fidl::encoding::Encode<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>
356        for &mut WakeGroupToken
357    {
358        #[inline]
359        unsafe fn encode(
360            self,
361            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
362            offset: usize,
363            _depth: fidl::encoding::Depth,
364        ) -> fidl::Result<()> {
365            encoder.debug_check_bounds::<WakeGroupToken>(offset);
366            // Delegate to tuple encoding.
367            fidl::encoding::Encode::<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>::encode(
368                (
369                    <fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
370                ),
371                encoder, offset, _depth
372            )
373        }
374    }
375    unsafe impl<
376        T0: fidl::encoding::Encode<
377                fidl::encoding::HandleType<
378                    fdomain_client::Event,
379                    { fidl::ObjectType::EVENT.into_raw() },
380                    3,
381                >,
382                fdomain_client::fidl::FDomainResourceDialect,
383            >,
384    > fidl::encoding::Encode<WakeGroupToken, fdomain_client::fidl::FDomainResourceDialect>
385        for (T0,)
386    {
387        #[inline]
388        unsafe fn encode(
389            self,
390            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
391            offset: usize,
392            depth: fidl::encoding::Depth,
393        ) -> fidl::Result<()> {
394            encoder.debug_check_bounds::<WakeGroupToken>(offset);
395            // Zero out padding regions. There's no need to apply masks
396            // because the unmasked parts will be overwritten by fields.
397            // Write the fields.
398            self.0.encode(encoder, offset + 0, depth)?;
399            Ok(())
400        }
401    }
402
403    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for WakeGroupToken {
404        #[inline(always)]
405        fn new_empty() -> Self {
406            Self {
407                token: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect),
408            }
409        }
410
411        #[inline]
412        unsafe fn decode(
413            &mut self,
414            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
415            offset: usize,
416            _depth: fidl::encoding::Depth,
417        ) -> fidl::Result<()> {
418            decoder.debug_check_bounds::<Self>(offset);
419            // Verify that padding bytes are zero.
420            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
421            Ok(())
422        }
423    }
424}