Skip to main content

fidl_fuchsia_net_filter/
fidl_fuchsia_net_filter.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_filter_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControlOpenControllerRequest {
16    pub id: String,
17    pub request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ControlOpenControllerRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct ControlReopenDetachedControllerRequest {
27    pub key: ControllerKey,
28    pub request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for ControlReopenDetachedControllerRequest
33{
34}
35
36#[derive(Debug, PartialEq)]
37pub struct NamespaceControllerPushChangesRequest {
38    /// The changes to be applied.
39    pub changes: Vec<Change>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for NamespaceControllerPushChangesRequest
44{
45}
46
47#[derive(Debug, PartialEq)]
48pub struct NamespaceControllerRegisterEbpfProgramRequest {
49    pub handle: fidl_fuchsia_ebpf::ProgramHandle,
50    pub program: fidl_fuchsia_ebpf::VerifiedProgram,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for NamespaceControllerRegisterEbpfProgramRequest
55{
56}
57
58#[derive(Debug, PartialEq)]
59pub struct StateGetWatcherRequest {
60    pub options: WatcherOptions,
61    pub request: fidl::endpoints::ServerEnd<WatcherMarker>,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StateGetWatcherRequest {}
65
66#[derive(Debug, Default, PartialEq)]
67pub struct AttachEbpfProgramOptions {
68    pub hook: Option<SocketHook>,
69    pub program: Option<fidl_fuchsia_ebpf::VerifiedProgram>,
70    #[doc(hidden)]
71    pub __source_breaking: fidl::marker::SourceBreaking,
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for AttachEbpfProgramOptions {}
75
76#[derive(Debug, Default, PartialEq)]
77pub struct CommitOptions {
78    /// Whether additions or removals should be idempotent.
79    ///
80    /// For example, an update to add a resource when the resource already
81    /// exists will fail with an `ALREADY_EXISTS` error if `idempotent` is
82    /// `false`, but will succeed if it is `true`. Likewise for removals and
83    /// `*_NOT_FOUND`.
84    ///
85    /// If not set, interpreted as false.
86    pub idempotent: Option<bool>,
87    #[doc(hidden)]
88    pub __source_breaking: fidl::marker::SourceBreaking,
89}
90
91impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommitOptions {}
92
93#[derive(Debug)]
94pub enum ChangeValidationResult {
95    /// The changes are valid.
96    Ok(Empty),
97    /// More than [`MAX_COMMIT_SIZE`] pending changes were pushed before
98    /// being committed.
99    ///
100    /// The pending changes that were pushed to the server *before* this
101    /// call remain and can be committed by calling `Commit`.
102    TooManyChanges(Empty),
103    /// At least one of the changes provided was invalid. In order to be
104    /// maximally informative, a vector of results is returned where each
105    /// result corresponds to the change at the same index.
106    ///
107    /// NB: if any change in the batch pushed by the client is invalid,
108    /// *none* of the provided changes will be added to the server's set of
109    /// pending changes. In other words, this method is all-or-nothing:
110    /// either it succeeds and all changes in the batch are added to the
111    /// pending set, or it fails and none are.
112    ErrorOnChange(Vec<ChangeValidationError>),
113    #[doc(hidden)]
114    __SourceBreaking { unknown_ordinal: u64 },
115}
116
117/// Pattern that matches an unknown `ChangeValidationResult` member.
118#[macro_export]
119macro_rules! ChangeValidationResultUnknown {
120    () => {
121        _
122    };
123}
124
125// Custom PartialEq so that unknown variants are not equal to themselves.
126impl PartialEq for ChangeValidationResult {
127    fn eq(&self, other: &Self) -> bool {
128        match (self, other) {
129            (Self::Ok(x), Self::Ok(y)) => *x == *y,
130            (Self::TooManyChanges(x), Self::TooManyChanges(y)) => *x == *y,
131            (Self::ErrorOnChange(x), Self::ErrorOnChange(y)) => *x == *y,
132            _ => false,
133        }
134    }
135}
136
137impl ChangeValidationResult {
138    #[inline]
139    pub fn ordinal(&self) -> u64 {
140        match *self {
141            Self::Ok(_) => 1,
142            Self::TooManyChanges(_) => 2,
143            Self::ErrorOnChange(_) => 3,
144            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
145        }
146    }
147
148    #[inline]
149    pub fn unknown_variant_for_testing() -> Self {
150        Self::__SourceBreaking { unknown_ordinal: 0 }
151    }
152
153    #[inline]
154    pub fn is_unknown(&self) -> bool {
155        match self {
156            Self::__SourceBreaking { .. } => true,
157            _ => false,
158        }
159    }
160}
161
162impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ChangeValidationResult {}
163
164#[derive(Debug)]
165pub enum CommitResult {
166    /// The commit was successfully applied.
167    Ok(Empty),
168    /// One of the changes in the commit caused the specified rule's matcher
169    /// to be invalid for the context in which the rule will be evaluated.
170    ///
171    /// For example, this could be a matcher on the ingress interface on
172    /// a rule that is in a routine installed in the egress hook, or a
173    /// matcher on the source address specifying an IPv4 subnet that is
174    /// in an IPv6-only namespace.
175    RuleWithInvalidMatcher(RuleId),
176    /// One of the changes in the commit caused the specified rule's action
177    /// to be invalid for the context in which the rule will be evaluated.
178    ///
179    /// For example, this could be a NAT action in an IP routine.
180    RuleWithInvalidAction(RuleId),
181    /// The routine graph forms a cycle, including (at least) the specified
182    /// routine.
183    ///
184    /// Each uninstalled routine and all of the routines it directly or
185    /// transitively jumps to must form a DAG.
186    CyclicalRoutineGraph(RoutineId),
187    /// At least one of the changes provided was invalid given the current
188    /// state when `Commit` was called. In order to be maximally
189    /// informative, a vector of results is returned where each result
190    /// corresponds to the change at the same index (across all batches of
191    /// pending changes).
192    ErrorOnChange(Vec<CommitError>),
193    /// A rule has a TransparentProxy action without a corresponding valid
194    /// matcher: the rule must match on transport protocol to ensure that
195    /// the packet has either a TCP or UDP header.
196    TransparentProxyWithInvalidMatcher(RuleId),
197    /// A rule has a Redirect action without a corresponding valid matcher:
198    /// if the action specifies a destination port, the rule must match on
199    /// transport protocol to ensure that the packet has either a TCP or UDP
200    /// header.
201    RedirectWithInvalidMatcher(RuleId),
202    /// A rule has a Masquerade action without a corresponding valid
203    /// matcher: if the action specifies a source port, the rule must match
204    /// on transport protocol to ensure that the packet has either a TCP or
205    /// UDP header.
206    MasqueradeWithInvalidMatcher(RuleId),
207    /// A rule has a Reject action without a corresponding valid
208    /// configuration. Reject actions with the `TcpReset` reject type
209    /// must match TCP packets.
210    RejectWithInvalidMatcher(RuleId),
211    #[doc(hidden)]
212    __SourceBreaking { unknown_ordinal: u64 },
213}
214
215/// Pattern that matches an unknown `CommitResult` member.
216#[macro_export]
217macro_rules! CommitResultUnknown {
218    () => {
219        _
220    };
221}
222
223// Custom PartialEq so that unknown variants are not equal to themselves.
224impl PartialEq for CommitResult {
225    fn eq(&self, other: &Self) -> bool {
226        match (self, other) {
227            (Self::Ok(x), Self::Ok(y)) => *x == *y,
228            (Self::RuleWithInvalidMatcher(x), Self::RuleWithInvalidMatcher(y)) => *x == *y,
229            (Self::RuleWithInvalidAction(x), Self::RuleWithInvalidAction(y)) => *x == *y,
230            (Self::CyclicalRoutineGraph(x), Self::CyclicalRoutineGraph(y)) => *x == *y,
231            (Self::ErrorOnChange(x), Self::ErrorOnChange(y)) => *x == *y,
232            (
233                Self::TransparentProxyWithInvalidMatcher(x),
234                Self::TransparentProxyWithInvalidMatcher(y),
235            ) => *x == *y,
236            (Self::RedirectWithInvalidMatcher(x), Self::RedirectWithInvalidMatcher(y)) => *x == *y,
237            (Self::MasqueradeWithInvalidMatcher(x), Self::MasqueradeWithInvalidMatcher(y)) => {
238                *x == *y
239            }
240            (Self::RejectWithInvalidMatcher(x), Self::RejectWithInvalidMatcher(y)) => *x == *y,
241            _ => false,
242        }
243    }
244}
245
246impl CommitResult {
247    #[inline]
248    pub fn ordinal(&self) -> u64 {
249        match *self {
250            Self::Ok(_) => 1,
251            Self::RuleWithInvalidMatcher(_) => 2,
252            Self::RuleWithInvalidAction(_) => 3,
253            Self::CyclicalRoutineGraph(_) => 4,
254            Self::ErrorOnChange(_) => 5,
255            Self::TransparentProxyWithInvalidMatcher(_) => 6,
256            Self::RedirectWithInvalidMatcher(_) => 7,
257            Self::MasqueradeWithInvalidMatcher(_) => 8,
258            Self::RejectWithInvalidMatcher(_) => 9,
259            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
260        }
261    }
262
263    #[inline]
264    pub fn unknown_variant_for_testing() -> Self {
265        Self::__SourceBreaking { unknown_ordinal: 0 }
266    }
267
268    #[inline]
269    pub fn is_unknown(&self) -> bool {
270        match self {
271            Self::__SourceBreaking { .. } => true,
272            _ => false,
273        }
274    }
275}
276
277impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommitResult {}
278
279#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
280pub struct ControlMarker;
281
282impl fidl::endpoints::ProtocolMarker for ControlMarker {
283    type Proxy = ControlProxy;
284    type RequestStream = ControlRequestStream;
285    #[cfg(target_os = "fuchsia")]
286    type SynchronousProxy = ControlSynchronousProxy;
287
288    const DEBUG_NAME: &'static str = "fuchsia.net.filter.Control";
289}
290impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
291
292pub trait ControlProxyInterface: Send + Sync {
293    fn r#open_controller(
294        &self,
295        id: &str,
296        request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
297    ) -> Result<(), fidl::Error>;
298    fn r#reopen_detached_controller(
299        &self,
300        key: &ControllerKey,
301        request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
302    ) -> Result<(), fidl::Error>;
303}
304#[derive(Debug)]
305#[cfg(target_os = "fuchsia")]
306pub struct ControlSynchronousProxy {
307    client: fidl::client::sync::Client,
308}
309
310#[cfg(target_os = "fuchsia")]
311impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
312    type Proxy = ControlProxy;
313    type Protocol = ControlMarker;
314
315    fn from_channel(inner: fidl::Channel) -> Self {
316        Self::new(inner)
317    }
318
319    fn into_channel(self) -> fidl::Channel {
320        self.client.into_channel()
321    }
322
323    fn as_channel(&self) -> &fidl::Channel {
324        self.client.as_channel()
325    }
326}
327
328#[cfg(target_os = "fuchsia")]
329impl ControlSynchronousProxy {
330    pub fn new(channel: fidl::Channel) -> Self {
331        Self { client: fidl::client::sync::Client::new(channel) }
332    }
333
334    pub fn into_channel(self) -> fidl::Channel {
335        self.client.into_channel()
336    }
337
338    /// Waits until an event arrives and returns it. It is safe for other
339    /// threads to make concurrent requests while waiting for an event.
340    pub fn wait_for_event(
341        &self,
342        deadline: zx::MonotonicInstant,
343    ) -> Result<ControlEvent, fidl::Error> {
344        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
345    }
346
347    /// Open a new isolated namespace controller for filtering state.
348    pub fn r#open_controller(
349        &self,
350        mut id: &str,
351        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
352    ) -> Result<(), fidl::Error> {
353        self.client.send::<ControlOpenControllerRequest>(
354            (id, request),
355            0x2e1014a4c918d0e6,
356            fidl::encoding::DynamicFlags::empty(),
357        )
358    }
359
360    /// Re-open an existing controller that was previously detached from.
361    ///
362    /// Note that if any administrative client connections exist to the
363    /// controller, this operation will fail. At most one client may be
364    /// connected to the controller at once (except for clients connected
365    /// through the [`fuchsia.net.root/Filter`] protocol).
366    ///
367    /// If reconnection fails, the provided server end will be closed with one
368    /// of the following epitaphs:
369    ///  * `ZX_ERR_INVALID_ARGS` if the provided key is invalid
370    ///  * `ZX_ERR_ALREADY_EXISTS` if another client is currently connected to
371    ///    the controller identified by the provided key
372    pub fn r#reopen_detached_controller(
373        &self,
374        mut key: &ControllerKey,
375        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
376    ) -> Result<(), fidl::Error> {
377        self.client.send::<ControlReopenDetachedControllerRequest>(
378            (key, request),
379            0x59cf56d70942967a,
380            fidl::encoding::DynamicFlags::empty(),
381        )
382    }
383}
384
385#[cfg(target_os = "fuchsia")]
386impl From<ControlSynchronousProxy> for zx::NullableHandle {
387    fn from(value: ControlSynchronousProxy) -> Self {
388        value.into_channel().into()
389    }
390}
391
392#[cfg(target_os = "fuchsia")]
393impl From<fidl::Channel> for ControlSynchronousProxy {
394    fn from(value: fidl::Channel) -> Self {
395        Self::new(value)
396    }
397}
398
399#[cfg(target_os = "fuchsia")]
400impl fidl::endpoints::FromClient for ControlSynchronousProxy {
401    type Protocol = ControlMarker;
402
403    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
404        Self::new(value.into_channel())
405    }
406}
407
408#[derive(Debug, Clone)]
409pub struct ControlProxy {
410    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
411}
412
413impl fidl::endpoints::Proxy for ControlProxy {
414    type Protocol = ControlMarker;
415
416    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
417        Self::new(inner)
418    }
419
420    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
421        self.client.into_channel().map_err(|client| Self { client })
422    }
423
424    fn as_channel(&self) -> &::fidl::AsyncChannel {
425        self.client.as_channel()
426    }
427}
428
429impl ControlProxy {
430    /// Create a new Proxy for fuchsia.net.filter/Control.
431    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
432        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
433        Self { client: fidl::client::Client::new(channel, protocol_name) }
434    }
435
436    /// Get a Stream of events from the remote end of the protocol.
437    ///
438    /// # Panics
439    ///
440    /// Panics if the event stream was already taken.
441    pub fn take_event_stream(&self) -> ControlEventStream {
442        ControlEventStream { event_receiver: self.client.take_event_receiver() }
443    }
444
445    /// Open a new isolated namespace controller for filtering state.
446    pub fn r#open_controller(
447        &self,
448        mut id: &str,
449        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
450    ) -> Result<(), fidl::Error> {
451        ControlProxyInterface::r#open_controller(self, id, request)
452    }
453
454    /// Re-open an existing controller that was previously detached from.
455    ///
456    /// Note that if any administrative client connections exist to the
457    /// controller, this operation will fail. At most one client may be
458    /// connected to the controller at once (except for clients connected
459    /// through the [`fuchsia.net.root/Filter`] protocol).
460    ///
461    /// If reconnection fails, the provided server end will be closed with one
462    /// of the following epitaphs:
463    ///  * `ZX_ERR_INVALID_ARGS` if the provided key is invalid
464    ///  * `ZX_ERR_ALREADY_EXISTS` if another client is currently connected to
465    ///    the controller identified by the provided key
466    pub fn r#reopen_detached_controller(
467        &self,
468        mut key: &ControllerKey,
469        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
470    ) -> Result<(), fidl::Error> {
471        ControlProxyInterface::r#reopen_detached_controller(self, key, request)
472    }
473}
474
475impl ControlProxyInterface for ControlProxy {
476    fn r#open_controller(
477        &self,
478        mut id: &str,
479        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
480    ) -> Result<(), fidl::Error> {
481        self.client.send::<ControlOpenControllerRequest>(
482            (id, request),
483            0x2e1014a4c918d0e6,
484            fidl::encoding::DynamicFlags::empty(),
485        )
486    }
487
488    fn r#reopen_detached_controller(
489        &self,
490        mut key: &ControllerKey,
491        mut request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
492    ) -> Result<(), fidl::Error> {
493        self.client.send::<ControlReopenDetachedControllerRequest>(
494            (key, request),
495            0x59cf56d70942967a,
496            fidl::encoding::DynamicFlags::empty(),
497        )
498    }
499}
500
501pub struct ControlEventStream {
502    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
503}
504
505impl std::marker::Unpin for ControlEventStream {}
506
507impl futures::stream::FusedStream for ControlEventStream {
508    fn is_terminated(&self) -> bool {
509        self.event_receiver.is_terminated()
510    }
511}
512
513impl futures::Stream for ControlEventStream {
514    type Item = Result<ControlEvent, fidl::Error>;
515
516    fn poll_next(
517        mut self: std::pin::Pin<&mut Self>,
518        cx: &mut std::task::Context<'_>,
519    ) -> std::task::Poll<Option<Self::Item>> {
520        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
521            &mut self.event_receiver,
522            cx
523        )?) {
524            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
525            None => std::task::Poll::Ready(None),
526        }
527    }
528}
529
530#[derive(Debug)]
531pub enum ControlEvent {}
532
533impl ControlEvent {
534    /// Decodes a message buffer as a [`ControlEvent`].
535    fn decode(
536        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
537    ) -> Result<ControlEvent, fidl::Error> {
538        let (bytes, _handles) = buf.split_mut();
539        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
540        debug_assert_eq!(tx_header.tx_id, 0);
541        match tx_header.ordinal {
542            _ => Err(fidl::Error::UnknownOrdinal {
543                ordinal: tx_header.ordinal,
544                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
545            }),
546        }
547    }
548}
549
550/// A Stream of incoming requests for fuchsia.net.filter/Control.
551pub struct ControlRequestStream {
552    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
553    is_terminated: bool,
554}
555
556impl std::marker::Unpin for ControlRequestStream {}
557
558impl futures::stream::FusedStream for ControlRequestStream {
559    fn is_terminated(&self) -> bool {
560        self.is_terminated
561    }
562}
563
564impl fidl::endpoints::RequestStream for ControlRequestStream {
565    type Protocol = ControlMarker;
566    type ControlHandle = ControlControlHandle;
567
568    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
569        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
570    }
571
572    fn control_handle(&self) -> Self::ControlHandle {
573        ControlControlHandle { inner: self.inner.clone() }
574    }
575
576    fn into_inner(
577        self,
578    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
579    {
580        (self.inner, self.is_terminated)
581    }
582
583    fn from_inner(
584        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
585        is_terminated: bool,
586    ) -> Self {
587        Self { inner, is_terminated }
588    }
589}
590
591impl futures::Stream for ControlRequestStream {
592    type Item = Result<ControlRequest, fidl::Error>;
593
594    fn poll_next(
595        mut self: std::pin::Pin<&mut Self>,
596        cx: &mut std::task::Context<'_>,
597    ) -> std::task::Poll<Option<Self::Item>> {
598        let this = &mut *self;
599        if this.inner.check_shutdown(cx) {
600            this.is_terminated = true;
601            return std::task::Poll::Ready(None);
602        }
603        if this.is_terminated {
604            panic!("polled ControlRequestStream after completion");
605        }
606        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
607            |bytes, handles| {
608                match this.inner.channel().read_etc(cx, bytes, handles) {
609                    std::task::Poll::Ready(Ok(())) => {}
610                    std::task::Poll::Pending => return std::task::Poll::Pending,
611                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
612                        this.is_terminated = true;
613                        return std::task::Poll::Ready(None);
614                    }
615                    std::task::Poll::Ready(Err(e)) => {
616                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
617                            e.into(),
618                        ))));
619                    }
620                }
621
622                // A message has been received from the channel
623                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
624
625                std::task::Poll::Ready(Some(match header.ordinal {
626                    0x2e1014a4c918d0e6 => {
627                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
628                        let mut req = fidl::new_empty!(
629                            ControlOpenControllerRequest,
630                            fidl::encoding::DefaultFuchsiaResourceDialect
631                        );
632                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlOpenControllerRequest>(&header, _body_bytes, handles, &mut req)?;
633                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
634                        Ok(ControlRequest::OpenController {
635                            id: req.id,
636                            request: req.request,
637
638                            control_handle,
639                        })
640                    }
641                    0x59cf56d70942967a => {
642                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
643                        let mut req = fidl::new_empty!(
644                            ControlReopenDetachedControllerRequest,
645                            fidl::encoding::DefaultFuchsiaResourceDialect
646                        );
647                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlReopenDetachedControllerRequest>(&header, _body_bytes, handles, &mut req)?;
648                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
649                        Ok(ControlRequest::ReopenDetachedController {
650                            key: req.key,
651                            request: req.request,
652
653                            control_handle,
654                        })
655                    }
656                    _ => Err(fidl::Error::UnknownOrdinal {
657                        ordinal: header.ordinal,
658                        protocol_name:
659                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
660                    }),
661                }))
662            },
663        )
664    }
665}
666
667/// Provides control over packet filtering configuration.
668#[derive(Debug)]
669pub enum ControlRequest {
670    /// Open a new isolated namespace controller for filtering state.
671    OpenController {
672        id: String,
673        request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
674        control_handle: ControlControlHandle,
675    },
676    /// Re-open an existing controller that was previously detached from.
677    ///
678    /// Note that if any administrative client connections exist to the
679    /// controller, this operation will fail. At most one client may be
680    /// connected to the controller at once (except for clients connected
681    /// through the [`fuchsia.net.root/Filter`] protocol).
682    ///
683    /// If reconnection fails, the provided server end will be closed with one
684    /// of the following epitaphs:
685    ///  * `ZX_ERR_INVALID_ARGS` if the provided key is invalid
686    ///  * `ZX_ERR_ALREADY_EXISTS` if another client is currently connected to
687    ///    the controller identified by the provided key
688    ReopenDetachedController {
689        key: ControllerKey,
690        request: fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
691        control_handle: ControlControlHandle,
692    },
693}
694
695impl ControlRequest {
696    #[allow(irrefutable_let_patterns)]
697    pub fn into_open_controller(
698        self,
699    ) -> Option<(String, fidl::endpoints::ServerEnd<NamespaceControllerMarker>, ControlControlHandle)>
700    {
701        if let ControlRequest::OpenController { id, request, control_handle } = self {
702            Some((id, request, control_handle))
703        } else {
704            None
705        }
706    }
707
708    #[allow(irrefutable_let_patterns)]
709    pub fn into_reopen_detached_controller(
710        self,
711    ) -> Option<(
712        ControllerKey,
713        fidl::endpoints::ServerEnd<NamespaceControllerMarker>,
714        ControlControlHandle,
715    )> {
716        if let ControlRequest::ReopenDetachedController { key, request, control_handle } = self {
717            Some((key, request, control_handle))
718        } else {
719            None
720        }
721    }
722
723    /// Name of the method defined in FIDL
724    pub fn method_name(&self) -> &'static str {
725        match *self {
726            ControlRequest::OpenController { .. } => "open_controller",
727            ControlRequest::ReopenDetachedController { .. } => "reopen_detached_controller",
728        }
729    }
730}
731
732#[derive(Debug, Clone)]
733pub struct ControlControlHandle {
734    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
735}
736
737impl fidl::endpoints::ControlHandle for ControlControlHandle {
738    fn shutdown(&self) {
739        self.inner.shutdown()
740    }
741
742    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
743        self.inner.shutdown_with_epitaph(status)
744    }
745
746    fn is_closed(&self) -> bool {
747        self.inner.channel().is_closed()
748    }
749    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
750        self.inner.channel().on_closed()
751    }
752
753    #[cfg(target_os = "fuchsia")]
754    fn signal_peer(
755        &self,
756        clear_mask: zx::Signals,
757        set_mask: zx::Signals,
758    ) -> Result<(), zx_status::Status> {
759        use fidl::Peered;
760        self.inner.channel().signal_peer(clear_mask, set_mask)
761    }
762}
763
764impl ControlControlHandle {}
765
766#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
767pub struct NamespaceControllerMarker;
768
769impl fidl::endpoints::ProtocolMarker for NamespaceControllerMarker {
770    type Proxy = NamespaceControllerProxy;
771    type RequestStream = NamespaceControllerRequestStream;
772    #[cfg(target_os = "fuchsia")]
773    type SynchronousProxy = NamespaceControllerSynchronousProxy;
774
775    const DEBUG_NAME: &'static str = "(anonymous) NamespaceController";
776}
777pub type NamespaceControllerRegisterEbpfProgramResult = Result<(), RegisterEbpfProgramError>;
778
779pub trait NamespaceControllerProxyInterface: Send + Sync {
780    type DetachResponseFut: std::future::Future<Output = Result<[u8; 16], fidl::Error>> + Send;
781    fn r#detach(&self) -> Self::DetachResponseFut;
782    type RegisterEbpfProgramResponseFut: std::future::Future<
783            Output = Result<NamespaceControllerRegisterEbpfProgramResult, fidl::Error>,
784        > + Send;
785    fn r#register_ebpf_program(
786        &self,
787        handle: fidl_fuchsia_ebpf::ProgramHandle,
788        program: fidl_fuchsia_ebpf::VerifiedProgram,
789    ) -> Self::RegisterEbpfProgramResponseFut;
790    type PushChangesResponseFut: std::future::Future<Output = Result<ChangeValidationResult, fidl::Error>>
791        + Send;
792    fn r#push_changes(&self, changes: &[Change]) -> Self::PushChangesResponseFut;
793    type CommitResponseFut: std::future::Future<Output = Result<CommitResult, fidl::Error>> + Send;
794    fn r#commit(&self, payload: CommitOptions) -> Self::CommitResponseFut;
795}
796#[derive(Debug)]
797#[cfg(target_os = "fuchsia")]
798pub struct NamespaceControllerSynchronousProxy {
799    client: fidl::client::sync::Client,
800}
801
802#[cfg(target_os = "fuchsia")]
803impl fidl::endpoints::SynchronousProxy for NamespaceControllerSynchronousProxy {
804    type Proxy = NamespaceControllerProxy;
805    type Protocol = NamespaceControllerMarker;
806
807    fn from_channel(inner: fidl::Channel) -> Self {
808        Self::new(inner)
809    }
810
811    fn into_channel(self) -> fidl::Channel {
812        self.client.into_channel()
813    }
814
815    fn as_channel(&self) -> &fidl::Channel {
816        self.client.as_channel()
817    }
818}
819
820#[cfg(target_os = "fuchsia")]
821impl NamespaceControllerSynchronousProxy {
822    pub fn new(channel: fidl::Channel) -> Self {
823        Self { client: fidl::client::sync::Client::new(channel) }
824    }
825
826    pub fn into_channel(self) -> fidl::Channel {
827        self.client.into_channel()
828    }
829
830    /// Waits until an event arrives and returns it. It is safe for other
831    /// threads to make concurrent requests while waiting for an event.
832    pub fn wait_for_event(
833        &self,
834        deadline: zx::MonotonicInstant,
835    ) -> Result<NamespaceControllerEvent, fidl::Error> {
836        NamespaceControllerEvent::decode(
837            self.client.wait_for_event::<NamespaceControllerMarker>(deadline)?,
838        )
839    }
840
841    /// Detaches the client end from the controller's lifetime.
842    ///
843    /// After calling `Detach`, closing this client end no longer causes the
844    /// filtering state owned by the controller to be removed. The key returned
845    /// by the method can be used *once* by a client to reconnect to a detached
846    /// controller. This allows clients to ensure the filtering state they
847    /// install is resilient to client-side crashes and disconnections. (Note,
848    /// however, that closing the client end of the channel *will* flush any
849    /// pending changes that have been pushed but not yet committed.)
850    ///
851    /// `Detach` can be called multiple times; the key returned by the most
852    /// recent call is valid to reconnect to the controller. Calling `Detach`
853    /// will always return a new key and invalidate any previous keys.
854    ///
855    /// Note that, once a client has called `Detach` on a controller, the
856    /// controller remains detached even after a reconnection. This means that,
857    /// for example, if a client detached, closed the client end, reconnected,
858    /// and then closed the client end again, the filtering state owned by the
859    /// controller would *not* be removed. After reconnection, the only reason a
860    /// client would call `Detach` is to be able to reconnect *again* in the
861    /// future, given the key is invalidated after use.
862    pub fn r#detach(&self, ___deadline: zx::MonotonicInstant) -> Result<[u8; 16], fidl::Error> {
863        let _response = self
864            .client
865            .send_query::<fidl::encoding::EmptyPayload, ControllerKey, NamespaceControllerMarker>(
866                (),
867                0x15db86969aaa7c37,
868                fidl::encoding::DynamicFlags::empty(),
869                ___deadline,
870            )?;
871        Ok(_response.uuid)
872    }
873
874    /// Registers the specified eBPF program with the sevice.
875    ///
876    /// The program must be verified as a valid socket filter (i.e.
877    ///`BPF_PROG_TYPE_SOCKET_FILTER`).
878    ///
879    /// The registration is scoped to this controller. The server keeps the
880    /// program registered until the [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`]
881    /// signal is raised on the program handle or the peer handle is closed.
882    /// Matchers installed with this program remain functional even after the
883    /// program is unregistered. The caller should keep the peer handle and not
884    /// signal [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`] until the matchers that
885    /// rely on that registration are commited using `Commit()`.
886    pub fn r#register_ebpf_program(
887        &self,
888        mut handle: fidl_fuchsia_ebpf::ProgramHandle,
889        mut program: fidl_fuchsia_ebpf::VerifiedProgram,
890        ___deadline: zx::MonotonicInstant,
891    ) -> Result<NamespaceControllerRegisterEbpfProgramResult, fidl::Error> {
892        let _response = self.client.send_query::<
893            NamespaceControllerRegisterEbpfProgramRequest,
894            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RegisterEbpfProgramError>,
895            NamespaceControllerMarker,
896        >(
897            (&mut handle, &mut program,),
898            0x65a03500ae88cc2b,
899            fidl::encoding::DynamicFlags::empty(),
900            ___deadline,
901        )?;
902        Ok(_response.map(|x| x))
903    }
904
905    /// Append a set of changes to a pending transactional update to the
906    /// filtering configuration.
907    ///
908    /// To apply these changes, a client must call `Commit`.
909    pub fn r#push_changes(
910        &self,
911        mut changes: &[Change],
912        ___deadline: zx::MonotonicInstant,
913    ) -> Result<ChangeValidationResult, fidl::Error> {
914        let _response = self.client.send_query::<
915            NamespaceControllerPushChangesRequest,
916            ChangeValidationResult,
917            NamespaceControllerMarker,
918        >(
919            (changes,),
920            0x2c814d42c2783ee6,
921            fidl::encoding::DynamicFlags::empty(),
922            ___deadline,
923        )?;
924        Ok(_response)
925    }
926
927    /// Apply all pending changes. The set of changes will either be applied in
928    /// its entirety or, in case of an error, not applied at all.
929    pub fn r#commit(
930        &self,
931        mut payload: CommitOptions,
932        ___deadline: zx::MonotonicInstant,
933    ) -> Result<CommitResult, fidl::Error> {
934        let _response =
935            self.client.send_query::<CommitOptions, CommitResult, NamespaceControllerMarker>(
936                &mut payload,
937                0x49ed5545357963e4,
938                fidl::encoding::DynamicFlags::empty(),
939                ___deadline,
940            )?;
941        Ok(_response)
942    }
943}
944
945#[cfg(target_os = "fuchsia")]
946impl From<NamespaceControllerSynchronousProxy> for zx::NullableHandle {
947    fn from(value: NamespaceControllerSynchronousProxy) -> Self {
948        value.into_channel().into()
949    }
950}
951
952#[cfg(target_os = "fuchsia")]
953impl From<fidl::Channel> for NamespaceControllerSynchronousProxy {
954    fn from(value: fidl::Channel) -> Self {
955        Self::new(value)
956    }
957}
958
959#[cfg(target_os = "fuchsia")]
960impl fidl::endpoints::FromClient for NamespaceControllerSynchronousProxy {
961    type Protocol = NamespaceControllerMarker;
962
963    fn from_client(value: fidl::endpoints::ClientEnd<NamespaceControllerMarker>) -> Self {
964        Self::new(value.into_channel())
965    }
966}
967
968#[derive(Debug, Clone)]
969pub struct NamespaceControllerProxy {
970    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
971}
972
973impl fidl::endpoints::Proxy for NamespaceControllerProxy {
974    type Protocol = NamespaceControllerMarker;
975
976    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
977        Self::new(inner)
978    }
979
980    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
981        self.client.into_channel().map_err(|client| Self { client })
982    }
983
984    fn as_channel(&self) -> &::fidl::AsyncChannel {
985        self.client.as_channel()
986    }
987}
988
989impl NamespaceControllerProxy {
990    /// Create a new Proxy for fuchsia.net.filter/NamespaceController.
991    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
992        let protocol_name =
993            <NamespaceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
994        Self { client: fidl::client::Client::new(channel, protocol_name) }
995    }
996
997    /// Get a Stream of events from the remote end of the protocol.
998    ///
999    /// # Panics
1000    ///
1001    /// Panics if the event stream was already taken.
1002    pub fn take_event_stream(&self) -> NamespaceControllerEventStream {
1003        NamespaceControllerEventStream { event_receiver: self.client.take_event_receiver() }
1004    }
1005
1006    /// Detaches the client end from the controller's lifetime.
1007    ///
1008    /// After calling `Detach`, closing this client end no longer causes the
1009    /// filtering state owned by the controller to be removed. The key returned
1010    /// by the method can be used *once* by a client to reconnect to a detached
1011    /// controller. This allows clients to ensure the filtering state they
1012    /// install is resilient to client-side crashes and disconnections. (Note,
1013    /// however, that closing the client end of the channel *will* flush any
1014    /// pending changes that have been pushed but not yet committed.)
1015    ///
1016    /// `Detach` can be called multiple times; the key returned by the most
1017    /// recent call is valid to reconnect to the controller. Calling `Detach`
1018    /// will always return a new key and invalidate any previous keys.
1019    ///
1020    /// Note that, once a client has called `Detach` on a controller, the
1021    /// controller remains detached even after a reconnection. This means that,
1022    /// for example, if a client detached, closed the client end, reconnected,
1023    /// and then closed the client end again, the filtering state owned by the
1024    /// controller would *not* be removed. After reconnection, the only reason a
1025    /// client would call `Detach` is to be able to reconnect *again* in the
1026    /// future, given the key is invalidated after use.
1027    pub fn r#detach(
1028        &self,
1029    ) -> fidl::client::QueryResponseFut<[u8; 16], fidl::encoding::DefaultFuchsiaResourceDialect>
1030    {
1031        NamespaceControllerProxyInterface::r#detach(self)
1032    }
1033
1034    /// Registers the specified eBPF program with the sevice.
1035    ///
1036    /// The program must be verified as a valid socket filter (i.e.
1037    ///`BPF_PROG_TYPE_SOCKET_FILTER`).
1038    ///
1039    /// The registration is scoped to this controller. The server keeps the
1040    /// program registered until the [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`]
1041    /// signal is raised on the program handle or the peer handle is closed.
1042    /// Matchers installed with this program remain functional even after the
1043    /// program is unregistered. The caller should keep the peer handle and not
1044    /// signal [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`] until the matchers that
1045    /// rely on that registration are commited using `Commit()`.
1046    pub fn r#register_ebpf_program(
1047        &self,
1048        mut handle: fidl_fuchsia_ebpf::ProgramHandle,
1049        mut program: fidl_fuchsia_ebpf::VerifiedProgram,
1050    ) -> fidl::client::QueryResponseFut<
1051        NamespaceControllerRegisterEbpfProgramResult,
1052        fidl::encoding::DefaultFuchsiaResourceDialect,
1053    > {
1054        NamespaceControllerProxyInterface::r#register_ebpf_program(self, handle, program)
1055    }
1056
1057    /// Append a set of changes to a pending transactional update to the
1058    /// filtering configuration.
1059    ///
1060    /// To apply these changes, a client must call `Commit`.
1061    pub fn r#push_changes(
1062        &self,
1063        mut changes: &[Change],
1064    ) -> fidl::client::QueryResponseFut<
1065        ChangeValidationResult,
1066        fidl::encoding::DefaultFuchsiaResourceDialect,
1067    > {
1068        NamespaceControllerProxyInterface::r#push_changes(self, changes)
1069    }
1070
1071    /// Apply all pending changes. The set of changes will either be applied in
1072    /// its entirety or, in case of an error, not applied at all.
1073    pub fn r#commit(
1074        &self,
1075        mut payload: CommitOptions,
1076    ) -> fidl::client::QueryResponseFut<CommitResult, fidl::encoding::DefaultFuchsiaResourceDialect>
1077    {
1078        NamespaceControllerProxyInterface::r#commit(self, payload)
1079    }
1080}
1081
1082impl NamespaceControllerProxyInterface for NamespaceControllerProxy {
1083    type DetachResponseFut =
1084        fidl::client::QueryResponseFut<[u8; 16], fidl::encoding::DefaultFuchsiaResourceDialect>;
1085    fn r#detach(&self) -> Self::DetachResponseFut {
1086        fn _decode(
1087            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1088        ) -> Result<[u8; 16], fidl::Error> {
1089            let _response = fidl::client::decode_transaction_body::<
1090                ControllerKey,
1091                fidl::encoding::DefaultFuchsiaResourceDialect,
1092                0x15db86969aaa7c37,
1093            >(_buf?)?;
1094            Ok(_response.uuid)
1095        }
1096        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 16]>(
1097            (),
1098            0x15db86969aaa7c37,
1099            fidl::encoding::DynamicFlags::empty(),
1100            _decode,
1101        )
1102    }
1103
1104    type RegisterEbpfProgramResponseFut = fidl::client::QueryResponseFut<
1105        NamespaceControllerRegisterEbpfProgramResult,
1106        fidl::encoding::DefaultFuchsiaResourceDialect,
1107    >;
1108    fn r#register_ebpf_program(
1109        &self,
1110        mut handle: fidl_fuchsia_ebpf::ProgramHandle,
1111        mut program: fidl_fuchsia_ebpf::VerifiedProgram,
1112    ) -> Self::RegisterEbpfProgramResponseFut {
1113        fn _decode(
1114            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1115        ) -> Result<NamespaceControllerRegisterEbpfProgramResult, fidl::Error> {
1116            let _response = fidl::client::decode_transaction_body::<
1117                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RegisterEbpfProgramError>,
1118                fidl::encoding::DefaultFuchsiaResourceDialect,
1119                0x65a03500ae88cc2b,
1120            >(_buf?)?;
1121            Ok(_response.map(|x| x))
1122        }
1123        self.client.send_query_and_decode::<
1124            NamespaceControllerRegisterEbpfProgramRequest,
1125            NamespaceControllerRegisterEbpfProgramResult,
1126        >(
1127            (&mut handle, &mut program,),
1128            0x65a03500ae88cc2b,
1129            fidl::encoding::DynamicFlags::empty(),
1130            _decode,
1131        )
1132    }
1133
1134    type PushChangesResponseFut = fidl::client::QueryResponseFut<
1135        ChangeValidationResult,
1136        fidl::encoding::DefaultFuchsiaResourceDialect,
1137    >;
1138    fn r#push_changes(&self, mut changes: &[Change]) -> Self::PushChangesResponseFut {
1139        fn _decode(
1140            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1141        ) -> Result<ChangeValidationResult, fidl::Error> {
1142            let _response = fidl::client::decode_transaction_body::<
1143                ChangeValidationResult,
1144                fidl::encoding::DefaultFuchsiaResourceDialect,
1145                0x2c814d42c2783ee6,
1146            >(_buf?)?;
1147            Ok(_response)
1148        }
1149        self.client
1150            .send_query_and_decode::<NamespaceControllerPushChangesRequest, ChangeValidationResult>(
1151                (changes,),
1152                0x2c814d42c2783ee6,
1153                fidl::encoding::DynamicFlags::empty(),
1154                _decode,
1155            )
1156    }
1157
1158    type CommitResponseFut =
1159        fidl::client::QueryResponseFut<CommitResult, fidl::encoding::DefaultFuchsiaResourceDialect>;
1160    fn r#commit(&self, mut payload: CommitOptions) -> Self::CommitResponseFut {
1161        fn _decode(
1162            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1163        ) -> Result<CommitResult, fidl::Error> {
1164            let _response = fidl::client::decode_transaction_body::<
1165                CommitResult,
1166                fidl::encoding::DefaultFuchsiaResourceDialect,
1167                0x49ed5545357963e4,
1168            >(_buf?)?;
1169            Ok(_response)
1170        }
1171        self.client.send_query_and_decode::<CommitOptions, CommitResult>(
1172            &mut payload,
1173            0x49ed5545357963e4,
1174            fidl::encoding::DynamicFlags::empty(),
1175            _decode,
1176        )
1177    }
1178}
1179
1180pub struct NamespaceControllerEventStream {
1181    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1182}
1183
1184impl std::marker::Unpin for NamespaceControllerEventStream {}
1185
1186impl futures::stream::FusedStream for NamespaceControllerEventStream {
1187    fn is_terminated(&self) -> bool {
1188        self.event_receiver.is_terminated()
1189    }
1190}
1191
1192impl futures::Stream for NamespaceControllerEventStream {
1193    type Item = Result<NamespaceControllerEvent, fidl::Error>;
1194
1195    fn poll_next(
1196        mut self: std::pin::Pin<&mut Self>,
1197        cx: &mut std::task::Context<'_>,
1198    ) -> std::task::Poll<Option<Self::Item>> {
1199        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1200            &mut self.event_receiver,
1201            cx
1202        )?) {
1203            Some(buf) => std::task::Poll::Ready(Some(NamespaceControllerEvent::decode(buf))),
1204            None => std::task::Poll::Ready(None),
1205        }
1206    }
1207}
1208
1209#[derive(Debug)]
1210pub enum NamespaceControllerEvent {
1211    OnIdAssigned { id: String },
1212}
1213
1214impl NamespaceControllerEvent {
1215    #[allow(irrefutable_let_patterns)]
1216    pub fn into_on_id_assigned(self) -> Option<String> {
1217        if let NamespaceControllerEvent::OnIdAssigned { id } = self { Some((id)) } else { None }
1218    }
1219
1220    /// Decodes a message buffer as a [`NamespaceControllerEvent`].
1221    fn decode(
1222        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1223    ) -> Result<NamespaceControllerEvent, fidl::Error> {
1224        let (bytes, _handles) = buf.split_mut();
1225        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1226        debug_assert_eq!(tx_header.tx_id, 0);
1227        match tx_header.ordinal {
1228            0x2e218c64a1d5ea74 => {
1229                let mut out = fidl::new_empty!(
1230                    NamespaceControllerOnIdAssignedRequest,
1231                    fidl::encoding::DefaultFuchsiaResourceDialect
1232                );
1233                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NamespaceControllerOnIdAssignedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1234                Ok((NamespaceControllerEvent::OnIdAssigned { id: out.id }))
1235            }
1236            _ => Err(fidl::Error::UnknownOrdinal {
1237                ordinal: tx_header.ordinal,
1238                protocol_name:
1239                    <NamespaceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1240            }),
1241        }
1242    }
1243}
1244
1245/// A Stream of incoming requests for fuchsia.net.filter/NamespaceController.
1246pub struct NamespaceControllerRequestStream {
1247    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1248    is_terminated: bool,
1249}
1250
1251impl std::marker::Unpin for NamespaceControllerRequestStream {}
1252
1253impl futures::stream::FusedStream for NamespaceControllerRequestStream {
1254    fn is_terminated(&self) -> bool {
1255        self.is_terminated
1256    }
1257}
1258
1259impl fidl::endpoints::RequestStream for NamespaceControllerRequestStream {
1260    type Protocol = NamespaceControllerMarker;
1261    type ControlHandle = NamespaceControllerControlHandle;
1262
1263    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1264        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1265    }
1266
1267    fn control_handle(&self) -> Self::ControlHandle {
1268        NamespaceControllerControlHandle { inner: self.inner.clone() }
1269    }
1270
1271    fn into_inner(
1272        self,
1273    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1274    {
1275        (self.inner, self.is_terminated)
1276    }
1277
1278    fn from_inner(
1279        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1280        is_terminated: bool,
1281    ) -> Self {
1282        Self { inner, is_terminated }
1283    }
1284}
1285
1286impl futures::Stream for NamespaceControllerRequestStream {
1287    type Item = Result<NamespaceControllerRequest, fidl::Error>;
1288
1289    fn poll_next(
1290        mut self: std::pin::Pin<&mut Self>,
1291        cx: &mut std::task::Context<'_>,
1292    ) -> std::task::Poll<Option<Self::Item>> {
1293        let this = &mut *self;
1294        if this.inner.check_shutdown(cx) {
1295            this.is_terminated = true;
1296            return std::task::Poll::Ready(None);
1297        }
1298        if this.is_terminated {
1299            panic!("polled NamespaceControllerRequestStream after completion");
1300        }
1301        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1302            |bytes, handles| {
1303                match this.inner.channel().read_etc(cx, bytes, handles) {
1304                    std::task::Poll::Ready(Ok(())) => {}
1305                    std::task::Poll::Pending => return std::task::Poll::Pending,
1306                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1307                        this.is_terminated = true;
1308                        return std::task::Poll::Ready(None);
1309                    }
1310                    std::task::Poll::Ready(Err(e)) => {
1311                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1312                            e.into(),
1313                        ))));
1314                    }
1315                }
1316
1317                // A message has been received from the channel
1318                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1319
1320                std::task::Poll::Ready(Some(match header.ordinal {
1321                0x15db86969aaa7c37 => {
1322                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1323                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1324                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1325                    let control_handle = NamespaceControllerControlHandle {
1326                        inner: this.inner.clone(),
1327                    };
1328                    Ok(NamespaceControllerRequest::Detach {
1329                        responder: NamespaceControllerDetachResponder {
1330                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1331                            tx_id: header.tx_id,
1332                        },
1333                    })
1334                }
1335                0x65a03500ae88cc2b => {
1336                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1337                    let mut req = fidl::new_empty!(NamespaceControllerRegisterEbpfProgramRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1338                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NamespaceControllerRegisterEbpfProgramRequest>(&header, _body_bytes, handles, &mut req)?;
1339                    let control_handle = NamespaceControllerControlHandle {
1340                        inner: this.inner.clone(),
1341                    };
1342                    Ok(NamespaceControllerRequest::RegisterEbpfProgram {handle: req.handle,
1343program: req.program,
1344
1345                        responder: NamespaceControllerRegisterEbpfProgramResponder {
1346                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1347                            tx_id: header.tx_id,
1348                        },
1349                    })
1350                }
1351                0x2c814d42c2783ee6 => {
1352                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1353                    let mut req = fidl::new_empty!(NamespaceControllerPushChangesRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1354                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NamespaceControllerPushChangesRequest>(&header, _body_bytes, handles, &mut req)?;
1355                    let control_handle = NamespaceControllerControlHandle {
1356                        inner: this.inner.clone(),
1357                    };
1358                    Ok(NamespaceControllerRequest::PushChanges {changes: req.changes,
1359
1360                        responder: NamespaceControllerPushChangesResponder {
1361                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1362                            tx_id: header.tx_id,
1363                        },
1364                    })
1365                }
1366                0x49ed5545357963e4 => {
1367                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1368                    let mut req = fidl::new_empty!(CommitOptions, fidl::encoding::DefaultFuchsiaResourceDialect);
1369                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CommitOptions>(&header, _body_bytes, handles, &mut req)?;
1370                    let control_handle = NamespaceControllerControlHandle {
1371                        inner: this.inner.clone(),
1372                    };
1373                    Ok(NamespaceControllerRequest::Commit {payload: req,
1374                        responder: NamespaceControllerCommitResponder {
1375                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1376                            tx_id: header.tx_id,
1377                        },
1378                    })
1379                }
1380                _ => Err(fidl::Error::UnknownOrdinal {
1381                    ordinal: header.ordinal,
1382                    protocol_name: <NamespaceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1383                }),
1384            }))
1385            },
1386        )
1387    }
1388}
1389
1390/// Provides mutable access to an isolated view of packet filtering
1391/// configuration.
1392///
1393/// The handle to this protocol encodes the lifetime of the contained state.
1394/// Closing the client end will remove filtering state owned by this controller,
1395/// unless the client has previously called `Detach`.
1396///
1397/// Note that pending changes, on the other hand, will always be flushed when
1398/// the client end of this protocol is closed (even if the client has detached).
1399#[derive(Debug)]
1400pub enum NamespaceControllerRequest {
1401    /// Detaches the client end from the controller's lifetime.
1402    ///
1403    /// After calling `Detach`, closing this client end no longer causes the
1404    /// filtering state owned by the controller to be removed. The key returned
1405    /// by the method can be used *once* by a client to reconnect to a detached
1406    /// controller. This allows clients to ensure the filtering state they
1407    /// install is resilient to client-side crashes and disconnections. (Note,
1408    /// however, that closing the client end of the channel *will* flush any
1409    /// pending changes that have been pushed but not yet committed.)
1410    ///
1411    /// `Detach` can be called multiple times; the key returned by the most
1412    /// recent call is valid to reconnect to the controller. Calling `Detach`
1413    /// will always return a new key and invalidate any previous keys.
1414    ///
1415    /// Note that, once a client has called `Detach` on a controller, the
1416    /// controller remains detached even after a reconnection. This means that,
1417    /// for example, if a client detached, closed the client end, reconnected,
1418    /// and then closed the client end again, the filtering state owned by the
1419    /// controller would *not* be removed. After reconnection, the only reason a
1420    /// client would call `Detach` is to be able to reconnect *again* in the
1421    /// future, given the key is invalidated after use.
1422    Detach { responder: NamespaceControllerDetachResponder },
1423    /// Registers the specified eBPF program with the sevice.
1424    ///
1425    /// The program must be verified as a valid socket filter (i.e.
1426    ///`BPF_PROG_TYPE_SOCKET_FILTER`).
1427    ///
1428    /// The registration is scoped to this controller. The server keeps the
1429    /// program registered until the [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`]
1430    /// signal is raised on the program handle or the peer handle is closed.
1431    /// Matchers installed with this program remain functional even after the
1432    /// program is unregistered. The caller should keep the peer handle and not
1433    /// signal [`fuchsia.ebpf.PROGRAM_DEFUNCT_SIGNAL`] until the matchers that
1434    /// rely on that registration are commited using `Commit()`.
1435    RegisterEbpfProgram {
1436        handle: fidl_fuchsia_ebpf::ProgramHandle,
1437        program: fidl_fuchsia_ebpf::VerifiedProgram,
1438        responder: NamespaceControllerRegisterEbpfProgramResponder,
1439    },
1440    /// Append a set of changes to a pending transactional update to the
1441    /// filtering configuration.
1442    ///
1443    /// To apply these changes, a client must call `Commit`.
1444    PushChanges { changes: Vec<Change>, responder: NamespaceControllerPushChangesResponder },
1445    /// Apply all pending changes. The set of changes will either be applied in
1446    /// its entirety or, in case of an error, not applied at all.
1447    Commit { payload: CommitOptions, responder: NamespaceControllerCommitResponder },
1448}
1449
1450impl NamespaceControllerRequest {
1451    #[allow(irrefutable_let_patterns)]
1452    pub fn into_detach(self) -> Option<(NamespaceControllerDetachResponder)> {
1453        if let NamespaceControllerRequest::Detach { responder } = self {
1454            Some((responder))
1455        } else {
1456            None
1457        }
1458    }
1459
1460    #[allow(irrefutable_let_patterns)]
1461    pub fn into_register_ebpf_program(
1462        self,
1463    ) -> Option<(
1464        fidl_fuchsia_ebpf::ProgramHandle,
1465        fidl_fuchsia_ebpf::VerifiedProgram,
1466        NamespaceControllerRegisterEbpfProgramResponder,
1467    )> {
1468        if let NamespaceControllerRequest::RegisterEbpfProgram { handle, program, responder } = self
1469        {
1470            Some((handle, program, responder))
1471        } else {
1472            None
1473        }
1474    }
1475
1476    #[allow(irrefutable_let_patterns)]
1477    pub fn into_push_changes(
1478        self,
1479    ) -> Option<(Vec<Change>, NamespaceControllerPushChangesResponder)> {
1480        if let NamespaceControllerRequest::PushChanges { changes, responder } = self {
1481            Some((changes, responder))
1482        } else {
1483            None
1484        }
1485    }
1486
1487    #[allow(irrefutable_let_patterns)]
1488    pub fn into_commit(self) -> Option<(CommitOptions, NamespaceControllerCommitResponder)> {
1489        if let NamespaceControllerRequest::Commit { payload, responder } = self {
1490            Some((payload, responder))
1491        } else {
1492            None
1493        }
1494    }
1495
1496    /// Name of the method defined in FIDL
1497    pub fn method_name(&self) -> &'static str {
1498        match *self {
1499            NamespaceControllerRequest::Detach { .. } => "detach",
1500            NamespaceControllerRequest::RegisterEbpfProgram { .. } => "register_ebpf_program",
1501            NamespaceControllerRequest::PushChanges { .. } => "push_changes",
1502            NamespaceControllerRequest::Commit { .. } => "commit",
1503        }
1504    }
1505}
1506
1507#[derive(Debug, Clone)]
1508pub struct NamespaceControllerControlHandle {
1509    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1510}
1511
1512impl fidl::endpoints::ControlHandle for NamespaceControllerControlHandle {
1513    fn shutdown(&self) {
1514        self.inner.shutdown()
1515    }
1516
1517    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1518        self.inner.shutdown_with_epitaph(status)
1519    }
1520
1521    fn is_closed(&self) -> bool {
1522        self.inner.channel().is_closed()
1523    }
1524    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1525        self.inner.channel().on_closed()
1526    }
1527
1528    #[cfg(target_os = "fuchsia")]
1529    fn signal_peer(
1530        &self,
1531        clear_mask: zx::Signals,
1532        set_mask: zx::Signals,
1533    ) -> Result<(), zx_status::Status> {
1534        use fidl::Peered;
1535        self.inner.channel().signal_peer(clear_mask, set_mask)
1536    }
1537}
1538
1539impl NamespaceControllerControlHandle {
1540    pub fn send_on_id_assigned(&self, mut id: &str) -> Result<(), fidl::Error> {
1541        self.inner.send::<NamespaceControllerOnIdAssignedRequest>(
1542            (id,),
1543            0,
1544            0x2e218c64a1d5ea74,
1545            fidl::encoding::DynamicFlags::empty(),
1546        )
1547    }
1548}
1549
1550#[must_use = "FIDL methods require a response to be sent"]
1551#[derive(Debug)]
1552pub struct NamespaceControllerDetachResponder {
1553    control_handle: std::mem::ManuallyDrop<NamespaceControllerControlHandle>,
1554    tx_id: u32,
1555}
1556
1557/// Set the the channel to be shutdown (see [`NamespaceControllerControlHandle::shutdown`])
1558/// if the responder is dropped without sending a response, so that the client
1559/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1560impl std::ops::Drop for NamespaceControllerDetachResponder {
1561    fn drop(&mut self) {
1562        self.control_handle.shutdown();
1563        // Safety: drops once, never accessed again
1564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1565    }
1566}
1567
1568impl fidl::endpoints::Responder for NamespaceControllerDetachResponder {
1569    type ControlHandle = NamespaceControllerControlHandle;
1570
1571    fn control_handle(&self) -> &NamespaceControllerControlHandle {
1572        &self.control_handle
1573    }
1574
1575    fn drop_without_shutdown(mut self) {
1576        // Safety: drops once, never accessed again due to mem::forget
1577        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1578        // Prevent Drop from running (which would shut down the channel)
1579        std::mem::forget(self);
1580    }
1581}
1582
1583impl NamespaceControllerDetachResponder {
1584    /// Sends a response to the FIDL transaction.
1585    ///
1586    /// Sets the channel to shutdown if an error occurs.
1587    pub fn send(self, mut uuid: &[u8; 16]) -> Result<(), fidl::Error> {
1588        let _result = self.send_raw(uuid);
1589        if _result.is_err() {
1590            self.control_handle.shutdown();
1591        }
1592        self.drop_without_shutdown();
1593        _result
1594    }
1595
1596    /// Similar to "send" but does not shutdown the channel if an error occurs.
1597    pub fn send_no_shutdown_on_err(self, mut uuid: &[u8; 16]) -> Result<(), fidl::Error> {
1598        let _result = self.send_raw(uuid);
1599        self.drop_without_shutdown();
1600        _result
1601    }
1602
1603    fn send_raw(&self, mut uuid: &[u8; 16]) -> Result<(), fidl::Error> {
1604        self.control_handle.inner.send::<ControllerKey>(
1605            (uuid,),
1606            self.tx_id,
1607            0x15db86969aaa7c37,
1608            fidl::encoding::DynamicFlags::empty(),
1609        )
1610    }
1611}
1612
1613#[must_use = "FIDL methods require a response to be sent"]
1614#[derive(Debug)]
1615pub struct NamespaceControllerRegisterEbpfProgramResponder {
1616    control_handle: std::mem::ManuallyDrop<NamespaceControllerControlHandle>,
1617    tx_id: u32,
1618}
1619
1620/// Set the the channel to be shutdown (see [`NamespaceControllerControlHandle::shutdown`])
1621/// if the responder is dropped without sending a response, so that the client
1622/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1623impl std::ops::Drop for NamespaceControllerRegisterEbpfProgramResponder {
1624    fn drop(&mut self) {
1625        self.control_handle.shutdown();
1626        // Safety: drops once, never accessed again
1627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1628    }
1629}
1630
1631impl fidl::endpoints::Responder for NamespaceControllerRegisterEbpfProgramResponder {
1632    type ControlHandle = NamespaceControllerControlHandle;
1633
1634    fn control_handle(&self) -> &NamespaceControllerControlHandle {
1635        &self.control_handle
1636    }
1637
1638    fn drop_without_shutdown(mut self) {
1639        // Safety: drops once, never accessed again due to mem::forget
1640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1641        // Prevent Drop from running (which would shut down the channel)
1642        std::mem::forget(self);
1643    }
1644}
1645
1646impl NamespaceControllerRegisterEbpfProgramResponder {
1647    /// Sends a response to the FIDL transaction.
1648    ///
1649    /// Sets the channel to shutdown if an error occurs.
1650    pub fn send(self, mut result: Result<(), RegisterEbpfProgramError>) -> Result<(), fidl::Error> {
1651        let _result = self.send_raw(result);
1652        if _result.is_err() {
1653            self.control_handle.shutdown();
1654        }
1655        self.drop_without_shutdown();
1656        _result
1657    }
1658
1659    /// Similar to "send" but does not shutdown the channel if an error occurs.
1660    pub fn send_no_shutdown_on_err(
1661        self,
1662        mut result: Result<(), RegisterEbpfProgramError>,
1663    ) -> Result<(), fidl::Error> {
1664        let _result = self.send_raw(result);
1665        self.drop_without_shutdown();
1666        _result
1667    }
1668
1669    fn send_raw(
1670        &self,
1671        mut result: Result<(), RegisterEbpfProgramError>,
1672    ) -> Result<(), fidl::Error> {
1673        self.control_handle.inner.send::<fidl::encoding::ResultType<
1674            fidl::encoding::EmptyStruct,
1675            RegisterEbpfProgramError,
1676        >>(
1677            result,
1678            self.tx_id,
1679            0x65a03500ae88cc2b,
1680            fidl::encoding::DynamicFlags::empty(),
1681        )
1682    }
1683}
1684
1685#[must_use = "FIDL methods require a response to be sent"]
1686#[derive(Debug)]
1687pub struct NamespaceControllerPushChangesResponder {
1688    control_handle: std::mem::ManuallyDrop<NamespaceControllerControlHandle>,
1689    tx_id: u32,
1690}
1691
1692/// Set the the channel to be shutdown (see [`NamespaceControllerControlHandle::shutdown`])
1693/// if the responder is dropped without sending a response, so that the client
1694/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1695impl std::ops::Drop for NamespaceControllerPushChangesResponder {
1696    fn drop(&mut self) {
1697        self.control_handle.shutdown();
1698        // Safety: drops once, never accessed again
1699        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1700    }
1701}
1702
1703impl fidl::endpoints::Responder for NamespaceControllerPushChangesResponder {
1704    type ControlHandle = NamespaceControllerControlHandle;
1705
1706    fn control_handle(&self) -> &NamespaceControllerControlHandle {
1707        &self.control_handle
1708    }
1709
1710    fn drop_without_shutdown(mut self) {
1711        // Safety: drops once, never accessed again due to mem::forget
1712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1713        // Prevent Drop from running (which would shut down the channel)
1714        std::mem::forget(self);
1715    }
1716}
1717
1718impl NamespaceControllerPushChangesResponder {
1719    /// Sends a response to the FIDL transaction.
1720    ///
1721    /// Sets the channel to shutdown if an error occurs.
1722    pub fn send(self, mut payload: ChangeValidationResult) -> Result<(), fidl::Error> {
1723        let _result = self.send_raw(payload);
1724        if _result.is_err() {
1725            self.control_handle.shutdown();
1726        }
1727        self.drop_without_shutdown();
1728        _result
1729    }
1730
1731    /// Similar to "send" but does not shutdown the channel if an error occurs.
1732    pub fn send_no_shutdown_on_err(
1733        self,
1734        mut payload: ChangeValidationResult,
1735    ) -> Result<(), fidl::Error> {
1736        let _result = self.send_raw(payload);
1737        self.drop_without_shutdown();
1738        _result
1739    }
1740
1741    fn send_raw(&self, mut payload: ChangeValidationResult) -> Result<(), fidl::Error> {
1742        self.control_handle.inner.send::<ChangeValidationResult>(
1743            &mut payload,
1744            self.tx_id,
1745            0x2c814d42c2783ee6,
1746            fidl::encoding::DynamicFlags::empty(),
1747        )
1748    }
1749}
1750
1751#[must_use = "FIDL methods require a response to be sent"]
1752#[derive(Debug)]
1753pub struct NamespaceControllerCommitResponder {
1754    control_handle: std::mem::ManuallyDrop<NamespaceControllerControlHandle>,
1755    tx_id: u32,
1756}
1757
1758/// Set the the channel to be shutdown (see [`NamespaceControllerControlHandle::shutdown`])
1759/// if the responder is dropped without sending a response, so that the client
1760/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1761impl std::ops::Drop for NamespaceControllerCommitResponder {
1762    fn drop(&mut self) {
1763        self.control_handle.shutdown();
1764        // Safety: drops once, never accessed again
1765        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1766    }
1767}
1768
1769impl fidl::endpoints::Responder for NamespaceControllerCommitResponder {
1770    type ControlHandle = NamespaceControllerControlHandle;
1771
1772    fn control_handle(&self) -> &NamespaceControllerControlHandle {
1773        &self.control_handle
1774    }
1775
1776    fn drop_without_shutdown(mut self) {
1777        // Safety: drops once, never accessed again due to mem::forget
1778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1779        // Prevent Drop from running (which would shut down the channel)
1780        std::mem::forget(self);
1781    }
1782}
1783
1784impl NamespaceControllerCommitResponder {
1785    /// Sends a response to the FIDL transaction.
1786    ///
1787    /// Sets the channel to shutdown if an error occurs.
1788    pub fn send(self, mut payload: CommitResult) -> Result<(), fidl::Error> {
1789        let _result = self.send_raw(payload);
1790        if _result.is_err() {
1791            self.control_handle.shutdown();
1792        }
1793        self.drop_without_shutdown();
1794        _result
1795    }
1796
1797    /// Similar to "send" but does not shutdown the channel if an error occurs.
1798    pub fn send_no_shutdown_on_err(self, mut payload: CommitResult) -> Result<(), fidl::Error> {
1799        let _result = self.send_raw(payload);
1800        self.drop_without_shutdown();
1801        _result
1802    }
1803
1804    fn send_raw(&self, mut payload: CommitResult) -> Result<(), fidl::Error> {
1805        self.control_handle.inner.send::<CommitResult>(
1806            &mut payload,
1807            self.tx_id,
1808            0x49ed5545357963e4,
1809            fidl::encoding::DynamicFlags::empty(),
1810        )
1811    }
1812}
1813
1814#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1815pub struct SocketControlMarker;
1816
1817impl fidl::endpoints::ProtocolMarker for SocketControlMarker {
1818    type Proxy = SocketControlProxy;
1819    type RequestStream = SocketControlRequestStream;
1820    #[cfg(target_os = "fuchsia")]
1821    type SynchronousProxy = SocketControlSynchronousProxy;
1822
1823    const DEBUG_NAME: &'static str = "fuchsia.net.filter.SocketControl";
1824}
1825impl fidl::endpoints::DiscoverableProtocolMarker for SocketControlMarker {}
1826pub type SocketControlAttachEbpfProgramResult = Result<(), SocketControlAttachEbpfProgramError>;
1827pub type SocketControlDetachEbpfProgramResult = Result<(), SocketControlDetachEbpfProgramError>;
1828
1829pub trait SocketControlProxyInterface: Send + Sync {
1830    type AttachEbpfProgramResponseFut: std::future::Future<Output = Result<SocketControlAttachEbpfProgramResult, fidl::Error>>
1831        + Send;
1832    fn r#attach_ebpf_program(
1833        &self,
1834        payload: AttachEbpfProgramOptions,
1835    ) -> Self::AttachEbpfProgramResponseFut;
1836    type DetachEbpfProgramResponseFut: std::future::Future<Output = Result<SocketControlDetachEbpfProgramResult, fidl::Error>>
1837        + Send;
1838    fn r#detach_ebpf_program(&self, hook: SocketHook) -> Self::DetachEbpfProgramResponseFut;
1839}
1840#[derive(Debug)]
1841#[cfg(target_os = "fuchsia")]
1842pub struct SocketControlSynchronousProxy {
1843    client: fidl::client::sync::Client,
1844}
1845
1846#[cfg(target_os = "fuchsia")]
1847impl fidl::endpoints::SynchronousProxy for SocketControlSynchronousProxy {
1848    type Proxy = SocketControlProxy;
1849    type Protocol = SocketControlMarker;
1850
1851    fn from_channel(inner: fidl::Channel) -> Self {
1852        Self::new(inner)
1853    }
1854
1855    fn into_channel(self) -> fidl::Channel {
1856        self.client.into_channel()
1857    }
1858
1859    fn as_channel(&self) -> &fidl::Channel {
1860        self.client.as_channel()
1861    }
1862}
1863
1864#[cfg(target_os = "fuchsia")]
1865impl SocketControlSynchronousProxy {
1866    pub fn new(channel: fidl::Channel) -> Self {
1867        Self { client: fidl::client::sync::Client::new(channel) }
1868    }
1869
1870    pub fn into_channel(self) -> fidl::Channel {
1871        self.client.into_channel()
1872    }
1873
1874    /// Waits until an event arrives and returns it. It is safe for other
1875    /// threads to make concurrent requests while waiting for an event.
1876    pub fn wait_for_event(
1877        &self,
1878        deadline: zx::MonotonicInstant,
1879    ) -> Result<SocketControlEvent, fidl::Error> {
1880        SocketControlEvent::decode(self.client.wait_for_event::<SocketControlMarker>(deadline)?)
1881    }
1882
1883    /// Attaches the specified eBPF `program` to the specified `hook`.
1884    ///
1885    /// May fail if another program is already attached (potentially by another
1886    /// `SocketControl` instance).
1887    ///
1888    /// *Warning:* Caller must check that the specified program is compatible
1889    /// with the specified `hook`.
1890    pub fn r#attach_ebpf_program(
1891        &self,
1892        mut payload: AttachEbpfProgramOptions,
1893        ___deadline: zx::MonotonicInstant,
1894    ) -> Result<SocketControlAttachEbpfProgramResult, fidl::Error> {
1895        let _response =
1896            self.client.send_query::<AttachEbpfProgramOptions, fidl::encoding::ResultType<
1897                fidl::encoding::EmptyStruct,
1898                SocketControlAttachEbpfProgramError,
1899            >, SocketControlMarker>(
1900                &mut payload,
1901                0x35076256e3cc40e,
1902                fidl::encoding::DynamicFlags::empty(),
1903                ___deadline,
1904            )?;
1905        Ok(_response.map(|x| x))
1906    }
1907
1908    /// Detaches eBPF program from the specified `hook`.
1909    pub fn r#detach_ebpf_program(
1910        &self,
1911        mut hook: SocketHook,
1912        ___deadline: zx::MonotonicInstant,
1913    ) -> Result<SocketControlDetachEbpfProgramResult, fidl::Error> {
1914        let _response = self
1915            .client
1916            .send_query::<SocketControlDetachEbpfProgramRequest, fidl::encoding::ResultType<
1917                fidl::encoding::EmptyStruct,
1918                SocketControlDetachEbpfProgramError,
1919            >, SocketControlMarker>(
1920                (hook,),
1921                0x226db36c461b6c1,
1922                fidl::encoding::DynamicFlags::empty(),
1923                ___deadline,
1924            )?;
1925        Ok(_response.map(|x| x))
1926    }
1927}
1928
1929#[cfg(target_os = "fuchsia")]
1930impl From<SocketControlSynchronousProxy> for zx::NullableHandle {
1931    fn from(value: SocketControlSynchronousProxy) -> Self {
1932        value.into_channel().into()
1933    }
1934}
1935
1936#[cfg(target_os = "fuchsia")]
1937impl From<fidl::Channel> for SocketControlSynchronousProxy {
1938    fn from(value: fidl::Channel) -> Self {
1939        Self::new(value)
1940    }
1941}
1942
1943#[cfg(target_os = "fuchsia")]
1944impl fidl::endpoints::FromClient for SocketControlSynchronousProxy {
1945    type Protocol = SocketControlMarker;
1946
1947    fn from_client(value: fidl::endpoints::ClientEnd<SocketControlMarker>) -> Self {
1948        Self::new(value.into_channel())
1949    }
1950}
1951
1952#[derive(Debug, Clone)]
1953pub struct SocketControlProxy {
1954    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1955}
1956
1957impl fidl::endpoints::Proxy for SocketControlProxy {
1958    type Protocol = SocketControlMarker;
1959
1960    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1961        Self::new(inner)
1962    }
1963
1964    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1965        self.client.into_channel().map_err(|client| Self { client })
1966    }
1967
1968    fn as_channel(&self) -> &::fidl::AsyncChannel {
1969        self.client.as_channel()
1970    }
1971}
1972
1973impl SocketControlProxy {
1974    /// Create a new Proxy for fuchsia.net.filter/SocketControl.
1975    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1976        let protocol_name = <SocketControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1977        Self { client: fidl::client::Client::new(channel, protocol_name) }
1978    }
1979
1980    /// Get a Stream of events from the remote end of the protocol.
1981    ///
1982    /// # Panics
1983    ///
1984    /// Panics if the event stream was already taken.
1985    pub fn take_event_stream(&self) -> SocketControlEventStream {
1986        SocketControlEventStream { event_receiver: self.client.take_event_receiver() }
1987    }
1988
1989    /// Attaches the specified eBPF `program` to the specified `hook`.
1990    ///
1991    /// May fail if another program is already attached (potentially by another
1992    /// `SocketControl` instance).
1993    ///
1994    /// *Warning:* Caller must check that the specified program is compatible
1995    /// with the specified `hook`.
1996    pub fn r#attach_ebpf_program(
1997        &self,
1998        mut payload: AttachEbpfProgramOptions,
1999    ) -> fidl::client::QueryResponseFut<
2000        SocketControlAttachEbpfProgramResult,
2001        fidl::encoding::DefaultFuchsiaResourceDialect,
2002    > {
2003        SocketControlProxyInterface::r#attach_ebpf_program(self, payload)
2004    }
2005
2006    /// Detaches eBPF program from the specified `hook`.
2007    pub fn r#detach_ebpf_program(
2008        &self,
2009        mut hook: SocketHook,
2010    ) -> fidl::client::QueryResponseFut<
2011        SocketControlDetachEbpfProgramResult,
2012        fidl::encoding::DefaultFuchsiaResourceDialect,
2013    > {
2014        SocketControlProxyInterface::r#detach_ebpf_program(self, hook)
2015    }
2016}
2017
2018impl SocketControlProxyInterface for SocketControlProxy {
2019    type AttachEbpfProgramResponseFut = fidl::client::QueryResponseFut<
2020        SocketControlAttachEbpfProgramResult,
2021        fidl::encoding::DefaultFuchsiaResourceDialect,
2022    >;
2023    fn r#attach_ebpf_program(
2024        &self,
2025        mut payload: AttachEbpfProgramOptions,
2026    ) -> Self::AttachEbpfProgramResponseFut {
2027        fn _decode(
2028            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2029        ) -> Result<SocketControlAttachEbpfProgramResult, fidl::Error> {
2030            let _response = fidl::client::decode_transaction_body::<
2031                fidl::encoding::ResultType<
2032                    fidl::encoding::EmptyStruct,
2033                    SocketControlAttachEbpfProgramError,
2034                >,
2035                fidl::encoding::DefaultFuchsiaResourceDialect,
2036                0x35076256e3cc40e,
2037            >(_buf?)?;
2038            Ok(_response.map(|x| x))
2039        }
2040        self.client.send_query_and_decode::<
2041            AttachEbpfProgramOptions,
2042            SocketControlAttachEbpfProgramResult,
2043        >(
2044            &mut payload,
2045            0x35076256e3cc40e,
2046            fidl::encoding::DynamicFlags::empty(),
2047            _decode,
2048        )
2049    }
2050
2051    type DetachEbpfProgramResponseFut = fidl::client::QueryResponseFut<
2052        SocketControlDetachEbpfProgramResult,
2053        fidl::encoding::DefaultFuchsiaResourceDialect,
2054    >;
2055    fn r#detach_ebpf_program(&self, mut hook: SocketHook) -> Self::DetachEbpfProgramResponseFut {
2056        fn _decode(
2057            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2058        ) -> Result<SocketControlDetachEbpfProgramResult, fidl::Error> {
2059            let _response = fidl::client::decode_transaction_body::<
2060                fidl::encoding::ResultType<
2061                    fidl::encoding::EmptyStruct,
2062                    SocketControlDetachEbpfProgramError,
2063                >,
2064                fidl::encoding::DefaultFuchsiaResourceDialect,
2065                0x226db36c461b6c1,
2066            >(_buf?)?;
2067            Ok(_response.map(|x| x))
2068        }
2069        self.client.send_query_and_decode::<
2070            SocketControlDetachEbpfProgramRequest,
2071            SocketControlDetachEbpfProgramResult,
2072        >(
2073            (hook,),
2074            0x226db36c461b6c1,
2075            fidl::encoding::DynamicFlags::empty(),
2076            _decode,
2077        )
2078    }
2079}
2080
2081pub struct SocketControlEventStream {
2082    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2083}
2084
2085impl std::marker::Unpin for SocketControlEventStream {}
2086
2087impl futures::stream::FusedStream for SocketControlEventStream {
2088    fn is_terminated(&self) -> bool {
2089        self.event_receiver.is_terminated()
2090    }
2091}
2092
2093impl futures::Stream for SocketControlEventStream {
2094    type Item = Result<SocketControlEvent, fidl::Error>;
2095
2096    fn poll_next(
2097        mut self: std::pin::Pin<&mut Self>,
2098        cx: &mut std::task::Context<'_>,
2099    ) -> std::task::Poll<Option<Self::Item>> {
2100        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2101            &mut self.event_receiver,
2102            cx
2103        )?) {
2104            Some(buf) => std::task::Poll::Ready(Some(SocketControlEvent::decode(buf))),
2105            None => std::task::Poll::Ready(None),
2106        }
2107    }
2108}
2109
2110#[derive(Debug)]
2111pub enum SocketControlEvent {}
2112
2113impl SocketControlEvent {
2114    /// Decodes a message buffer as a [`SocketControlEvent`].
2115    fn decode(
2116        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2117    ) -> Result<SocketControlEvent, fidl::Error> {
2118        let (bytes, _handles) = buf.split_mut();
2119        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2120        debug_assert_eq!(tx_header.tx_id, 0);
2121        match tx_header.ordinal {
2122            _ => Err(fidl::Error::UnknownOrdinal {
2123                ordinal: tx_header.ordinal,
2124                protocol_name: <SocketControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2125            }),
2126        }
2127    }
2128}
2129
2130/// A Stream of incoming requests for fuchsia.net.filter/SocketControl.
2131pub struct SocketControlRequestStream {
2132    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2133    is_terminated: bool,
2134}
2135
2136impl std::marker::Unpin for SocketControlRequestStream {}
2137
2138impl futures::stream::FusedStream for SocketControlRequestStream {
2139    fn is_terminated(&self) -> bool {
2140        self.is_terminated
2141    }
2142}
2143
2144impl fidl::endpoints::RequestStream for SocketControlRequestStream {
2145    type Protocol = SocketControlMarker;
2146    type ControlHandle = SocketControlControlHandle;
2147
2148    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2149        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2150    }
2151
2152    fn control_handle(&self) -> Self::ControlHandle {
2153        SocketControlControlHandle { inner: self.inner.clone() }
2154    }
2155
2156    fn into_inner(
2157        self,
2158    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2159    {
2160        (self.inner, self.is_terminated)
2161    }
2162
2163    fn from_inner(
2164        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2165        is_terminated: bool,
2166    ) -> Self {
2167        Self { inner, is_terminated }
2168    }
2169}
2170
2171impl futures::Stream for SocketControlRequestStream {
2172    type Item = Result<SocketControlRequest, fidl::Error>;
2173
2174    fn poll_next(
2175        mut self: std::pin::Pin<&mut Self>,
2176        cx: &mut std::task::Context<'_>,
2177    ) -> std::task::Poll<Option<Self::Item>> {
2178        let this = &mut *self;
2179        if this.inner.check_shutdown(cx) {
2180            this.is_terminated = true;
2181            return std::task::Poll::Ready(None);
2182        }
2183        if this.is_terminated {
2184            panic!("polled SocketControlRequestStream after completion");
2185        }
2186        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2187            |bytes, handles| {
2188                match this.inner.channel().read_etc(cx, bytes, handles) {
2189                    std::task::Poll::Ready(Ok(())) => {}
2190                    std::task::Poll::Pending => return std::task::Poll::Pending,
2191                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2192                        this.is_terminated = true;
2193                        return std::task::Poll::Ready(None);
2194                    }
2195                    std::task::Poll::Ready(Err(e)) => {
2196                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2197                            e.into(),
2198                        ))));
2199                    }
2200                }
2201
2202                // A message has been received from the channel
2203                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2204
2205                std::task::Poll::Ready(Some(match header.ordinal {
2206                    0x35076256e3cc40e => {
2207                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2208                        let mut req = fidl::new_empty!(
2209                            AttachEbpfProgramOptions,
2210                            fidl::encoding::DefaultFuchsiaResourceDialect
2211                        );
2212                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AttachEbpfProgramOptions>(&header, _body_bytes, handles, &mut req)?;
2213                        let control_handle =
2214                            SocketControlControlHandle { inner: this.inner.clone() };
2215                        Ok(SocketControlRequest::AttachEbpfProgram {
2216                            payload: req,
2217                            responder: SocketControlAttachEbpfProgramResponder {
2218                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2219                                tx_id: header.tx_id,
2220                            },
2221                        })
2222                    }
2223                    0x226db36c461b6c1 => {
2224                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2225                        let mut req = fidl::new_empty!(
2226                            SocketControlDetachEbpfProgramRequest,
2227                            fidl::encoding::DefaultFuchsiaResourceDialect
2228                        );
2229                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SocketControlDetachEbpfProgramRequest>(&header, _body_bytes, handles, &mut req)?;
2230                        let control_handle =
2231                            SocketControlControlHandle { inner: this.inner.clone() };
2232                        Ok(SocketControlRequest::DetachEbpfProgram {
2233                            hook: req.hook,
2234
2235                            responder: SocketControlDetachEbpfProgramResponder {
2236                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2237                                tx_id: header.tx_id,
2238                            },
2239                        })
2240                    }
2241                    _ => Err(fidl::Error::UnknownOrdinal {
2242                        ordinal: header.ordinal,
2243                        protocol_name:
2244                            <SocketControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2245                    }),
2246                }))
2247            },
2248        )
2249    }
2250}
2251
2252/// Allows to attach eBPF filters to sockets API.
2253///
2254/// More than one `SocketControl` client is allowed but they cannot install
2255/// more than one filter for the same hook. Closing the client end causes
2256/// all filters installed by that client to be removed.
2257///
2258/// *Warning:* Currently this protocol should be routed only to Starnix.
2259#[derive(Debug)]
2260pub enum SocketControlRequest {
2261    /// Attaches the specified eBPF `program` to the specified `hook`.
2262    ///
2263    /// May fail if another program is already attached (potentially by another
2264    /// `SocketControl` instance).
2265    ///
2266    /// *Warning:* Caller must check that the specified program is compatible
2267    /// with the specified `hook`.
2268    AttachEbpfProgram {
2269        payload: AttachEbpfProgramOptions,
2270        responder: SocketControlAttachEbpfProgramResponder,
2271    },
2272    /// Detaches eBPF program from the specified `hook`.
2273    DetachEbpfProgram { hook: SocketHook, responder: SocketControlDetachEbpfProgramResponder },
2274}
2275
2276impl SocketControlRequest {
2277    #[allow(irrefutable_let_patterns)]
2278    pub fn into_attach_ebpf_program(
2279        self,
2280    ) -> Option<(AttachEbpfProgramOptions, SocketControlAttachEbpfProgramResponder)> {
2281        if let SocketControlRequest::AttachEbpfProgram { payload, responder } = self {
2282            Some((payload, responder))
2283        } else {
2284            None
2285        }
2286    }
2287
2288    #[allow(irrefutable_let_patterns)]
2289    pub fn into_detach_ebpf_program(
2290        self,
2291    ) -> Option<(SocketHook, SocketControlDetachEbpfProgramResponder)> {
2292        if let SocketControlRequest::DetachEbpfProgram { hook, responder } = self {
2293            Some((hook, responder))
2294        } else {
2295            None
2296        }
2297    }
2298
2299    /// Name of the method defined in FIDL
2300    pub fn method_name(&self) -> &'static str {
2301        match *self {
2302            SocketControlRequest::AttachEbpfProgram { .. } => "attach_ebpf_program",
2303            SocketControlRequest::DetachEbpfProgram { .. } => "detach_ebpf_program",
2304        }
2305    }
2306}
2307
2308#[derive(Debug, Clone)]
2309pub struct SocketControlControlHandle {
2310    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2311}
2312
2313impl fidl::endpoints::ControlHandle for SocketControlControlHandle {
2314    fn shutdown(&self) {
2315        self.inner.shutdown()
2316    }
2317
2318    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2319        self.inner.shutdown_with_epitaph(status)
2320    }
2321
2322    fn is_closed(&self) -> bool {
2323        self.inner.channel().is_closed()
2324    }
2325    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2326        self.inner.channel().on_closed()
2327    }
2328
2329    #[cfg(target_os = "fuchsia")]
2330    fn signal_peer(
2331        &self,
2332        clear_mask: zx::Signals,
2333        set_mask: zx::Signals,
2334    ) -> Result<(), zx_status::Status> {
2335        use fidl::Peered;
2336        self.inner.channel().signal_peer(clear_mask, set_mask)
2337    }
2338}
2339
2340impl SocketControlControlHandle {}
2341
2342#[must_use = "FIDL methods require a response to be sent"]
2343#[derive(Debug)]
2344pub struct SocketControlAttachEbpfProgramResponder {
2345    control_handle: std::mem::ManuallyDrop<SocketControlControlHandle>,
2346    tx_id: u32,
2347}
2348
2349/// Set the the channel to be shutdown (see [`SocketControlControlHandle::shutdown`])
2350/// if the responder is dropped without sending a response, so that the client
2351/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2352impl std::ops::Drop for SocketControlAttachEbpfProgramResponder {
2353    fn drop(&mut self) {
2354        self.control_handle.shutdown();
2355        // Safety: drops once, never accessed again
2356        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2357    }
2358}
2359
2360impl fidl::endpoints::Responder for SocketControlAttachEbpfProgramResponder {
2361    type ControlHandle = SocketControlControlHandle;
2362
2363    fn control_handle(&self) -> &SocketControlControlHandle {
2364        &self.control_handle
2365    }
2366
2367    fn drop_without_shutdown(mut self) {
2368        // Safety: drops once, never accessed again due to mem::forget
2369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2370        // Prevent Drop from running (which would shut down the channel)
2371        std::mem::forget(self);
2372    }
2373}
2374
2375impl SocketControlAttachEbpfProgramResponder {
2376    /// Sends a response to the FIDL transaction.
2377    ///
2378    /// Sets the channel to shutdown if an error occurs.
2379    pub fn send(
2380        self,
2381        mut result: Result<(), SocketControlAttachEbpfProgramError>,
2382    ) -> Result<(), fidl::Error> {
2383        let _result = self.send_raw(result);
2384        if _result.is_err() {
2385            self.control_handle.shutdown();
2386        }
2387        self.drop_without_shutdown();
2388        _result
2389    }
2390
2391    /// Similar to "send" but does not shutdown the channel if an error occurs.
2392    pub fn send_no_shutdown_on_err(
2393        self,
2394        mut result: Result<(), SocketControlAttachEbpfProgramError>,
2395    ) -> Result<(), fidl::Error> {
2396        let _result = self.send_raw(result);
2397        self.drop_without_shutdown();
2398        _result
2399    }
2400
2401    fn send_raw(
2402        &self,
2403        mut result: Result<(), SocketControlAttachEbpfProgramError>,
2404    ) -> Result<(), fidl::Error> {
2405        self.control_handle.inner.send::<fidl::encoding::ResultType<
2406            fidl::encoding::EmptyStruct,
2407            SocketControlAttachEbpfProgramError,
2408        >>(
2409            result,
2410            self.tx_id,
2411            0x35076256e3cc40e,
2412            fidl::encoding::DynamicFlags::empty(),
2413        )
2414    }
2415}
2416
2417#[must_use = "FIDL methods require a response to be sent"]
2418#[derive(Debug)]
2419pub struct SocketControlDetachEbpfProgramResponder {
2420    control_handle: std::mem::ManuallyDrop<SocketControlControlHandle>,
2421    tx_id: u32,
2422}
2423
2424/// Set the the channel to be shutdown (see [`SocketControlControlHandle::shutdown`])
2425/// if the responder is dropped without sending a response, so that the client
2426/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2427impl std::ops::Drop for SocketControlDetachEbpfProgramResponder {
2428    fn drop(&mut self) {
2429        self.control_handle.shutdown();
2430        // Safety: drops once, never accessed again
2431        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2432    }
2433}
2434
2435impl fidl::endpoints::Responder for SocketControlDetachEbpfProgramResponder {
2436    type ControlHandle = SocketControlControlHandle;
2437
2438    fn control_handle(&self) -> &SocketControlControlHandle {
2439        &self.control_handle
2440    }
2441
2442    fn drop_without_shutdown(mut self) {
2443        // Safety: drops once, never accessed again due to mem::forget
2444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2445        // Prevent Drop from running (which would shut down the channel)
2446        std::mem::forget(self);
2447    }
2448}
2449
2450impl SocketControlDetachEbpfProgramResponder {
2451    /// Sends a response to the FIDL transaction.
2452    ///
2453    /// Sets the channel to shutdown if an error occurs.
2454    pub fn send(
2455        self,
2456        mut result: Result<(), SocketControlDetachEbpfProgramError>,
2457    ) -> Result<(), fidl::Error> {
2458        let _result = self.send_raw(result);
2459        if _result.is_err() {
2460            self.control_handle.shutdown();
2461        }
2462        self.drop_without_shutdown();
2463        _result
2464    }
2465
2466    /// Similar to "send" but does not shutdown the channel if an error occurs.
2467    pub fn send_no_shutdown_on_err(
2468        self,
2469        mut result: Result<(), SocketControlDetachEbpfProgramError>,
2470    ) -> Result<(), fidl::Error> {
2471        let _result = self.send_raw(result);
2472        self.drop_without_shutdown();
2473        _result
2474    }
2475
2476    fn send_raw(
2477        &self,
2478        mut result: Result<(), SocketControlDetachEbpfProgramError>,
2479    ) -> Result<(), fidl::Error> {
2480        self.control_handle.inner.send::<fidl::encoding::ResultType<
2481            fidl::encoding::EmptyStruct,
2482            SocketControlDetachEbpfProgramError,
2483        >>(
2484            result,
2485            self.tx_id,
2486            0x226db36c461b6c1,
2487            fidl::encoding::DynamicFlags::empty(),
2488        )
2489    }
2490}
2491
2492#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2493pub struct StateMarker;
2494
2495impl fidl::endpoints::ProtocolMarker for StateMarker {
2496    type Proxy = StateProxy;
2497    type RequestStream = StateRequestStream;
2498    #[cfg(target_os = "fuchsia")]
2499    type SynchronousProxy = StateSynchronousProxy;
2500
2501    const DEBUG_NAME: &'static str = "fuchsia.net.filter.State";
2502}
2503impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
2504
2505pub trait StateProxyInterface: Send + Sync {
2506    fn r#get_watcher(
2507        &self,
2508        options: &WatcherOptions,
2509        request: fidl::endpoints::ServerEnd<WatcherMarker>,
2510    ) -> Result<(), fidl::Error>;
2511}
2512#[derive(Debug)]
2513#[cfg(target_os = "fuchsia")]
2514pub struct StateSynchronousProxy {
2515    client: fidl::client::sync::Client,
2516}
2517
2518#[cfg(target_os = "fuchsia")]
2519impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
2520    type Proxy = StateProxy;
2521    type Protocol = StateMarker;
2522
2523    fn from_channel(inner: fidl::Channel) -> Self {
2524        Self::new(inner)
2525    }
2526
2527    fn into_channel(self) -> fidl::Channel {
2528        self.client.into_channel()
2529    }
2530
2531    fn as_channel(&self) -> &fidl::Channel {
2532        self.client.as_channel()
2533    }
2534}
2535
2536#[cfg(target_os = "fuchsia")]
2537impl StateSynchronousProxy {
2538    pub fn new(channel: fidl::Channel) -> Self {
2539        Self { client: fidl::client::sync::Client::new(channel) }
2540    }
2541
2542    pub fn into_channel(self) -> fidl::Channel {
2543        self.client.into_channel()
2544    }
2545
2546    /// Waits until an event arrives and returns it. It is safe for other
2547    /// threads to make concurrent requests while waiting for an event.
2548    pub fn wait_for_event(
2549        &self,
2550        deadline: zx::MonotonicInstant,
2551    ) -> Result<StateEvent, fidl::Error> {
2552        StateEvent::decode(self.client.wait_for_event::<StateMarker>(deadline)?)
2553    }
2554
2555    /// Initialize a watcher for filtering state.
2556    pub fn r#get_watcher(
2557        &self,
2558        mut options: &WatcherOptions,
2559        mut request: fidl::endpoints::ServerEnd<WatcherMarker>,
2560    ) -> Result<(), fidl::Error> {
2561        self.client.send::<StateGetWatcherRequest>(
2562            (options, request),
2563            0x663aae2b6bc5aa14,
2564            fidl::encoding::DynamicFlags::empty(),
2565        )
2566    }
2567}
2568
2569#[cfg(target_os = "fuchsia")]
2570impl From<StateSynchronousProxy> for zx::NullableHandle {
2571    fn from(value: StateSynchronousProxy) -> Self {
2572        value.into_channel().into()
2573    }
2574}
2575
2576#[cfg(target_os = "fuchsia")]
2577impl From<fidl::Channel> for StateSynchronousProxy {
2578    fn from(value: fidl::Channel) -> Self {
2579        Self::new(value)
2580    }
2581}
2582
2583#[cfg(target_os = "fuchsia")]
2584impl fidl::endpoints::FromClient for StateSynchronousProxy {
2585    type Protocol = StateMarker;
2586
2587    fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
2588        Self::new(value.into_channel())
2589    }
2590}
2591
2592#[derive(Debug, Clone)]
2593pub struct StateProxy {
2594    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2595}
2596
2597impl fidl::endpoints::Proxy for StateProxy {
2598    type Protocol = StateMarker;
2599
2600    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2601        Self::new(inner)
2602    }
2603
2604    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2605        self.client.into_channel().map_err(|client| Self { client })
2606    }
2607
2608    fn as_channel(&self) -> &::fidl::AsyncChannel {
2609        self.client.as_channel()
2610    }
2611}
2612
2613impl StateProxy {
2614    /// Create a new Proxy for fuchsia.net.filter/State.
2615    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2616        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2617        Self { client: fidl::client::Client::new(channel, protocol_name) }
2618    }
2619
2620    /// Get a Stream of events from the remote end of the protocol.
2621    ///
2622    /// # Panics
2623    ///
2624    /// Panics if the event stream was already taken.
2625    pub fn take_event_stream(&self) -> StateEventStream {
2626        StateEventStream { event_receiver: self.client.take_event_receiver() }
2627    }
2628
2629    /// Initialize a watcher for filtering state.
2630    pub fn r#get_watcher(
2631        &self,
2632        mut options: &WatcherOptions,
2633        mut request: fidl::endpoints::ServerEnd<WatcherMarker>,
2634    ) -> Result<(), fidl::Error> {
2635        StateProxyInterface::r#get_watcher(self, options, request)
2636    }
2637}
2638
2639impl StateProxyInterface for StateProxy {
2640    fn r#get_watcher(
2641        &self,
2642        mut options: &WatcherOptions,
2643        mut request: fidl::endpoints::ServerEnd<WatcherMarker>,
2644    ) -> Result<(), fidl::Error> {
2645        self.client.send::<StateGetWatcherRequest>(
2646            (options, request),
2647            0x663aae2b6bc5aa14,
2648            fidl::encoding::DynamicFlags::empty(),
2649        )
2650    }
2651}
2652
2653pub struct StateEventStream {
2654    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2655}
2656
2657impl std::marker::Unpin for StateEventStream {}
2658
2659impl futures::stream::FusedStream for StateEventStream {
2660    fn is_terminated(&self) -> bool {
2661        self.event_receiver.is_terminated()
2662    }
2663}
2664
2665impl futures::Stream for StateEventStream {
2666    type Item = Result<StateEvent, fidl::Error>;
2667
2668    fn poll_next(
2669        mut self: std::pin::Pin<&mut Self>,
2670        cx: &mut std::task::Context<'_>,
2671    ) -> std::task::Poll<Option<Self::Item>> {
2672        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2673            &mut self.event_receiver,
2674            cx
2675        )?) {
2676            Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
2677            None => std::task::Poll::Ready(None),
2678        }
2679    }
2680}
2681
2682#[derive(Debug)]
2683pub enum StateEvent {}
2684
2685impl StateEvent {
2686    /// Decodes a message buffer as a [`StateEvent`].
2687    fn decode(
2688        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2689    ) -> Result<StateEvent, fidl::Error> {
2690        let (bytes, _handles) = buf.split_mut();
2691        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2692        debug_assert_eq!(tx_header.tx_id, 0);
2693        match tx_header.ordinal {
2694            _ => Err(fidl::Error::UnknownOrdinal {
2695                ordinal: tx_header.ordinal,
2696                protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2697            }),
2698        }
2699    }
2700}
2701
2702/// A Stream of incoming requests for fuchsia.net.filter/State.
2703pub struct StateRequestStream {
2704    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2705    is_terminated: bool,
2706}
2707
2708impl std::marker::Unpin for StateRequestStream {}
2709
2710impl futures::stream::FusedStream for StateRequestStream {
2711    fn is_terminated(&self) -> bool {
2712        self.is_terminated
2713    }
2714}
2715
2716impl fidl::endpoints::RequestStream for StateRequestStream {
2717    type Protocol = StateMarker;
2718    type ControlHandle = StateControlHandle;
2719
2720    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2721        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2722    }
2723
2724    fn control_handle(&self) -> Self::ControlHandle {
2725        StateControlHandle { inner: self.inner.clone() }
2726    }
2727
2728    fn into_inner(
2729        self,
2730    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2731    {
2732        (self.inner, self.is_terminated)
2733    }
2734
2735    fn from_inner(
2736        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2737        is_terminated: bool,
2738    ) -> Self {
2739        Self { inner, is_terminated }
2740    }
2741}
2742
2743impl futures::Stream for StateRequestStream {
2744    type Item = Result<StateRequest, fidl::Error>;
2745
2746    fn poll_next(
2747        mut self: std::pin::Pin<&mut Self>,
2748        cx: &mut std::task::Context<'_>,
2749    ) -> std::task::Poll<Option<Self::Item>> {
2750        let this = &mut *self;
2751        if this.inner.check_shutdown(cx) {
2752            this.is_terminated = true;
2753            return std::task::Poll::Ready(None);
2754        }
2755        if this.is_terminated {
2756            panic!("polled StateRequestStream after completion");
2757        }
2758        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2759            |bytes, handles| {
2760                match this.inner.channel().read_etc(cx, bytes, handles) {
2761                    std::task::Poll::Ready(Ok(())) => {}
2762                    std::task::Poll::Pending => return std::task::Poll::Pending,
2763                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2764                        this.is_terminated = true;
2765                        return std::task::Poll::Ready(None);
2766                    }
2767                    std::task::Poll::Ready(Err(e)) => {
2768                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2769                            e.into(),
2770                        ))));
2771                    }
2772                }
2773
2774                // A message has been received from the channel
2775                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2776
2777                std::task::Poll::Ready(Some(match header.ordinal {
2778                    0x663aae2b6bc5aa14 => {
2779                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2780                        let mut req = fidl::new_empty!(
2781                            StateGetWatcherRequest,
2782                            fidl::encoding::DefaultFuchsiaResourceDialect
2783                        );
2784                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateGetWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
2785                        let control_handle = StateControlHandle { inner: this.inner.clone() };
2786                        Ok(StateRequest::GetWatcher {
2787                            options: req.options,
2788                            request: req.request,
2789
2790                            control_handle,
2791                        })
2792                    }
2793                    _ => Err(fidl::Error::UnknownOrdinal {
2794                        ordinal: header.ordinal,
2795                        protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2796                    }),
2797                }))
2798            },
2799        )
2800    }
2801}
2802
2803/// Provides view-only access to the system's packet filtering state.
2804#[derive(Debug)]
2805pub enum StateRequest {
2806    /// Initialize a watcher for filtering state.
2807    GetWatcher {
2808        options: WatcherOptions,
2809        request: fidl::endpoints::ServerEnd<WatcherMarker>,
2810        control_handle: StateControlHandle,
2811    },
2812}
2813
2814impl StateRequest {
2815    #[allow(irrefutable_let_patterns)]
2816    pub fn into_get_watcher(
2817        self,
2818    ) -> Option<(WatcherOptions, fidl::endpoints::ServerEnd<WatcherMarker>, StateControlHandle)>
2819    {
2820        if let StateRequest::GetWatcher { options, request, control_handle } = self {
2821            Some((options, request, control_handle))
2822        } else {
2823            None
2824        }
2825    }
2826
2827    /// Name of the method defined in FIDL
2828    pub fn method_name(&self) -> &'static str {
2829        match *self {
2830            StateRequest::GetWatcher { .. } => "get_watcher",
2831        }
2832    }
2833}
2834
2835#[derive(Debug, Clone)]
2836pub struct StateControlHandle {
2837    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2838}
2839
2840impl fidl::endpoints::ControlHandle for StateControlHandle {
2841    fn shutdown(&self) {
2842        self.inner.shutdown()
2843    }
2844
2845    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2846        self.inner.shutdown_with_epitaph(status)
2847    }
2848
2849    fn is_closed(&self) -> bool {
2850        self.inner.channel().is_closed()
2851    }
2852    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2853        self.inner.channel().on_closed()
2854    }
2855
2856    #[cfg(target_os = "fuchsia")]
2857    fn signal_peer(
2858        &self,
2859        clear_mask: zx::Signals,
2860        set_mask: zx::Signals,
2861    ) -> Result<(), zx_status::Status> {
2862        use fidl::Peered;
2863        self.inner.channel().signal_peer(clear_mask, set_mask)
2864    }
2865}
2866
2867impl StateControlHandle {}
2868
2869#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2870pub struct WatcherMarker;
2871
2872impl fidl::endpoints::ProtocolMarker for WatcherMarker {
2873    type Proxy = WatcherProxy;
2874    type RequestStream = WatcherRequestStream;
2875    #[cfg(target_os = "fuchsia")]
2876    type SynchronousProxy = WatcherSynchronousProxy;
2877
2878    const DEBUG_NAME: &'static str = "(anonymous) Watcher";
2879}
2880
2881pub trait WatcherProxyInterface: Send + Sync {
2882    type WatchResponseFut: std::future::Future<Output = Result<Vec<Event>, fidl::Error>> + Send;
2883    fn r#watch(&self) -> Self::WatchResponseFut;
2884}
2885#[derive(Debug)]
2886#[cfg(target_os = "fuchsia")]
2887pub struct WatcherSynchronousProxy {
2888    client: fidl::client::sync::Client,
2889}
2890
2891#[cfg(target_os = "fuchsia")]
2892impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
2893    type Proxy = WatcherProxy;
2894    type Protocol = WatcherMarker;
2895
2896    fn from_channel(inner: fidl::Channel) -> Self {
2897        Self::new(inner)
2898    }
2899
2900    fn into_channel(self) -> fidl::Channel {
2901        self.client.into_channel()
2902    }
2903
2904    fn as_channel(&self) -> &fidl::Channel {
2905        self.client.as_channel()
2906    }
2907}
2908
2909#[cfg(target_os = "fuchsia")]
2910impl WatcherSynchronousProxy {
2911    pub fn new(channel: fidl::Channel) -> Self {
2912        Self { client: fidl::client::sync::Client::new(channel) }
2913    }
2914
2915    pub fn into_channel(self) -> fidl::Channel {
2916        self.client.into_channel()
2917    }
2918
2919    /// Waits until an event arrives and returns it. It is safe for other
2920    /// threads to make concurrent requests while waiting for an event.
2921    pub fn wait_for_event(
2922        &self,
2923        deadline: zx::MonotonicInstant,
2924    ) -> Result<WatcherEvent, fidl::Error> {
2925        WatcherEvent::decode(self.client.wait_for_event::<WatcherMarker>(deadline)?)
2926    }
2927
2928    /// Hanging get for filtering resource changes.
2929    ///
2930    /// Clients should only have one pending call of this method outstanding at
2931    /// a time; a second call to this method while a call is already pending
2932    /// will cause the server to close the channel.
2933    ///
2934    /// The first N events returned by this method will be [`Event.existing`],
2935    /// enumerating all existing N filtering resources, followed by a single
2936    /// [`Event.idle`] indicating that all existing resources have been sent.
2937    /// Subsequent calls will immediately return with new events if there is at
2938    /// least one to be reported, or will otherwise block until an event occurs.
2939    ///
2940    /// In order to communicate atomic updates, after the initial state is
2941    /// provided followed by [`Event.idle`], a sequence of events that occurred
2942    /// atomically will always be followed by [`Event.end_of_update`],
2943    /// demarcating the end of the atomic update.
2944    ///
2945    /// Note that each non-sentinel event is scoped to a controller; the
2946    /// [`ControllerId`] is provided along with the event to allow the client to
2947    /// disambiguate.
2948    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Event>, fidl::Error> {
2949        let _response = self
2950            .client
2951            .send_query::<fidl::encoding::EmptyPayload, WatcherWatchResponse, WatcherMarker>(
2952                (),
2953                0x5f62165a0638ca75,
2954                fidl::encoding::DynamicFlags::empty(),
2955                ___deadline,
2956            )?;
2957        Ok(_response.events)
2958    }
2959}
2960
2961#[cfg(target_os = "fuchsia")]
2962impl From<WatcherSynchronousProxy> for zx::NullableHandle {
2963    fn from(value: WatcherSynchronousProxy) -> Self {
2964        value.into_channel().into()
2965    }
2966}
2967
2968#[cfg(target_os = "fuchsia")]
2969impl From<fidl::Channel> for WatcherSynchronousProxy {
2970    fn from(value: fidl::Channel) -> Self {
2971        Self::new(value)
2972    }
2973}
2974
2975#[cfg(target_os = "fuchsia")]
2976impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
2977    type Protocol = WatcherMarker;
2978
2979    fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
2980        Self::new(value.into_channel())
2981    }
2982}
2983
2984#[derive(Debug, Clone)]
2985pub struct WatcherProxy {
2986    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2987}
2988
2989impl fidl::endpoints::Proxy for WatcherProxy {
2990    type Protocol = WatcherMarker;
2991
2992    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2993        Self::new(inner)
2994    }
2995
2996    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2997        self.client.into_channel().map_err(|client| Self { client })
2998    }
2999
3000    fn as_channel(&self) -> &::fidl::AsyncChannel {
3001        self.client.as_channel()
3002    }
3003}
3004
3005impl WatcherProxy {
3006    /// Create a new Proxy for fuchsia.net.filter/Watcher.
3007    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3008        let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3009        Self { client: fidl::client::Client::new(channel, protocol_name) }
3010    }
3011
3012    /// Get a Stream of events from the remote end of the protocol.
3013    ///
3014    /// # Panics
3015    ///
3016    /// Panics if the event stream was already taken.
3017    pub fn take_event_stream(&self) -> WatcherEventStream {
3018        WatcherEventStream { event_receiver: self.client.take_event_receiver() }
3019    }
3020
3021    /// Hanging get for filtering resource changes.
3022    ///
3023    /// Clients should only have one pending call of this method outstanding at
3024    /// a time; a second call to this method while a call is already pending
3025    /// will cause the server to close the channel.
3026    ///
3027    /// The first N events returned by this method will be [`Event.existing`],
3028    /// enumerating all existing N filtering resources, followed by a single
3029    /// [`Event.idle`] indicating that all existing resources have been sent.
3030    /// Subsequent calls will immediately return with new events if there is at
3031    /// least one to be reported, or will otherwise block until an event occurs.
3032    ///
3033    /// In order to communicate atomic updates, after the initial state is
3034    /// provided followed by [`Event.idle`], a sequence of events that occurred
3035    /// atomically will always be followed by [`Event.end_of_update`],
3036    /// demarcating the end of the atomic update.
3037    ///
3038    /// Note that each non-sentinel event is scoped to a controller; the
3039    /// [`ControllerId`] is provided along with the event to allow the client to
3040    /// disambiguate.
3041    pub fn r#watch(
3042        &self,
3043    ) -> fidl::client::QueryResponseFut<Vec<Event>, fidl::encoding::DefaultFuchsiaResourceDialect>
3044    {
3045        WatcherProxyInterface::r#watch(self)
3046    }
3047}
3048
3049impl WatcherProxyInterface for WatcherProxy {
3050    type WatchResponseFut =
3051        fidl::client::QueryResponseFut<Vec<Event>, fidl::encoding::DefaultFuchsiaResourceDialect>;
3052    fn r#watch(&self) -> Self::WatchResponseFut {
3053        fn _decode(
3054            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3055        ) -> Result<Vec<Event>, fidl::Error> {
3056            let _response = fidl::client::decode_transaction_body::<
3057                WatcherWatchResponse,
3058                fidl::encoding::DefaultFuchsiaResourceDialect,
3059                0x5f62165a0638ca75,
3060            >(_buf?)?;
3061            Ok(_response.events)
3062        }
3063        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Event>>(
3064            (),
3065            0x5f62165a0638ca75,
3066            fidl::encoding::DynamicFlags::empty(),
3067            _decode,
3068        )
3069    }
3070}
3071
3072pub struct WatcherEventStream {
3073    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3074}
3075
3076impl std::marker::Unpin for WatcherEventStream {}
3077
3078impl futures::stream::FusedStream for WatcherEventStream {
3079    fn is_terminated(&self) -> bool {
3080        self.event_receiver.is_terminated()
3081    }
3082}
3083
3084impl futures::Stream for WatcherEventStream {
3085    type Item = Result<WatcherEvent, fidl::Error>;
3086
3087    fn poll_next(
3088        mut self: std::pin::Pin<&mut Self>,
3089        cx: &mut std::task::Context<'_>,
3090    ) -> std::task::Poll<Option<Self::Item>> {
3091        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3092            &mut self.event_receiver,
3093            cx
3094        )?) {
3095            Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
3096            None => std::task::Poll::Ready(None),
3097        }
3098    }
3099}
3100
3101#[derive(Debug)]
3102pub enum WatcherEvent {}
3103
3104impl WatcherEvent {
3105    /// Decodes a message buffer as a [`WatcherEvent`].
3106    fn decode(
3107        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3108    ) -> Result<WatcherEvent, fidl::Error> {
3109        let (bytes, _handles) = buf.split_mut();
3110        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3111        debug_assert_eq!(tx_header.tx_id, 0);
3112        match tx_header.ordinal {
3113            _ => Err(fidl::Error::UnknownOrdinal {
3114                ordinal: tx_header.ordinal,
3115                protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3116            }),
3117        }
3118    }
3119}
3120
3121/// A Stream of incoming requests for fuchsia.net.filter/Watcher.
3122pub struct WatcherRequestStream {
3123    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3124    is_terminated: bool,
3125}
3126
3127impl std::marker::Unpin for WatcherRequestStream {}
3128
3129impl futures::stream::FusedStream for WatcherRequestStream {
3130    fn is_terminated(&self) -> bool {
3131        self.is_terminated
3132    }
3133}
3134
3135impl fidl::endpoints::RequestStream for WatcherRequestStream {
3136    type Protocol = WatcherMarker;
3137    type ControlHandle = WatcherControlHandle;
3138
3139    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3140        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3141    }
3142
3143    fn control_handle(&self) -> Self::ControlHandle {
3144        WatcherControlHandle { inner: self.inner.clone() }
3145    }
3146
3147    fn into_inner(
3148        self,
3149    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3150    {
3151        (self.inner, self.is_terminated)
3152    }
3153
3154    fn from_inner(
3155        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3156        is_terminated: bool,
3157    ) -> Self {
3158        Self { inner, is_terminated }
3159    }
3160}
3161
3162impl futures::Stream for WatcherRequestStream {
3163    type Item = Result<WatcherRequest, fidl::Error>;
3164
3165    fn poll_next(
3166        mut self: std::pin::Pin<&mut Self>,
3167        cx: &mut std::task::Context<'_>,
3168    ) -> std::task::Poll<Option<Self::Item>> {
3169        let this = &mut *self;
3170        if this.inner.check_shutdown(cx) {
3171            this.is_terminated = true;
3172            return std::task::Poll::Ready(None);
3173        }
3174        if this.is_terminated {
3175            panic!("polled WatcherRequestStream after completion");
3176        }
3177        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3178            |bytes, handles| {
3179                match this.inner.channel().read_etc(cx, bytes, handles) {
3180                    std::task::Poll::Ready(Ok(())) => {}
3181                    std::task::Poll::Pending => return std::task::Poll::Pending,
3182                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3183                        this.is_terminated = true;
3184                        return std::task::Poll::Ready(None);
3185                    }
3186                    std::task::Poll::Ready(Err(e)) => {
3187                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3188                            e.into(),
3189                        ))));
3190                    }
3191                }
3192
3193                // A message has been received from the channel
3194                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3195
3196                std::task::Poll::Ready(Some(match header.ordinal {
3197                    0x5f62165a0638ca75 => {
3198                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3199                        let mut req = fidl::new_empty!(
3200                            fidl::encoding::EmptyPayload,
3201                            fidl::encoding::DefaultFuchsiaResourceDialect
3202                        );
3203                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3204                        let control_handle = WatcherControlHandle { inner: this.inner.clone() };
3205                        Ok(WatcherRequest::Watch {
3206                            responder: WatcherWatchResponder {
3207                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3208                                tx_id: header.tx_id,
3209                            },
3210                        })
3211                    }
3212                    _ => Err(fidl::Error::UnknownOrdinal {
3213                        ordinal: header.ordinal,
3214                        protocol_name:
3215                            <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3216                    }),
3217                }))
3218            },
3219        )
3220    }
3221}
3222
3223/// Observer protocol for changes to packet filtering state (addition, deletion,
3224/// and updates to filtering resources).
3225#[derive(Debug)]
3226pub enum WatcherRequest {
3227    /// Hanging get for filtering resource changes.
3228    ///
3229    /// Clients should only have one pending call of this method outstanding at
3230    /// a time; a second call to this method while a call is already pending
3231    /// will cause the server to close the channel.
3232    ///
3233    /// The first N events returned by this method will be [`Event.existing`],
3234    /// enumerating all existing N filtering resources, followed by a single
3235    /// [`Event.idle`] indicating that all existing resources have been sent.
3236    /// Subsequent calls will immediately return with new events if there is at
3237    /// least one to be reported, or will otherwise block until an event occurs.
3238    ///
3239    /// In order to communicate atomic updates, after the initial state is
3240    /// provided followed by [`Event.idle`], a sequence of events that occurred
3241    /// atomically will always be followed by [`Event.end_of_update`],
3242    /// demarcating the end of the atomic update.
3243    ///
3244    /// Note that each non-sentinel event is scoped to a controller; the
3245    /// [`ControllerId`] is provided along with the event to allow the client to
3246    /// disambiguate.
3247    Watch { responder: WatcherWatchResponder },
3248}
3249
3250impl WatcherRequest {
3251    #[allow(irrefutable_let_patterns)]
3252    pub fn into_watch(self) -> Option<(WatcherWatchResponder)> {
3253        if let WatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
3254    }
3255
3256    /// Name of the method defined in FIDL
3257    pub fn method_name(&self) -> &'static str {
3258        match *self {
3259            WatcherRequest::Watch { .. } => "watch",
3260        }
3261    }
3262}
3263
3264#[derive(Debug, Clone)]
3265pub struct WatcherControlHandle {
3266    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3267}
3268
3269impl fidl::endpoints::ControlHandle for WatcherControlHandle {
3270    fn shutdown(&self) {
3271        self.inner.shutdown()
3272    }
3273
3274    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3275        self.inner.shutdown_with_epitaph(status)
3276    }
3277
3278    fn is_closed(&self) -> bool {
3279        self.inner.channel().is_closed()
3280    }
3281    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3282        self.inner.channel().on_closed()
3283    }
3284
3285    #[cfg(target_os = "fuchsia")]
3286    fn signal_peer(
3287        &self,
3288        clear_mask: zx::Signals,
3289        set_mask: zx::Signals,
3290    ) -> Result<(), zx_status::Status> {
3291        use fidl::Peered;
3292        self.inner.channel().signal_peer(clear_mask, set_mask)
3293    }
3294}
3295
3296impl WatcherControlHandle {}
3297
3298#[must_use = "FIDL methods require a response to be sent"]
3299#[derive(Debug)]
3300pub struct WatcherWatchResponder {
3301    control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
3302    tx_id: u32,
3303}
3304
3305/// Set the the channel to be shutdown (see [`WatcherControlHandle::shutdown`])
3306/// if the responder is dropped without sending a response, so that the client
3307/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3308impl std::ops::Drop for WatcherWatchResponder {
3309    fn drop(&mut self) {
3310        self.control_handle.shutdown();
3311        // Safety: drops once, never accessed again
3312        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3313    }
3314}
3315
3316impl fidl::endpoints::Responder for WatcherWatchResponder {
3317    type ControlHandle = WatcherControlHandle;
3318
3319    fn control_handle(&self) -> &WatcherControlHandle {
3320        &self.control_handle
3321    }
3322
3323    fn drop_without_shutdown(mut self) {
3324        // Safety: drops once, never accessed again due to mem::forget
3325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3326        // Prevent Drop from running (which would shut down the channel)
3327        std::mem::forget(self);
3328    }
3329}
3330
3331impl WatcherWatchResponder {
3332    /// Sends a response to the FIDL transaction.
3333    ///
3334    /// Sets the channel to shutdown if an error occurs.
3335    pub fn send(self, mut events: &[Event]) -> Result<(), fidl::Error> {
3336        let _result = self.send_raw(events);
3337        if _result.is_err() {
3338            self.control_handle.shutdown();
3339        }
3340        self.drop_without_shutdown();
3341        _result
3342    }
3343
3344    /// Similar to "send" but does not shutdown the channel if an error occurs.
3345    pub fn send_no_shutdown_on_err(self, mut events: &[Event]) -> Result<(), fidl::Error> {
3346        let _result = self.send_raw(events);
3347        self.drop_without_shutdown();
3348        _result
3349    }
3350
3351    fn send_raw(&self, mut events: &[Event]) -> Result<(), fidl::Error> {
3352        self.control_handle.inner.send::<WatcherWatchResponse>(
3353            (events,),
3354            self.tx_id,
3355            0x5f62165a0638ca75,
3356            fidl::encoding::DynamicFlags::empty(),
3357        )
3358    }
3359}
3360
3361mod internal {
3362    use super::*;
3363
3364    impl fidl::encoding::ResourceTypeMarker for ControlOpenControllerRequest {
3365        type Borrowed<'a> = &'a mut Self;
3366        fn take_or_borrow<'a>(
3367            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3368        ) -> Self::Borrowed<'a> {
3369            value
3370        }
3371    }
3372
3373    unsafe impl fidl::encoding::TypeMarker for ControlOpenControllerRequest {
3374        type Owned = Self;
3375
3376        #[inline(always)]
3377        fn inline_align(_context: fidl::encoding::Context) -> usize {
3378            8
3379        }
3380
3381        #[inline(always)]
3382        fn inline_size(_context: fidl::encoding::Context) -> usize {
3383            24
3384        }
3385    }
3386
3387    unsafe impl
3388        fidl::encoding::Encode<
3389            ControlOpenControllerRequest,
3390            fidl::encoding::DefaultFuchsiaResourceDialect,
3391        > for &mut ControlOpenControllerRequest
3392    {
3393        #[inline]
3394        unsafe fn encode(
3395            self,
3396            encoder: &mut fidl::encoding::Encoder<
3397                '_,
3398                fidl::encoding::DefaultFuchsiaResourceDialect,
3399            >,
3400            offset: usize,
3401            _depth: fidl::encoding::Depth,
3402        ) -> fidl::Result<()> {
3403            encoder.debug_check_bounds::<ControlOpenControllerRequest>(offset);
3404            // Delegate to tuple encoding.
3405            fidl::encoding::Encode::<ControlOpenControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3406                (
3407                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
3408                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
3409                ),
3410                encoder, offset, _depth
3411            )
3412        }
3413    }
3414    unsafe impl<
3415        T0: fidl::encoding::Encode<
3416                fidl::encoding::BoundedString<255>,
3417                fidl::encoding::DefaultFuchsiaResourceDialect,
3418            >,
3419        T1: fidl::encoding::Encode<
3420                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3421                fidl::encoding::DefaultFuchsiaResourceDialect,
3422            >,
3423    >
3424        fidl::encoding::Encode<
3425            ControlOpenControllerRequest,
3426            fidl::encoding::DefaultFuchsiaResourceDialect,
3427        > for (T0, T1)
3428    {
3429        #[inline]
3430        unsafe fn encode(
3431            self,
3432            encoder: &mut fidl::encoding::Encoder<
3433                '_,
3434                fidl::encoding::DefaultFuchsiaResourceDialect,
3435            >,
3436            offset: usize,
3437            depth: fidl::encoding::Depth,
3438        ) -> fidl::Result<()> {
3439            encoder.debug_check_bounds::<ControlOpenControllerRequest>(offset);
3440            // Zero out padding regions. There's no need to apply masks
3441            // because the unmasked parts will be overwritten by fields.
3442            unsafe {
3443                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3444                (ptr as *mut u64).write_unaligned(0);
3445            }
3446            // Write the fields.
3447            self.0.encode(encoder, offset + 0, depth)?;
3448            self.1.encode(encoder, offset + 16, depth)?;
3449            Ok(())
3450        }
3451    }
3452
3453    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3454        for ControlOpenControllerRequest
3455    {
3456        #[inline(always)]
3457        fn new_empty() -> Self {
3458            Self {
3459                id: fidl::new_empty!(
3460                    fidl::encoding::BoundedString<255>,
3461                    fidl::encoding::DefaultFuchsiaResourceDialect
3462                ),
3463                request: fidl::new_empty!(
3464                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3465                    fidl::encoding::DefaultFuchsiaResourceDialect
3466                ),
3467            }
3468        }
3469
3470        #[inline]
3471        unsafe fn decode(
3472            &mut self,
3473            decoder: &mut fidl::encoding::Decoder<
3474                '_,
3475                fidl::encoding::DefaultFuchsiaResourceDialect,
3476            >,
3477            offset: usize,
3478            _depth: fidl::encoding::Depth,
3479        ) -> fidl::Result<()> {
3480            decoder.debug_check_bounds::<Self>(offset);
3481            // Verify that padding bytes are zero.
3482            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3483            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3484            let mask = 0xffffffff00000000u64;
3485            let maskedval = padval & mask;
3486            if maskedval != 0 {
3487                return Err(fidl::Error::NonZeroPadding {
3488                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3489                });
3490            }
3491            fidl::decode!(
3492                fidl::encoding::BoundedString<255>,
3493                fidl::encoding::DefaultFuchsiaResourceDialect,
3494                &mut self.id,
3495                decoder,
3496                offset + 0,
3497                _depth
3498            )?;
3499            fidl::decode!(
3500                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3501                fidl::encoding::DefaultFuchsiaResourceDialect,
3502                &mut self.request,
3503                decoder,
3504                offset + 16,
3505                _depth
3506            )?;
3507            Ok(())
3508        }
3509    }
3510
3511    impl fidl::encoding::ResourceTypeMarker for ControlReopenDetachedControllerRequest {
3512        type Borrowed<'a> = &'a mut Self;
3513        fn take_or_borrow<'a>(
3514            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3515        ) -> Self::Borrowed<'a> {
3516            value
3517        }
3518    }
3519
3520    unsafe impl fidl::encoding::TypeMarker for ControlReopenDetachedControllerRequest {
3521        type Owned = Self;
3522
3523        #[inline(always)]
3524        fn inline_align(_context: fidl::encoding::Context) -> usize {
3525            4
3526        }
3527
3528        #[inline(always)]
3529        fn inline_size(_context: fidl::encoding::Context) -> usize {
3530            20
3531        }
3532    }
3533
3534    unsafe impl
3535        fidl::encoding::Encode<
3536            ControlReopenDetachedControllerRequest,
3537            fidl::encoding::DefaultFuchsiaResourceDialect,
3538        > for &mut ControlReopenDetachedControllerRequest
3539    {
3540        #[inline]
3541        unsafe fn encode(
3542            self,
3543            encoder: &mut fidl::encoding::Encoder<
3544                '_,
3545                fidl::encoding::DefaultFuchsiaResourceDialect,
3546            >,
3547            offset: usize,
3548            _depth: fidl::encoding::Depth,
3549        ) -> fidl::Result<()> {
3550            encoder.debug_check_bounds::<ControlReopenDetachedControllerRequest>(offset);
3551            // Delegate to tuple encoding.
3552            fidl::encoding::Encode::<ControlReopenDetachedControllerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3553                (
3554                    <ControllerKey as fidl::encoding::ValueTypeMarker>::borrow(&self.key),
3555                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
3556                ),
3557                encoder, offset, _depth
3558            )
3559        }
3560    }
3561    unsafe impl<
3562        T0: fidl::encoding::Encode<ControllerKey, fidl::encoding::DefaultFuchsiaResourceDialect>,
3563        T1: fidl::encoding::Encode<
3564                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3565                fidl::encoding::DefaultFuchsiaResourceDialect,
3566            >,
3567    >
3568        fidl::encoding::Encode<
3569            ControlReopenDetachedControllerRequest,
3570            fidl::encoding::DefaultFuchsiaResourceDialect,
3571        > for (T0, T1)
3572    {
3573        #[inline]
3574        unsafe fn encode(
3575            self,
3576            encoder: &mut fidl::encoding::Encoder<
3577                '_,
3578                fidl::encoding::DefaultFuchsiaResourceDialect,
3579            >,
3580            offset: usize,
3581            depth: fidl::encoding::Depth,
3582        ) -> fidl::Result<()> {
3583            encoder.debug_check_bounds::<ControlReopenDetachedControllerRequest>(offset);
3584            // Zero out padding regions. There's no need to apply masks
3585            // because the unmasked parts will be overwritten by fields.
3586            // Write the fields.
3587            self.0.encode(encoder, offset + 0, depth)?;
3588            self.1.encode(encoder, offset + 16, depth)?;
3589            Ok(())
3590        }
3591    }
3592
3593    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3594        for ControlReopenDetachedControllerRequest
3595    {
3596        #[inline(always)]
3597        fn new_empty() -> Self {
3598            Self {
3599                key: fidl::new_empty!(ControllerKey, fidl::encoding::DefaultFuchsiaResourceDialect),
3600                request: fidl::new_empty!(
3601                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3602                    fidl::encoding::DefaultFuchsiaResourceDialect
3603                ),
3604            }
3605        }
3606
3607        #[inline]
3608        unsafe fn decode(
3609            &mut self,
3610            decoder: &mut fidl::encoding::Decoder<
3611                '_,
3612                fidl::encoding::DefaultFuchsiaResourceDialect,
3613            >,
3614            offset: usize,
3615            _depth: fidl::encoding::Depth,
3616        ) -> fidl::Result<()> {
3617            decoder.debug_check_bounds::<Self>(offset);
3618            // Verify that padding bytes are zero.
3619            fidl::decode!(
3620                ControllerKey,
3621                fidl::encoding::DefaultFuchsiaResourceDialect,
3622                &mut self.key,
3623                decoder,
3624                offset + 0,
3625                _depth
3626            )?;
3627            fidl::decode!(
3628                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NamespaceControllerMarker>>,
3629                fidl::encoding::DefaultFuchsiaResourceDialect,
3630                &mut self.request,
3631                decoder,
3632                offset + 16,
3633                _depth
3634            )?;
3635            Ok(())
3636        }
3637    }
3638
3639    impl fidl::encoding::ResourceTypeMarker for NamespaceControllerPushChangesRequest {
3640        type Borrowed<'a> = &'a mut Self;
3641        fn take_or_borrow<'a>(
3642            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3643        ) -> Self::Borrowed<'a> {
3644            value
3645        }
3646    }
3647
3648    unsafe impl fidl::encoding::TypeMarker for NamespaceControllerPushChangesRequest {
3649        type Owned = Self;
3650
3651        #[inline(always)]
3652        fn inline_align(_context: fidl::encoding::Context) -> usize {
3653            8
3654        }
3655
3656        #[inline(always)]
3657        fn inline_size(_context: fidl::encoding::Context) -> usize {
3658            16
3659        }
3660    }
3661
3662    unsafe impl
3663        fidl::encoding::Encode<
3664            NamespaceControllerPushChangesRequest,
3665            fidl::encoding::DefaultFuchsiaResourceDialect,
3666        > for &mut NamespaceControllerPushChangesRequest
3667    {
3668        #[inline]
3669        unsafe fn encode(
3670            self,
3671            encoder: &mut fidl::encoding::Encoder<
3672                '_,
3673                fidl::encoding::DefaultFuchsiaResourceDialect,
3674            >,
3675            offset: usize,
3676            _depth: fidl::encoding::Depth,
3677        ) -> fidl::Result<()> {
3678            encoder.debug_check_bounds::<NamespaceControllerPushChangesRequest>(offset);
3679            // Delegate to tuple encoding.
3680            fidl::encoding::Encode::<
3681                NamespaceControllerPushChangesRequest,
3682                fidl::encoding::DefaultFuchsiaResourceDialect,
3683            >::encode(
3684                (<fidl::encoding::Vector<Change, 42> as fidl::encoding::ValueTypeMarker>::borrow(
3685                    &self.changes,
3686                ),),
3687                encoder,
3688                offset,
3689                _depth,
3690            )
3691        }
3692    }
3693    unsafe impl<
3694        T0: fidl::encoding::Encode<
3695                fidl::encoding::Vector<Change, 42>,
3696                fidl::encoding::DefaultFuchsiaResourceDialect,
3697            >,
3698    >
3699        fidl::encoding::Encode<
3700            NamespaceControllerPushChangesRequest,
3701            fidl::encoding::DefaultFuchsiaResourceDialect,
3702        > for (T0,)
3703    {
3704        #[inline]
3705        unsafe fn encode(
3706            self,
3707            encoder: &mut fidl::encoding::Encoder<
3708                '_,
3709                fidl::encoding::DefaultFuchsiaResourceDialect,
3710            >,
3711            offset: usize,
3712            depth: fidl::encoding::Depth,
3713        ) -> fidl::Result<()> {
3714            encoder.debug_check_bounds::<NamespaceControllerPushChangesRequest>(offset);
3715            // Zero out padding regions. There's no need to apply masks
3716            // because the unmasked parts will be overwritten by fields.
3717            // Write the fields.
3718            self.0.encode(encoder, offset + 0, depth)?;
3719            Ok(())
3720        }
3721    }
3722
3723    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3724        for NamespaceControllerPushChangesRequest
3725    {
3726        #[inline(always)]
3727        fn new_empty() -> Self {
3728            Self {
3729                changes: fidl::new_empty!(fidl::encoding::Vector<Change, 42>, fidl::encoding::DefaultFuchsiaResourceDialect),
3730            }
3731        }
3732
3733        #[inline]
3734        unsafe fn decode(
3735            &mut self,
3736            decoder: &mut fidl::encoding::Decoder<
3737                '_,
3738                fidl::encoding::DefaultFuchsiaResourceDialect,
3739            >,
3740            offset: usize,
3741            _depth: fidl::encoding::Depth,
3742        ) -> fidl::Result<()> {
3743            decoder.debug_check_bounds::<Self>(offset);
3744            // Verify that padding bytes are zero.
3745            fidl::decode!(fidl::encoding::Vector<Change, 42>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.changes, decoder, offset + 0, _depth)?;
3746            Ok(())
3747        }
3748    }
3749
3750    impl fidl::encoding::ResourceTypeMarker for NamespaceControllerRegisterEbpfProgramRequest {
3751        type Borrowed<'a> = &'a mut Self;
3752        fn take_or_borrow<'a>(
3753            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3754        ) -> Self::Borrowed<'a> {
3755            value
3756        }
3757    }
3758
3759    unsafe impl fidl::encoding::TypeMarker for NamespaceControllerRegisterEbpfProgramRequest {
3760        type Owned = Self;
3761
3762        #[inline(always)]
3763        fn inline_align(_context: fidl::encoding::Context) -> usize {
3764            8
3765        }
3766
3767        #[inline(always)]
3768        fn inline_size(_context: fidl::encoding::Context) -> usize {
3769            24
3770        }
3771    }
3772
3773    unsafe impl
3774        fidl::encoding::Encode<
3775            NamespaceControllerRegisterEbpfProgramRequest,
3776            fidl::encoding::DefaultFuchsiaResourceDialect,
3777        > for &mut NamespaceControllerRegisterEbpfProgramRequest
3778    {
3779        #[inline]
3780        unsafe fn encode(
3781            self,
3782            encoder: &mut fidl::encoding::Encoder<
3783                '_,
3784                fidl::encoding::DefaultFuchsiaResourceDialect,
3785            >,
3786            offset: usize,
3787            _depth: fidl::encoding::Depth,
3788        ) -> fidl::Result<()> {
3789            encoder.debug_check_bounds::<NamespaceControllerRegisterEbpfProgramRequest>(offset);
3790            // Delegate to tuple encoding.
3791            fidl::encoding::Encode::<NamespaceControllerRegisterEbpfProgramRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3792                (
3793                    <fidl_fuchsia_ebpf::ProgramHandle as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
3794                    <fidl_fuchsia_ebpf::VerifiedProgram as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.program),
3795                ),
3796                encoder, offset, _depth
3797            )
3798        }
3799    }
3800    unsafe impl<
3801        T0: fidl::encoding::Encode<
3802                fidl_fuchsia_ebpf::ProgramHandle,
3803                fidl::encoding::DefaultFuchsiaResourceDialect,
3804            >,
3805        T1: fidl::encoding::Encode<
3806                fidl_fuchsia_ebpf::VerifiedProgram,
3807                fidl::encoding::DefaultFuchsiaResourceDialect,
3808            >,
3809    >
3810        fidl::encoding::Encode<
3811            NamespaceControllerRegisterEbpfProgramRequest,
3812            fidl::encoding::DefaultFuchsiaResourceDialect,
3813        > for (T0, T1)
3814    {
3815        #[inline]
3816        unsafe fn encode(
3817            self,
3818            encoder: &mut fidl::encoding::Encoder<
3819                '_,
3820                fidl::encoding::DefaultFuchsiaResourceDialect,
3821            >,
3822            offset: usize,
3823            depth: fidl::encoding::Depth,
3824        ) -> fidl::Result<()> {
3825            encoder.debug_check_bounds::<NamespaceControllerRegisterEbpfProgramRequest>(offset);
3826            // Zero out padding regions. There's no need to apply masks
3827            // because the unmasked parts will be overwritten by fields.
3828            unsafe {
3829                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3830                (ptr as *mut u64).write_unaligned(0);
3831            }
3832            // Write the fields.
3833            self.0.encode(encoder, offset + 0, depth)?;
3834            self.1.encode(encoder, offset + 8, depth)?;
3835            Ok(())
3836        }
3837    }
3838
3839    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3840        for NamespaceControllerRegisterEbpfProgramRequest
3841    {
3842        #[inline(always)]
3843        fn new_empty() -> Self {
3844            Self {
3845                handle: fidl::new_empty!(
3846                    fidl_fuchsia_ebpf::ProgramHandle,
3847                    fidl::encoding::DefaultFuchsiaResourceDialect
3848                ),
3849                program: fidl::new_empty!(
3850                    fidl_fuchsia_ebpf::VerifiedProgram,
3851                    fidl::encoding::DefaultFuchsiaResourceDialect
3852                ),
3853            }
3854        }
3855
3856        #[inline]
3857        unsafe fn decode(
3858            &mut self,
3859            decoder: &mut fidl::encoding::Decoder<
3860                '_,
3861                fidl::encoding::DefaultFuchsiaResourceDialect,
3862            >,
3863            offset: usize,
3864            _depth: fidl::encoding::Depth,
3865        ) -> fidl::Result<()> {
3866            decoder.debug_check_bounds::<Self>(offset);
3867            // Verify that padding bytes are zero.
3868            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3869            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3870            let mask = 0xffffffff00000000u64;
3871            let maskedval = padval & mask;
3872            if maskedval != 0 {
3873                return Err(fidl::Error::NonZeroPadding {
3874                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3875                });
3876            }
3877            fidl::decode!(
3878                fidl_fuchsia_ebpf::ProgramHandle,
3879                fidl::encoding::DefaultFuchsiaResourceDialect,
3880                &mut self.handle,
3881                decoder,
3882                offset + 0,
3883                _depth
3884            )?;
3885            fidl::decode!(
3886                fidl_fuchsia_ebpf::VerifiedProgram,
3887                fidl::encoding::DefaultFuchsiaResourceDialect,
3888                &mut self.program,
3889                decoder,
3890                offset + 8,
3891                _depth
3892            )?;
3893            Ok(())
3894        }
3895    }
3896
3897    impl fidl::encoding::ResourceTypeMarker for StateGetWatcherRequest {
3898        type Borrowed<'a> = &'a mut Self;
3899        fn take_or_borrow<'a>(
3900            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3901        ) -> Self::Borrowed<'a> {
3902            value
3903        }
3904    }
3905
3906    unsafe impl fidl::encoding::TypeMarker for StateGetWatcherRequest {
3907        type Owned = Self;
3908
3909        #[inline(always)]
3910        fn inline_align(_context: fidl::encoding::Context) -> usize {
3911            8
3912        }
3913
3914        #[inline(always)]
3915        fn inline_size(_context: fidl::encoding::Context) -> usize {
3916            24
3917        }
3918    }
3919
3920    unsafe impl
3921        fidl::encoding::Encode<
3922            StateGetWatcherRequest,
3923            fidl::encoding::DefaultFuchsiaResourceDialect,
3924        > for &mut StateGetWatcherRequest
3925    {
3926        #[inline]
3927        unsafe fn encode(
3928            self,
3929            encoder: &mut fidl::encoding::Encoder<
3930                '_,
3931                fidl::encoding::DefaultFuchsiaResourceDialect,
3932            >,
3933            offset: usize,
3934            _depth: fidl::encoding::Depth,
3935        ) -> fidl::Result<()> {
3936            encoder.debug_check_bounds::<StateGetWatcherRequest>(offset);
3937            // Delegate to tuple encoding.
3938            fidl::encoding::Encode::<StateGetWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3939                (
3940                    <WatcherOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
3941                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
3942                ),
3943                encoder, offset, _depth
3944            )
3945        }
3946    }
3947    unsafe impl<
3948        T0: fidl::encoding::Encode<WatcherOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
3949        T1: fidl::encoding::Encode<
3950                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
3951                fidl::encoding::DefaultFuchsiaResourceDialect,
3952            >,
3953    >
3954        fidl::encoding::Encode<
3955            StateGetWatcherRequest,
3956            fidl::encoding::DefaultFuchsiaResourceDialect,
3957        > for (T0, T1)
3958    {
3959        #[inline]
3960        unsafe fn encode(
3961            self,
3962            encoder: &mut fidl::encoding::Encoder<
3963                '_,
3964                fidl::encoding::DefaultFuchsiaResourceDialect,
3965            >,
3966            offset: usize,
3967            depth: fidl::encoding::Depth,
3968        ) -> fidl::Result<()> {
3969            encoder.debug_check_bounds::<StateGetWatcherRequest>(offset);
3970            // Zero out padding regions. There's no need to apply masks
3971            // because the unmasked parts will be overwritten by fields.
3972            unsafe {
3973                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3974                (ptr as *mut u64).write_unaligned(0);
3975            }
3976            // Write the fields.
3977            self.0.encode(encoder, offset + 0, depth)?;
3978            self.1.encode(encoder, offset + 16, depth)?;
3979            Ok(())
3980        }
3981    }
3982
3983    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3984        for StateGetWatcherRequest
3985    {
3986        #[inline(always)]
3987        fn new_empty() -> Self {
3988            Self {
3989                options: fidl::new_empty!(
3990                    WatcherOptions,
3991                    fidl::encoding::DefaultFuchsiaResourceDialect
3992                ),
3993                request: fidl::new_empty!(
3994                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
3995                    fidl::encoding::DefaultFuchsiaResourceDialect
3996                ),
3997            }
3998        }
3999
4000        #[inline]
4001        unsafe fn decode(
4002            &mut self,
4003            decoder: &mut fidl::encoding::Decoder<
4004                '_,
4005                fidl::encoding::DefaultFuchsiaResourceDialect,
4006            >,
4007            offset: usize,
4008            _depth: fidl::encoding::Depth,
4009        ) -> fidl::Result<()> {
4010            decoder.debug_check_bounds::<Self>(offset);
4011            // Verify that padding bytes are zero.
4012            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
4013            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4014            let mask = 0xffffffff00000000u64;
4015            let maskedval = padval & mask;
4016            if maskedval != 0 {
4017                return Err(fidl::Error::NonZeroPadding {
4018                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
4019                });
4020            }
4021            fidl::decode!(
4022                WatcherOptions,
4023                fidl::encoding::DefaultFuchsiaResourceDialect,
4024                &mut self.options,
4025                decoder,
4026                offset + 0,
4027                _depth
4028            )?;
4029            fidl::decode!(
4030                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
4031                fidl::encoding::DefaultFuchsiaResourceDialect,
4032                &mut self.request,
4033                decoder,
4034                offset + 16,
4035                _depth
4036            )?;
4037            Ok(())
4038        }
4039    }
4040
4041    impl AttachEbpfProgramOptions {
4042        #[inline(always)]
4043        fn max_ordinal_present(&self) -> u64 {
4044            if let Some(_) = self.program {
4045                return 2;
4046            }
4047            if let Some(_) = self.hook {
4048                return 1;
4049            }
4050            0
4051        }
4052    }
4053
4054    impl fidl::encoding::ResourceTypeMarker for AttachEbpfProgramOptions {
4055        type Borrowed<'a> = &'a mut Self;
4056        fn take_or_borrow<'a>(
4057            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4058        ) -> Self::Borrowed<'a> {
4059            value
4060        }
4061    }
4062
4063    unsafe impl fidl::encoding::TypeMarker for AttachEbpfProgramOptions {
4064        type Owned = Self;
4065
4066        #[inline(always)]
4067        fn inline_align(_context: fidl::encoding::Context) -> usize {
4068            8
4069        }
4070
4071        #[inline(always)]
4072        fn inline_size(_context: fidl::encoding::Context) -> usize {
4073            16
4074        }
4075    }
4076
4077    unsafe impl
4078        fidl::encoding::Encode<
4079            AttachEbpfProgramOptions,
4080            fidl::encoding::DefaultFuchsiaResourceDialect,
4081        > for &mut AttachEbpfProgramOptions
4082    {
4083        unsafe fn encode(
4084            self,
4085            encoder: &mut fidl::encoding::Encoder<
4086                '_,
4087                fidl::encoding::DefaultFuchsiaResourceDialect,
4088            >,
4089            offset: usize,
4090            mut depth: fidl::encoding::Depth,
4091        ) -> fidl::Result<()> {
4092            encoder.debug_check_bounds::<AttachEbpfProgramOptions>(offset);
4093            // Vector header
4094            let max_ordinal: u64 = self.max_ordinal_present();
4095            encoder.write_num(max_ordinal, offset);
4096            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4097            // Calling encoder.out_of_line_offset(0) is not allowed.
4098            if max_ordinal == 0 {
4099                return Ok(());
4100            }
4101            depth.increment()?;
4102            let envelope_size = 8;
4103            let bytes_len = max_ordinal as usize * envelope_size;
4104            #[allow(unused_variables)]
4105            let offset = encoder.out_of_line_offset(bytes_len);
4106            let mut _prev_end_offset: usize = 0;
4107            if 1 > max_ordinal {
4108                return Ok(());
4109            }
4110
4111            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4112            // are envelope_size bytes.
4113            let cur_offset: usize = (1 - 1) * envelope_size;
4114
4115            // Zero reserved fields.
4116            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4117
4118            // Safety:
4119            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4120            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4121            //   envelope_size bytes, there is always sufficient room.
4122            fidl::encoding::encode_in_envelope_optional::<
4123                SocketHook,
4124                fidl::encoding::DefaultFuchsiaResourceDialect,
4125            >(
4126                self.hook.as_ref().map(<SocketHook as fidl::encoding::ValueTypeMarker>::borrow),
4127                encoder,
4128                offset + cur_offset,
4129                depth,
4130            )?;
4131
4132            _prev_end_offset = cur_offset + envelope_size;
4133            if 2 > max_ordinal {
4134                return Ok(());
4135            }
4136
4137            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4138            // are envelope_size bytes.
4139            let cur_offset: usize = (2 - 1) * envelope_size;
4140
4141            // Zero reserved fields.
4142            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4143
4144            // Safety:
4145            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4146            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4147            //   envelope_size bytes, there is always sufficient room.
4148            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ebpf::VerifiedProgram, fidl::encoding::DefaultFuchsiaResourceDialect>(
4149            self.program.as_mut().map(<fidl_fuchsia_ebpf::VerifiedProgram as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4150            encoder, offset + cur_offset, depth
4151        )?;
4152
4153            _prev_end_offset = cur_offset + envelope_size;
4154
4155            Ok(())
4156        }
4157    }
4158
4159    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4160        for AttachEbpfProgramOptions
4161    {
4162        #[inline(always)]
4163        fn new_empty() -> Self {
4164            Self::default()
4165        }
4166
4167        unsafe fn decode(
4168            &mut self,
4169            decoder: &mut fidl::encoding::Decoder<
4170                '_,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172            >,
4173            offset: usize,
4174            mut depth: fidl::encoding::Depth,
4175        ) -> fidl::Result<()> {
4176            decoder.debug_check_bounds::<Self>(offset);
4177            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4178                None => return Err(fidl::Error::NotNullable),
4179                Some(len) => len,
4180            };
4181            // Calling decoder.out_of_line_offset(0) is not allowed.
4182            if len == 0 {
4183                return Ok(());
4184            };
4185            depth.increment()?;
4186            let envelope_size = 8;
4187            let bytes_len = len * envelope_size;
4188            let offset = decoder.out_of_line_offset(bytes_len)?;
4189            // Decode the envelope for each type.
4190            let mut _next_ordinal_to_read = 0;
4191            let mut next_offset = offset;
4192            let end_offset = offset + bytes_len;
4193            _next_ordinal_to_read += 1;
4194            if next_offset >= end_offset {
4195                return Ok(());
4196            }
4197
4198            // Decode unknown envelopes for gaps in ordinals.
4199            while _next_ordinal_to_read < 1 {
4200                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4201                _next_ordinal_to_read += 1;
4202                next_offset += envelope_size;
4203            }
4204
4205            let next_out_of_line = decoder.next_out_of_line();
4206            let handles_before = decoder.remaining_handles();
4207            if let Some((inlined, num_bytes, num_handles)) =
4208                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4209            {
4210                let member_inline_size =
4211                    <SocketHook as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4212                if inlined != (member_inline_size <= 4) {
4213                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4214                }
4215                let inner_offset;
4216                let mut inner_depth = depth.clone();
4217                if inlined {
4218                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4219                    inner_offset = next_offset;
4220                } else {
4221                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4222                    inner_depth.increment()?;
4223                }
4224                let val_ref = self.hook.get_or_insert_with(|| {
4225                    fidl::new_empty!(SocketHook, fidl::encoding::DefaultFuchsiaResourceDialect)
4226                });
4227                fidl::decode!(
4228                    SocketHook,
4229                    fidl::encoding::DefaultFuchsiaResourceDialect,
4230                    val_ref,
4231                    decoder,
4232                    inner_offset,
4233                    inner_depth
4234                )?;
4235                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4236                {
4237                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4238                }
4239                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4240                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4241                }
4242            }
4243
4244            next_offset += envelope_size;
4245            _next_ordinal_to_read += 1;
4246            if next_offset >= end_offset {
4247                return Ok(());
4248            }
4249
4250            // Decode unknown envelopes for gaps in ordinals.
4251            while _next_ordinal_to_read < 2 {
4252                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4253                _next_ordinal_to_read += 1;
4254                next_offset += envelope_size;
4255            }
4256
4257            let next_out_of_line = decoder.next_out_of_line();
4258            let handles_before = decoder.remaining_handles();
4259            if let Some((inlined, num_bytes, num_handles)) =
4260                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4261            {
4262                let member_inline_size =
4263                    <fidl_fuchsia_ebpf::VerifiedProgram as fidl::encoding::TypeMarker>::inline_size(
4264                        decoder.context,
4265                    );
4266                if inlined != (member_inline_size <= 4) {
4267                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4268                }
4269                let inner_offset;
4270                let mut inner_depth = depth.clone();
4271                if inlined {
4272                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4273                    inner_offset = next_offset;
4274                } else {
4275                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4276                    inner_depth.increment()?;
4277                }
4278                let val_ref = self.program.get_or_insert_with(|| {
4279                    fidl::new_empty!(
4280                        fidl_fuchsia_ebpf::VerifiedProgram,
4281                        fidl::encoding::DefaultFuchsiaResourceDialect
4282                    )
4283                });
4284                fidl::decode!(
4285                    fidl_fuchsia_ebpf::VerifiedProgram,
4286                    fidl::encoding::DefaultFuchsiaResourceDialect,
4287                    val_ref,
4288                    decoder,
4289                    inner_offset,
4290                    inner_depth
4291                )?;
4292                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4293                {
4294                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4295                }
4296                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4297                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4298                }
4299            }
4300
4301            next_offset += envelope_size;
4302
4303            // Decode the remaining unknown envelopes.
4304            while next_offset < end_offset {
4305                _next_ordinal_to_read += 1;
4306                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4307                next_offset += envelope_size;
4308            }
4309
4310            Ok(())
4311        }
4312    }
4313
4314    impl CommitOptions {
4315        #[inline(always)]
4316        fn max_ordinal_present(&self) -> u64 {
4317            if let Some(_) = self.idempotent {
4318                return 1;
4319            }
4320            0
4321        }
4322    }
4323
4324    impl fidl::encoding::ResourceTypeMarker for CommitOptions {
4325        type Borrowed<'a> = &'a mut Self;
4326        fn take_or_borrow<'a>(
4327            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4328        ) -> Self::Borrowed<'a> {
4329            value
4330        }
4331    }
4332
4333    unsafe impl fidl::encoding::TypeMarker for CommitOptions {
4334        type Owned = Self;
4335
4336        #[inline(always)]
4337        fn inline_align(_context: fidl::encoding::Context) -> usize {
4338            8
4339        }
4340
4341        #[inline(always)]
4342        fn inline_size(_context: fidl::encoding::Context) -> usize {
4343            16
4344        }
4345    }
4346
4347    unsafe impl fidl::encoding::Encode<CommitOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
4348        for &mut CommitOptions
4349    {
4350        unsafe fn encode(
4351            self,
4352            encoder: &mut fidl::encoding::Encoder<
4353                '_,
4354                fidl::encoding::DefaultFuchsiaResourceDialect,
4355            >,
4356            offset: usize,
4357            mut depth: fidl::encoding::Depth,
4358        ) -> fidl::Result<()> {
4359            encoder.debug_check_bounds::<CommitOptions>(offset);
4360            // Vector header
4361            let max_ordinal: u64 = self.max_ordinal_present();
4362            encoder.write_num(max_ordinal, offset);
4363            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4364            // Calling encoder.out_of_line_offset(0) is not allowed.
4365            if max_ordinal == 0 {
4366                return Ok(());
4367            }
4368            depth.increment()?;
4369            let envelope_size = 8;
4370            let bytes_len = max_ordinal as usize * envelope_size;
4371            #[allow(unused_variables)]
4372            let offset = encoder.out_of_line_offset(bytes_len);
4373            let mut _prev_end_offset: usize = 0;
4374            if 1 > max_ordinal {
4375                return Ok(());
4376            }
4377
4378            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4379            // are envelope_size bytes.
4380            let cur_offset: usize = (1 - 1) * envelope_size;
4381
4382            // Zero reserved fields.
4383            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4384
4385            // Safety:
4386            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4387            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4388            //   envelope_size bytes, there is always sufficient room.
4389            fidl::encoding::encode_in_envelope_optional::<
4390                bool,
4391                fidl::encoding::DefaultFuchsiaResourceDialect,
4392            >(
4393                self.idempotent.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
4394                encoder,
4395                offset + cur_offset,
4396                depth,
4397            )?;
4398
4399            _prev_end_offset = cur_offset + envelope_size;
4400
4401            Ok(())
4402        }
4403    }
4404
4405    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for CommitOptions {
4406        #[inline(always)]
4407        fn new_empty() -> Self {
4408            Self::default()
4409        }
4410
4411        unsafe fn decode(
4412            &mut self,
4413            decoder: &mut fidl::encoding::Decoder<
4414                '_,
4415                fidl::encoding::DefaultFuchsiaResourceDialect,
4416            >,
4417            offset: usize,
4418            mut depth: fidl::encoding::Depth,
4419        ) -> fidl::Result<()> {
4420            decoder.debug_check_bounds::<Self>(offset);
4421            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4422                None => return Err(fidl::Error::NotNullable),
4423                Some(len) => len,
4424            };
4425            // Calling decoder.out_of_line_offset(0) is not allowed.
4426            if len == 0 {
4427                return Ok(());
4428            };
4429            depth.increment()?;
4430            let envelope_size = 8;
4431            let bytes_len = len * envelope_size;
4432            let offset = decoder.out_of_line_offset(bytes_len)?;
4433            // Decode the envelope for each type.
4434            let mut _next_ordinal_to_read = 0;
4435            let mut next_offset = offset;
4436            let end_offset = offset + bytes_len;
4437            _next_ordinal_to_read += 1;
4438            if next_offset >= end_offset {
4439                return Ok(());
4440            }
4441
4442            // Decode unknown envelopes for gaps in ordinals.
4443            while _next_ordinal_to_read < 1 {
4444                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4445                _next_ordinal_to_read += 1;
4446                next_offset += envelope_size;
4447            }
4448
4449            let next_out_of_line = decoder.next_out_of_line();
4450            let handles_before = decoder.remaining_handles();
4451            if let Some((inlined, num_bytes, num_handles)) =
4452                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4453            {
4454                let member_inline_size =
4455                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4456                if inlined != (member_inline_size <= 4) {
4457                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4458                }
4459                let inner_offset;
4460                let mut inner_depth = depth.clone();
4461                if inlined {
4462                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4463                    inner_offset = next_offset;
4464                } else {
4465                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4466                    inner_depth.increment()?;
4467                }
4468                let val_ref = self.idempotent.get_or_insert_with(|| {
4469                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
4470                });
4471                fidl::decode!(
4472                    bool,
4473                    fidl::encoding::DefaultFuchsiaResourceDialect,
4474                    val_ref,
4475                    decoder,
4476                    inner_offset,
4477                    inner_depth
4478                )?;
4479                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4480                {
4481                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4482                }
4483                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4484                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4485                }
4486            }
4487
4488            next_offset += envelope_size;
4489
4490            // Decode the remaining unknown envelopes.
4491            while next_offset < end_offset {
4492                _next_ordinal_to_read += 1;
4493                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4494                next_offset += envelope_size;
4495            }
4496
4497            Ok(())
4498        }
4499    }
4500
4501    impl fidl::encoding::ResourceTypeMarker for ChangeValidationResult {
4502        type Borrowed<'a> = &'a mut Self;
4503        fn take_or_borrow<'a>(
4504            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4505        ) -> Self::Borrowed<'a> {
4506            value
4507        }
4508    }
4509
4510    unsafe impl fidl::encoding::TypeMarker for ChangeValidationResult {
4511        type Owned = Self;
4512
4513        #[inline(always)]
4514        fn inline_align(_context: fidl::encoding::Context) -> usize {
4515            8
4516        }
4517
4518        #[inline(always)]
4519        fn inline_size(_context: fidl::encoding::Context) -> usize {
4520            16
4521        }
4522    }
4523
4524    unsafe impl
4525        fidl::encoding::Encode<
4526            ChangeValidationResult,
4527            fidl::encoding::DefaultFuchsiaResourceDialect,
4528        > for &mut ChangeValidationResult
4529    {
4530        #[inline]
4531        unsafe fn encode(
4532            self,
4533            encoder: &mut fidl::encoding::Encoder<
4534                '_,
4535                fidl::encoding::DefaultFuchsiaResourceDialect,
4536            >,
4537            offset: usize,
4538            _depth: fidl::encoding::Depth,
4539        ) -> fidl::Result<()> {
4540            encoder.debug_check_bounds::<ChangeValidationResult>(offset);
4541            encoder.write_num::<u64>(self.ordinal(), offset);
4542            match self {
4543            ChangeValidationResult::Ok(ref val) => {
4544                fidl::encoding::encode_in_envelope::<Empty, fidl::encoding::DefaultFuchsiaResourceDialect>(
4545                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
4546                    encoder, offset + 8, _depth
4547                )
4548            }
4549            ChangeValidationResult::TooManyChanges(ref val) => {
4550                fidl::encoding::encode_in_envelope::<Empty, fidl::encoding::DefaultFuchsiaResourceDialect>(
4551                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
4552                    encoder, offset + 8, _depth
4553                )
4554            }
4555            ChangeValidationResult::ErrorOnChange(ref val) => {
4556                fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<ChangeValidationError, 42>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4557                    <fidl::encoding::Vector<ChangeValidationError, 42> as fidl::encoding::ValueTypeMarker>::borrow(val),
4558                    encoder, offset + 8, _depth
4559                )
4560            }
4561            ChangeValidationResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4562        }
4563        }
4564    }
4565
4566    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4567        for ChangeValidationResult
4568    {
4569        #[inline(always)]
4570        fn new_empty() -> Self {
4571            Self::__SourceBreaking { unknown_ordinal: 0 }
4572        }
4573
4574        #[inline]
4575        unsafe fn decode(
4576            &mut self,
4577            decoder: &mut fidl::encoding::Decoder<
4578                '_,
4579                fidl::encoding::DefaultFuchsiaResourceDialect,
4580            >,
4581            offset: usize,
4582            mut depth: fidl::encoding::Depth,
4583        ) -> fidl::Result<()> {
4584            decoder.debug_check_bounds::<Self>(offset);
4585            #[allow(unused_variables)]
4586            let next_out_of_line = decoder.next_out_of_line();
4587            let handles_before = decoder.remaining_handles();
4588            let (ordinal, inlined, num_bytes, num_handles) =
4589                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4590
4591            let member_inline_size = match ordinal {
4592            1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4593            2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4594            3 => <fidl::encoding::Vector<ChangeValidationError, 42> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4595            0 => return Err(fidl::Error::UnknownUnionTag),
4596            _ => num_bytes as usize,
4597        };
4598
4599            if inlined != (member_inline_size <= 4) {
4600                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4601            }
4602            let _inner_offset;
4603            if inlined {
4604                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4605                _inner_offset = offset + 8;
4606            } else {
4607                depth.increment()?;
4608                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4609            }
4610            match ordinal {
4611                1 => {
4612                    #[allow(irrefutable_let_patterns)]
4613                    if let ChangeValidationResult::Ok(_) = self {
4614                        // Do nothing, read the value into the object
4615                    } else {
4616                        // Initialize `self` to the right variant
4617                        *self = ChangeValidationResult::Ok(fidl::new_empty!(
4618                            Empty,
4619                            fidl::encoding::DefaultFuchsiaResourceDialect
4620                        ));
4621                    }
4622                    #[allow(irrefutable_let_patterns)]
4623                    if let ChangeValidationResult::Ok(ref mut val) = self {
4624                        fidl::decode!(
4625                            Empty,
4626                            fidl::encoding::DefaultFuchsiaResourceDialect,
4627                            val,
4628                            decoder,
4629                            _inner_offset,
4630                            depth
4631                        )?;
4632                    } else {
4633                        unreachable!()
4634                    }
4635                }
4636                2 => {
4637                    #[allow(irrefutable_let_patterns)]
4638                    if let ChangeValidationResult::TooManyChanges(_) = self {
4639                        // Do nothing, read the value into the object
4640                    } else {
4641                        // Initialize `self` to the right variant
4642                        *self = ChangeValidationResult::TooManyChanges(fidl::new_empty!(
4643                            Empty,
4644                            fidl::encoding::DefaultFuchsiaResourceDialect
4645                        ));
4646                    }
4647                    #[allow(irrefutable_let_patterns)]
4648                    if let ChangeValidationResult::TooManyChanges(ref mut val) = self {
4649                        fidl::decode!(
4650                            Empty,
4651                            fidl::encoding::DefaultFuchsiaResourceDialect,
4652                            val,
4653                            decoder,
4654                            _inner_offset,
4655                            depth
4656                        )?;
4657                    } else {
4658                        unreachable!()
4659                    }
4660                }
4661                3 => {
4662                    #[allow(irrefutable_let_patterns)]
4663                    if let ChangeValidationResult::ErrorOnChange(_) = self {
4664                        // Do nothing, read the value into the object
4665                    } else {
4666                        // Initialize `self` to the right variant
4667                        *self = ChangeValidationResult::ErrorOnChange(
4668                            fidl::new_empty!(fidl::encoding::Vector<ChangeValidationError, 42>, fidl::encoding::DefaultFuchsiaResourceDialect),
4669                        );
4670                    }
4671                    #[allow(irrefutable_let_patterns)]
4672                    if let ChangeValidationResult::ErrorOnChange(ref mut val) = self {
4673                        fidl::decode!(fidl::encoding::Vector<ChangeValidationError, 42>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
4674                    } else {
4675                        unreachable!()
4676                    }
4677                }
4678                #[allow(deprecated)]
4679                ordinal => {
4680                    for _ in 0..num_handles {
4681                        decoder.drop_next_handle()?;
4682                    }
4683                    *self = ChangeValidationResult::__SourceBreaking { unknown_ordinal: ordinal };
4684                }
4685            }
4686            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4687                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4688            }
4689            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4690                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4691            }
4692            Ok(())
4693        }
4694    }
4695
4696    impl fidl::encoding::ResourceTypeMarker for CommitResult {
4697        type Borrowed<'a> = &'a mut Self;
4698        fn take_or_borrow<'a>(
4699            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4700        ) -> Self::Borrowed<'a> {
4701            value
4702        }
4703    }
4704
4705    unsafe impl fidl::encoding::TypeMarker for CommitResult {
4706        type Owned = Self;
4707
4708        #[inline(always)]
4709        fn inline_align(_context: fidl::encoding::Context) -> usize {
4710            8
4711        }
4712
4713        #[inline(always)]
4714        fn inline_size(_context: fidl::encoding::Context) -> usize {
4715            16
4716        }
4717    }
4718
4719    unsafe impl fidl::encoding::Encode<CommitResult, fidl::encoding::DefaultFuchsiaResourceDialect>
4720        for &mut CommitResult
4721    {
4722        #[inline]
4723        unsafe fn encode(
4724            self,
4725            encoder: &mut fidl::encoding::Encoder<
4726                '_,
4727                fidl::encoding::DefaultFuchsiaResourceDialect,
4728            >,
4729            offset: usize,
4730            _depth: fidl::encoding::Depth,
4731        ) -> fidl::Result<()> {
4732            encoder.debug_check_bounds::<CommitResult>(offset);
4733            encoder.write_num::<u64>(self.ordinal(), offset);
4734            match self {
4735            CommitResult::Ok(ref val) => {
4736                fidl::encoding::encode_in_envelope::<Empty, fidl::encoding::DefaultFuchsiaResourceDialect>(
4737                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
4738                    encoder, offset + 8, _depth
4739                )
4740            }
4741            CommitResult::RuleWithInvalidMatcher(ref val) => {
4742                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4743                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4744                    encoder, offset + 8, _depth
4745                )
4746            }
4747            CommitResult::RuleWithInvalidAction(ref val) => {
4748                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4749                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4750                    encoder, offset + 8, _depth
4751                )
4752            }
4753            CommitResult::CyclicalRoutineGraph(ref val) => {
4754                fidl::encoding::encode_in_envelope::<RoutineId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4755                    <RoutineId as fidl::encoding::ValueTypeMarker>::borrow(val),
4756                    encoder, offset + 8, _depth
4757                )
4758            }
4759            CommitResult::ErrorOnChange(ref val) => {
4760                fidl::encoding::encode_in_envelope::<fidl::encoding::Vector<CommitError, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4761                    <fidl::encoding::Vector<CommitError, 1024> as fidl::encoding::ValueTypeMarker>::borrow(val),
4762                    encoder, offset + 8, _depth
4763                )
4764            }
4765            CommitResult::TransparentProxyWithInvalidMatcher(ref val) => {
4766                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4767                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4768                    encoder, offset + 8, _depth
4769                )
4770            }
4771            CommitResult::RedirectWithInvalidMatcher(ref val) => {
4772                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4773                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4774                    encoder, offset + 8, _depth
4775                )
4776            }
4777            CommitResult::MasqueradeWithInvalidMatcher(ref val) => {
4778                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4779                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4780                    encoder, offset + 8, _depth
4781                )
4782            }
4783            CommitResult::RejectWithInvalidMatcher(ref val) => {
4784                fidl::encoding::encode_in_envelope::<RuleId, fidl::encoding::DefaultFuchsiaResourceDialect>(
4785                    <RuleId as fidl::encoding::ValueTypeMarker>::borrow(val),
4786                    encoder, offset + 8, _depth
4787                )
4788            }
4789            CommitResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4790        }
4791        }
4792    }
4793
4794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for CommitResult {
4795        #[inline(always)]
4796        fn new_empty() -> Self {
4797            Self::__SourceBreaking { unknown_ordinal: 0 }
4798        }
4799
4800        #[inline]
4801        unsafe fn decode(
4802            &mut self,
4803            decoder: &mut fidl::encoding::Decoder<
4804                '_,
4805                fidl::encoding::DefaultFuchsiaResourceDialect,
4806            >,
4807            offset: usize,
4808            mut depth: fidl::encoding::Depth,
4809        ) -> fidl::Result<()> {
4810            decoder.debug_check_bounds::<Self>(offset);
4811            #[allow(unused_variables)]
4812            let next_out_of_line = decoder.next_out_of_line();
4813            let handles_before = decoder.remaining_handles();
4814            let (ordinal, inlined, num_bytes, num_handles) =
4815                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4816
4817            let member_inline_size = match ordinal {
4818            1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4819            2 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4820            3 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4821            4 => <RoutineId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4822            5 => <fidl::encoding::Vector<CommitError, 1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4823            6 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4824            7 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4825            8 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4826            9 => <RuleId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4827            0 => return Err(fidl::Error::UnknownUnionTag),
4828            _ => num_bytes as usize,
4829        };
4830
4831            if inlined != (member_inline_size <= 4) {
4832                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4833            }
4834            let _inner_offset;
4835            if inlined {
4836                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4837                _inner_offset = offset + 8;
4838            } else {
4839                depth.increment()?;
4840                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4841            }
4842            match ordinal {
4843                1 => {
4844                    #[allow(irrefutable_let_patterns)]
4845                    if let CommitResult::Ok(_) = self {
4846                        // Do nothing, read the value into the object
4847                    } else {
4848                        // Initialize `self` to the right variant
4849                        *self = CommitResult::Ok(fidl::new_empty!(
4850                            Empty,
4851                            fidl::encoding::DefaultFuchsiaResourceDialect
4852                        ));
4853                    }
4854                    #[allow(irrefutable_let_patterns)]
4855                    if let CommitResult::Ok(ref mut val) = self {
4856                        fidl::decode!(
4857                            Empty,
4858                            fidl::encoding::DefaultFuchsiaResourceDialect,
4859                            val,
4860                            decoder,
4861                            _inner_offset,
4862                            depth
4863                        )?;
4864                    } else {
4865                        unreachable!()
4866                    }
4867                }
4868                2 => {
4869                    #[allow(irrefutable_let_patterns)]
4870                    if let CommitResult::RuleWithInvalidMatcher(_) = self {
4871                        // Do nothing, read the value into the object
4872                    } else {
4873                        // Initialize `self` to the right variant
4874                        *self = CommitResult::RuleWithInvalidMatcher(fidl::new_empty!(
4875                            RuleId,
4876                            fidl::encoding::DefaultFuchsiaResourceDialect
4877                        ));
4878                    }
4879                    #[allow(irrefutable_let_patterns)]
4880                    if let CommitResult::RuleWithInvalidMatcher(ref mut val) = self {
4881                        fidl::decode!(
4882                            RuleId,
4883                            fidl::encoding::DefaultFuchsiaResourceDialect,
4884                            val,
4885                            decoder,
4886                            _inner_offset,
4887                            depth
4888                        )?;
4889                    } else {
4890                        unreachable!()
4891                    }
4892                }
4893                3 => {
4894                    #[allow(irrefutable_let_patterns)]
4895                    if let CommitResult::RuleWithInvalidAction(_) = self {
4896                        // Do nothing, read the value into the object
4897                    } else {
4898                        // Initialize `self` to the right variant
4899                        *self = CommitResult::RuleWithInvalidAction(fidl::new_empty!(
4900                            RuleId,
4901                            fidl::encoding::DefaultFuchsiaResourceDialect
4902                        ));
4903                    }
4904                    #[allow(irrefutable_let_patterns)]
4905                    if let CommitResult::RuleWithInvalidAction(ref mut val) = self {
4906                        fidl::decode!(
4907                            RuleId,
4908                            fidl::encoding::DefaultFuchsiaResourceDialect,
4909                            val,
4910                            decoder,
4911                            _inner_offset,
4912                            depth
4913                        )?;
4914                    } else {
4915                        unreachable!()
4916                    }
4917                }
4918                4 => {
4919                    #[allow(irrefutable_let_patterns)]
4920                    if let CommitResult::CyclicalRoutineGraph(_) = self {
4921                        // Do nothing, read the value into the object
4922                    } else {
4923                        // Initialize `self` to the right variant
4924                        *self = CommitResult::CyclicalRoutineGraph(fidl::new_empty!(
4925                            RoutineId,
4926                            fidl::encoding::DefaultFuchsiaResourceDialect
4927                        ));
4928                    }
4929                    #[allow(irrefutable_let_patterns)]
4930                    if let CommitResult::CyclicalRoutineGraph(ref mut val) = self {
4931                        fidl::decode!(
4932                            RoutineId,
4933                            fidl::encoding::DefaultFuchsiaResourceDialect,
4934                            val,
4935                            decoder,
4936                            _inner_offset,
4937                            depth
4938                        )?;
4939                    } else {
4940                        unreachable!()
4941                    }
4942                }
4943                5 => {
4944                    #[allow(irrefutable_let_patterns)]
4945                    if let CommitResult::ErrorOnChange(_) = self {
4946                        // Do nothing, read the value into the object
4947                    } else {
4948                        // Initialize `self` to the right variant
4949                        *self = CommitResult::ErrorOnChange(
4950                            fidl::new_empty!(fidl::encoding::Vector<CommitError, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect),
4951                        );
4952                    }
4953                    #[allow(irrefutable_let_patterns)]
4954                    if let CommitResult::ErrorOnChange(ref mut val) = self {
4955                        fidl::decode!(fidl::encoding::Vector<CommitError, 1024>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
4956                    } else {
4957                        unreachable!()
4958                    }
4959                }
4960                6 => {
4961                    #[allow(irrefutable_let_patterns)]
4962                    if let CommitResult::TransparentProxyWithInvalidMatcher(_) = self {
4963                        // Do nothing, read the value into the object
4964                    } else {
4965                        // Initialize `self` to the right variant
4966                        *self = CommitResult::TransparentProxyWithInvalidMatcher(fidl::new_empty!(
4967                            RuleId,
4968                            fidl::encoding::DefaultFuchsiaResourceDialect
4969                        ));
4970                    }
4971                    #[allow(irrefutable_let_patterns)]
4972                    if let CommitResult::TransparentProxyWithInvalidMatcher(ref mut val) = self {
4973                        fidl::decode!(
4974                            RuleId,
4975                            fidl::encoding::DefaultFuchsiaResourceDialect,
4976                            val,
4977                            decoder,
4978                            _inner_offset,
4979                            depth
4980                        )?;
4981                    } else {
4982                        unreachable!()
4983                    }
4984                }
4985                7 => {
4986                    #[allow(irrefutable_let_patterns)]
4987                    if let CommitResult::RedirectWithInvalidMatcher(_) = self {
4988                        // Do nothing, read the value into the object
4989                    } else {
4990                        // Initialize `self` to the right variant
4991                        *self = CommitResult::RedirectWithInvalidMatcher(fidl::new_empty!(
4992                            RuleId,
4993                            fidl::encoding::DefaultFuchsiaResourceDialect
4994                        ));
4995                    }
4996                    #[allow(irrefutable_let_patterns)]
4997                    if let CommitResult::RedirectWithInvalidMatcher(ref mut val) = self {
4998                        fidl::decode!(
4999                            RuleId,
5000                            fidl::encoding::DefaultFuchsiaResourceDialect,
5001                            val,
5002                            decoder,
5003                            _inner_offset,
5004                            depth
5005                        )?;
5006                    } else {
5007                        unreachable!()
5008                    }
5009                }
5010                8 => {
5011                    #[allow(irrefutable_let_patterns)]
5012                    if let CommitResult::MasqueradeWithInvalidMatcher(_) = self {
5013                        // Do nothing, read the value into the object
5014                    } else {
5015                        // Initialize `self` to the right variant
5016                        *self = CommitResult::MasqueradeWithInvalidMatcher(fidl::new_empty!(
5017                            RuleId,
5018                            fidl::encoding::DefaultFuchsiaResourceDialect
5019                        ));
5020                    }
5021                    #[allow(irrefutable_let_patterns)]
5022                    if let CommitResult::MasqueradeWithInvalidMatcher(ref mut val) = self {
5023                        fidl::decode!(
5024                            RuleId,
5025                            fidl::encoding::DefaultFuchsiaResourceDialect,
5026                            val,
5027                            decoder,
5028                            _inner_offset,
5029                            depth
5030                        )?;
5031                    } else {
5032                        unreachable!()
5033                    }
5034                }
5035                9 => {
5036                    #[allow(irrefutable_let_patterns)]
5037                    if let CommitResult::RejectWithInvalidMatcher(_) = self {
5038                        // Do nothing, read the value into the object
5039                    } else {
5040                        // Initialize `self` to the right variant
5041                        *self = CommitResult::RejectWithInvalidMatcher(fidl::new_empty!(
5042                            RuleId,
5043                            fidl::encoding::DefaultFuchsiaResourceDialect
5044                        ));
5045                    }
5046                    #[allow(irrefutable_let_patterns)]
5047                    if let CommitResult::RejectWithInvalidMatcher(ref mut val) = self {
5048                        fidl::decode!(
5049                            RuleId,
5050                            fidl::encoding::DefaultFuchsiaResourceDialect,
5051                            val,
5052                            decoder,
5053                            _inner_offset,
5054                            depth
5055                        )?;
5056                    } else {
5057                        unreachable!()
5058                    }
5059                }
5060                #[allow(deprecated)]
5061                ordinal => {
5062                    for _ in 0..num_handles {
5063                        decoder.drop_next_handle()?;
5064                    }
5065                    *self = CommitResult::__SourceBreaking { unknown_ordinal: ordinal };
5066                }
5067            }
5068            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5069                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5070            }
5071            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5072                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5073            }
5074            Ok(())
5075        }
5076    }
5077}