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