Skip to main content

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