1#![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_policy_properties__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
18pub struct NetworkToken {
19 pub value: Option<fidl::EventPair>,
20 #[doc(hidden)]
21 pub __source_breaking: fidl::marker::SourceBreaking,
22}
23
24impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {}
25
26#[derive(Debug, Default, PartialEq)]
27pub struct NetworksWatchPropertiesRequest {
28 pub network: Option<NetworkToken>,
31 pub properties: Option<Vec<Property>>,
35 #[doc(hidden)]
36 pub __source_breaking: fidl::marker::SourceBreaking,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40 for NetworksWatchPropertiesRequest
41{
42}
43
44#[derive(Debug)]
45pub enum NetworksWatchDefaultResponse {
46 Network(NetworkToken),
47 NoDefaultNetwork(Empty),
48 #[doc(hidden)]
49 __SourceBreaking {
50 unknown_ordinal: u64,
51 },
52}
53
54#[macro_export]
56macro_rules! NetworksWatchDefaultResponseUnknown {
57 () => {
58 _
59 };
60}
61
62impl PartialEq for NetworksWatchDefaultResponse {
64 fn eq(&self, other: &Self) -> bool {
65 match (self, other) {
66 (Self::Network(x), Self::Network(y)) => *x == *y,
67 (Self::NoDefaultNetwork(x), Self::NoDefaultNetwork(y)) => *x == *y,
68 _ => false,
69 }
70 }
71}
72
73impl NetworksWatchDefaultResponse {
74 #[inline]
75 pub fn ordinal(&self) -> u64 {
76 match *self {
77 Self::Network(_) => 1,
78 Self::NoDefaultNetwork(_) => 2,
79 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
80 }
81 }
82
83 #[inline]
84 pub fn unknown_variant_for_testing() -> Self {
85 Self::__SourceBreaking { unknown_ordinal: 0 }
86 }
87
88 #[inline]
89 pub fn is_unknown(&self) -> bool {
90 match self {
91 Self::__SourceBreaking { .. } => true,
92 _ => false,
93 }
94 }
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
98 for NetworksWatchDefaultResponse
99{
100}
101
102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
103pub struct DefaultNetworkWatcherMarker;
104
105impl fidl::endpoints::ProtocolMarker for DefaultNetworkWatcherMarker {
106 type Proxy = DefaultNetworkWatcherProxy;
107 type RequestStream = DefaultNetworkWatcherRequestStream;
108 #[cfg(target_os = "fuchsia")]
109 type SynchronousProxy = DefaultNetworkWatcherSynchronousProxy;
110
111 const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.DefaultNetworkWatcher";
112}
113impl fidl::endpoints::DiscoverableProtocolMarker for DefaultNetworkWatcherMarker {}
114
115pub trait DefaultNetworkWatcherProxyInterface: Send + Sync {
116 type WatchResponseFut: std::future::Future<Output = Result<DefaultNetworkUpdate, fidl::Error>>
117 + Send;
118 fn r#watch(&self) -> Self::WatchResponseFut;
119}
120#[derive(Debug)]
121#[cfg(target_os = "fuchsia")]
122pub struct DefaultNetworkWatcherSynchronousProxy {
123 client: fidl::client::sync::Client,
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::SynchronousProxy for DefaultNetworkWatcherSynchronousProxy {
128 type Proxy = DefaultNetworkWatcherProxy;
129 type Protocol = DefaultNetworkWatcherMarker;
130
131 fn from_channel(inner: fidl::Channel) -> Self {
132 Self::new(inner)
133 }
134
135 fn into_channel(self) -> fidl::Channel {
136 self.client.into_channel()
137 }
138
139 fn as_channel(&self) -> &fidl::Channel {
140 self.client.as_channel()
141 }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl DefaultNetworkWatcherSynchronousProxy {
146 pub fn new(channel: fidl::Channel) -> Self {
147 let protocol_name =
148 <DefaultNetworkWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
149 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
150 }
151
152 pub fn into_channel(self) -> fidl::Channel {
153 self.client.into_channel()
154 }
155
156 pub fn wait_for_event(
159 &self,
160 deadline: zx::MonotonicInstant,
161 ) -> Result<DefaultNetworkWatcherEvent, fidl::Error> {
162 DefaultNetworkWatcherEvent::decode(self.client.wait_for_event(deadline)?)
163 }
164
165 pub fn r#watch(
170 &self,
171 ___deadline: zx::MonotonicInstant,
172 ) -> Result<DefaultNetworkUpdate, fidl::Error> {
173 let _response =
174 self.client.send_query::<fidl::encoding::EmptyPayload, DefaultNetworkUpdate>(
175 (),
176 0x5fa419d19afc90b2,
177 fidl::encoding::DynamicFlags::empty(),
178 ___deadline,
179 )?;
180 Ok(_response)
181 }
182}
183
184#[cfg(target_os = "fuchsia")]
185impl From<DefaultNetworkWatcherSynchronousProxy> for zx::Handle {
186 fn from(value: DefaultNetworkWatcherSynchronousProxy) -> Self {
187 value.into_channel().into()
188 }
189}
190
191#[cfg(target_os = "fuchsia")]
192impl From<fidl::Channel> for DefaultNetworkWatcherSynchronousProxy {
193 fn from(value: fidl::Channel) -> Self {
194 Self::new(value)
195 }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl fidl::endpoints::FromClient for DefaultNetworkWatcherSynchronousProxy {
200 type Protocol = DefaultNetworkWatcherMarker;
201
202 fn from_client(value: fidl::endpoints::ClientEnd<DefaultNetworkWatcherMarker>) -> Self {
203 Self::new(value.into_channel())
204 }
205}
206
207#[derive(Debug, Clone)]
208pub struct DefaultNetworkWatcherProxy {
209 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
210}
211
212impl fidl::endpoints::Proxy for DefaultNetworkWatcherProxy {
213 type Protocol = DefaultNetworkWatcherMarker;
214
215 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
216 Self::new(inner)
217 }
218
219 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
220 self.client.into_channel().map_err(|client| Self { client })
221 }
222
223 fn as_channel(&self) -> &::fidl::AsyncChannel {
224 self.client.as_channel()
225 }
226}
227
228impl DefaultNetworkWatcherProxy {
229 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
231 let protocol_name =
232 <DefaultNetworkWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
233 Self { client: fidl::client::Client::new(channel, protocol_name) }
234 }
235
236 pub fn take_event_stream(&self) -> DefaultNetworkWatcherEventStream {
242 DefaultNetworkWatcherEventStream { event_receiver: self.client.take_event_receiver() }
243 }
244
245 pub fn r#watch(
250 &self,
251 ) -> fidl::client::QueryResponseFut<
252 DefaultNetworkUpdate,
253 fidl::encoding::DefaultFuchsiaResourceDialect,
254 > {
255 DefaultNetworkWatcherProxyInterface::r#watch(self)
256 }
257}
258
259impl DefaultNetworkWatcherProxyInterface for DefaultNetworkWatcherProxy {
260 type WatchResponseFut = fidl::client::QueryResponseFut<
261 DefaultNetworkUpdate,
262 fidl::encoding::DefaultFuchsiaResourceDialect,
263 >;
264 fn r#watch(&self) -> Self::WatchResponseFut {
265 fn _decode(
266 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
267 ) -> Result<DefaultNetworkUpdate, fidl::Error> {
268 let _response = fidl::client::decode_transaction_body::<
269 DefaultNetworkUpdate,
270 fidl::encoding::DefaultFuchsiaResourceDialect,
271 0x5fa419d19afc90b2,
272 >(_buf?)?;
273 Ok(_response)
274 }
275 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DefaultNetworkUpdate>(
276 (),
277 0x5fa419d19afc90b2,
278 fidl::encoding::DynamicFlags::empty(),
279 _decode,
280 )
281 }
282}
283
284pub struct DefaultNetworkWatcherEventStream {
285 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
286}
287
288impl std::marker::Unpin for DefaultNetworkWatcherEventStream {}
289
290impl futures::stream::FusedStream for DefaultNetworkWatcherEventStream {
291 fn is_terminated(&self) -> bool {
292 self.event_receiver.is_terminated()
293 }
294}
295
296impl futures::Stream for DefaultNetworkWatcherEventStream {
297 type Item = Result<DefaultNetworkWatcherEvent, fidl::Error>;
298
299 fn poll_next(
300 mut self: std::pin::Pin<&mut Self>,
301 cx: &mut std::task::Context<'_>,
302 ) -> std::task::Poll<Option<Self::Item>> {
303 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
304 &mut self.event_receiver,
305 cx
306 )?) {
307 Some(buf) => std::task::Poll::Ready(Some(DefaultNetworkWatcherEvent::decode(buf))),
308 None => std::task::Poll::Ready(None),
309 }
310 }
311}
312
313#[derive(Debug)]
314pub enum DefaultNetworkWatcherEvent {
315 #[non_exhaustive]
316 _UnknownEvent {
317 ordinal: u64,
319 },
320}
321
322impl DefaultNetworkWatcherEvent {
323 fn decode(
325 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
326 ) -> Result<DefaultNetworkWatcherEvent, fidl::Error> {
327 let (bytes, _handles) = buf.split_mut();
328 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
329 debug_assert_eq!(tx_header.tx_id, 0);
330 match tx_header.ordinal {
331 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
332 Ok(DefaultNetworkWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
333 }
334 _ => Err(fidl::Error::UnknownOrdinal {
335 ordinal: tx_header.ordinal,
336 protocol_name:
337 <DefaultNetworkWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
338 }),
339 }
340 }
341}
342
343pub struct DefaultNetworkWatcherRequestStream {
345 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
346 is_terminated: bool,
347}
348
349impl std::marker::Unpin for DefaultNetworkWatcherRequestStream {}
350
351impl futures::stream::FusedStream for DefaultNetworkWatcherRequestStream {
352 fn is_terminated(&self) -> bool {
353 self.is_terminated
354 }
355}
356
357impl fidl::endpoints::RequestStream for DefaultNetworkWatcherRequestStream {
358 type Protocol = DefaultNetworkWatcherMarker;
359 type ControlHandle = DefaultNetworkWatcherControlHandle;
360
361 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
362 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
363 }
364
365 fn control_handle(&self) -> Self::ControlHandle {
366 DefaultNetworkWatcherControlHandle { inner: self.inner.clone() }
367 }
368
369 fn into_inner(
370 self,
371 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
372 {
373 (self.inner, self.is_terminated)
374 }
375
376 fn from_inner(
377 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
378 is_terminated: bool,
379 ) -> Self {
380 Self { inner, is_terminated }
381 }
382}
383
384impl futures::Stream for DefaultNetworkWatcherRequestStream {
385 type Item = Result<DefaultNetworkWatcherRequest, fidl::Error>;
386
387 fn poll_next(
388 mut self: std::pin::Pin<&mut Self>,
389 cx: &mut std::task::Context<'_>,
390 ) -> std::task::Poll<Option<Self::Item>> {
391 let this = &mut *self;
392 if this.inner.check_shutdown(cx) {
393 this.is_terminated = true;
394 return std::task::Poll::Ready(None);
395 }
396 if this.is_terminated {
397 panic!("polled DefaultNetworkWatcherRequestStream after completion");
398 }
399 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
400 |bytes, handles| {
401 match this.inner.channel().read_etc(cx, bytes, handles) {
402 std::task::Poll::Ready(Ok(())) => {}
403 std::task::Poll::Pending => return std::task::Poll::Pending,
404 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
405 this.is_terminated = true;
406 return std::task::Poll::Ready(None);
407 }
408 std::task::Poll::Ready(Err(e)) => {
409 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
410 e.into(),
411 ))));
412 }
413 }
414
415 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
417
418 std::task::Poll::Ready(Some(match header.ordinal {
419 0x5fa419d19afc90b2 => {
420 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
421 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
422 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
423 let control_handle = DefaultNetworkWatcherControlHandle {
424 inner: this.inner.clone(),
425 };
426 Ok(DefaultNetworkWatcherRequest::Watch {
427 responder: DefaultNetworkWatcherWatchResponder {
428 control_handle: std::mem::ManuallyDrop::new(control_handle),
429 tx_id: header.tx_id,
430 },
431 })
432 }
433 _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
434 Ok(DefaultNetworkWatcherRequest::_UnknownMethod {
435 ordinal: header.ordinal,
436 control_handle: DefaultNetworkWatcherControlHandle { inner: this.inner.clone() },
437 method_type: fidl::MethodType::OneWay,
438 })
439 }
440 _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
441 this.inner.send_framework_err(
442 fidl::encoding::FrameworkErr::UnknownMethod,
443 header.tx_id,
444 header.ordinal,
445 header.dynamic_flags(),
446 (bytes, handles),
447 )?;
448 Ok(DefaultNetworkWatcherRequest::_UnknownMethod {
449 ordinal: header.ordinal,
450 control_handle: DefaultNetworkWatcherControlHandle { inner: this.inner.clone() },
451 method_type: fidl::MethodType::TwoWay,
452 })
453 }
454 _ => Err(fidl::Error::UnknownOrdinal {
455 ordinal: header.ordinal,
456 protocol_name: <DefaultNetworkWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
457 }),
458 }))
459 },
460 )
461 }
462}
463
464#[derive(Debug)]
469pub enum DefaultNetworkWatcherRequest {
470 Watch { responder: DefaultNetworkWatcherWatchResponder },
475 #[non_exhaustive]
477 _UnknownMethod {
478 ordinal: u64,
480 control_handle: DefaultNetworkWatcherControlHandle,
481 method_type: fidl::MethodType,
482 },
483}
484
485impl DefaultNetworkWatcherRequest {
486 #[allow(irrefutable_let_patterns)]
487 pub fn into_watch(self) -> Option<(DefaultNetworkWatcherWatchResponder)> {
488 if let DefaultNetworkWatcherRequest::Watch { responder } = self {
489 Some((responder))
490 } else {
491 None
492 }
493 }
494
495 pub fn method_name(&self) -> &'static str {
497 match *self {
498 DefaultNetworkWatcherRequest::Watch { .. } => "watch",
499 DefaultNetworkWatcherRequest::_UnknownMethod {
500 method_type: fidl::MethodType::OneWay,
501 ..
502 } => "unknown one-way method",
503 DefaultNetworkWatcherRequest::_UnknownMethod {
504 method_type: fidl::MethodType::TwoWay,
505 ..
506 } => "unknown two-way method",
507 }
508 }
509}
510
511#[derive(Debug, Clone)]
512pub struct DefaultNetworkWatcherControlHandle {
513 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
514}
515
516impl fidl::endpoints::ControlHandle for DefaultNetworkWatcherControlHandle {
517 fn shutdown(&self) {
518 self.inner.shutdown()
519 }
520 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
521 self.inner.shutdown_with_epitaph(status)
522 }
523
524 fn is_closed(&self) -> bool {
525 self.inner.channel().is_closed()
526 }
527 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
528 self.inner.channel().on_closed()
529 }
530
531 #[cfg(target_os = "fuchsia")]
532 fn signal_peer(
533 &self,
534 clear_mask: zx::Signals,
535 set_mask: zx::Signals,
536 ) -> Result<(), zx_status::Status> {
537 use fidl::Peered;
538 self.inner.channel().signal_peer(clear_mask, set_mask)
539 }
540}
541
542impl DefaultNetworkWatcherControlHandle {}
543
544#[must_use = "FIDL methods require a response to be sent"]
545#[derive(Debug)]
546pub struct DefaultNetworkWatcherWatchResponder {
547 control_handle: std::mem::ManuallyDrop<DefaultNetworkWatcherControlHandle>,
548 tx_id: u32,
549}
550
551impl std::ops::Drop for DefaultNetworkWatcherWatchResponder {
555 fn drop(&mut self) {
556 self.control_handle.shutdown();
557 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
559 }
560}
561
562impl fidl::endpoints::Responder for DefaultNetworkWatcherWatchResponder {
563 type ControlHandle = DefaultNetworkWatcherControlHandle;
564
565 fn control_handle(&self) -> &DefaultNetworkWatcherControlHandle {
566 &self.control_handle
567 }
568
569 fn drop_without_shutdown(mut self) {
570 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
572 std::mem::forget(self);
574 }
575}
576
577impl DefaultNetworkWatcherWatchResponder {
578 pub fn send(self, mut payload: &DefaultNetworkUpdate) -> Result<(), fidl::Error> {
582 let _result = self.send_raw(payload);
583 if _result.is_err() {
584 self.control_handle.shutdown();
585 }
586 self.drop_without_shutdown();
587 _result
588 }
589
590 pub fn send_no_shutdown_on_err(
592 self,
593 mut payload: &DefaultNetworkUpdate,
594 ) -> Result<(), fidl::Error> {
595 let _result = self.send_raw(payload);
596 self.drop_without_shutdown();
597 _result
598 }
599
600 fn send_raw(&self, mut payload: &DefaultNetworkUpdate) -> Result<(), fidl::Error> {
601 self.control_handle.inner.send::<DefaultNetworkUpdate>(
602 payload,
603 self.tx_id,
604 0x5fa419d19afc90b2,
605 fidl::encoding::DynamicFlags::empty(),
606 )
607 }
608}
609
610#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
611pub struct NetworksMarker;
612
613impl fidl::endpoints::ProtocolMarker for NetworksMarker {
614 type Proxy = NetworksProxy;
615 type RequestStream = NetworksRequestStream;
616 #[cfg(target_os = "fuchsia")]
617 type SynchronousProxy = NetworksSynchronousProxy;
618
619 const DEBUG_NAME: &'static str = "fuchsia.net.policy.properties.Networks";
620}
621impl fidl::endpoints::DiscoverableProtocolMarker for NetworksMarker {}
622pub type NetworksWatchPropertiesResult = Result<Vec<PropertyUpdate>, WatchError>;
623
624pub trait NetworksProxyInterface: Send + Sync {
625 type WatchDefaultResponseFut: std::future::Future<Output = Result<NetworksWatchDefaultResponse, fidl::Error>>
626 + Send;
627 fn r#watch_default(&self) -> Self::WatchDefaultResponseFut;
628 type WatchPropertiesResponseFut: std::future::Future<Output = Result<NetworksWatchPropertiesResult, fidl::Error>>
629 + Send;
630 fn r#watch_properties(
631 &self,
632 payload: NetworksWatchPropertiesRequest,
633 ) -> Self::WatchPropertiesResponseFut;
634}
635#[derive(Debug)]
636#[cfg(target_os = "fuchsia")]
637pub struct NetworksSynchronousProxy {
638 client: fidl::client::sync::Client,
639}
640
641#[cfg(target_os = "fuchsia")]
642impl fidl::endpoints::SynchronousProxy for NetworksSynchronousProxy {
643 type Proxy = NetworksProxy;
644 type Protocol = NetworksMarker;
645
646 fn from_channel(inner: fidl::Channel) -> Self {
647 Self::new(inner)
648 }
649
650 fn into_channel(self) -> fidl::Channel {
651 self.client.into_channel()
652 }
653
654 fn as_channel(&self) -> &fidl::Channel {
655 self.client.as_channel()
656 }
657}
658
659#[cfg(target_os = "fuchsia")]
660impl NetworksSynchronousProxy {
661 pub fn new(channel: fidl::Channel) -> Self {
662 let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
663 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
664 }
665
666 pub fn into_channel(self) -> fidl::Channel {
667 self.client.into_channel()
668 }
669
670 pub fn wait_for_event(
673 &self,
674 deadline: zx::MonotonicInstant,
675 ) -> Result<NetworksEvent, fidl::Error> {
676 NetworksEvent::decode(self.client.wait_for_event(deadline)?)
677 }
678
679 pub fn r#watch_default(
690 &self,
691 ___deadline: zx::MonotonicInstant,
692 ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
693 let _response = self.client.send_query::<
694 fidl::encoding::EmptyPayload,
695 fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
696 >(
697 (),
698 0x346880b2d7db0f98,
699 fidl::encoding::DynamicFlags::FLEXIBLE,
700 ___deadline,
701 )?
702 .into_result::<NetworksMarker>("watch_default")?;
703 Ok(_response)
704 }
705
706 pub fn r#watch_properties(
719 &self,
720 mut payload: NetworksWatchPropertiesRequest,
721 ___deadline: zx::MonotonicInstant,
722 ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
723 let _response = self.client.send_query::<
724 NetworksWatchPropertiesRequest,
725 fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
726 >(
727 &mut payload,
728 0x24d2340905f7dcc6,
729 fidl::encoding::DynamicFlags::FLEXIBLE,
730 ___deadline,
731 )?
732 .into_result::<NetworksMarker>("watch_properties")?;
733 Ok(_response.map(|x| x.updates))
734 }
735}
736
737#[cfg(target_os = "fuchsia")]
738impl From<NetworksSynchronousProxy> for zx::Handle {
739 fn from(value: NetworksSynchronousProxy) -> Self {
740 value.into_channel().into()
741 }
742}
743
744#[cfg(target_os = "fuchsia")]
745impl From<fidl::Channel> for NetworksSynchronousProxy {
746 fn from(value: fidl::Channel) -> Self {
747 Self::new(value)
748 }
749}
750
751#[cfg(target_os = "fuchsia")]
752impl fidl::endpoints::FromClient for NetworksSynchronousProxy {
753 type Protocol = NetworksMarker;
754
755 fn from_client(value: fidl::endpoints::ClientEnd<NetworksMarker>) -> Self {
756 Self::new(value.into_channel())
757 }
758}
759
760#[derive(Debug, Clone)]
761pub struct NetworksProxy {
762 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
763}
764
765impl fidl::endpoints::Proxy for NetworksProxy {
766 type Protocol = NetworksMarker;
767
768 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
769 Self::new(inner)
770 }
771
772 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
773 self.client.into_channel().map_err(|client| Self { client })
774 }
775
776 fn as_channel(&self) -> &::fidl::AsyncChannel {
777 self.client.as_channel()
778 }
779}
780
781impl NetworksProxy {
782 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
784 let protocol_name = <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
785 Self { client: fidl::client::Client::new(channel, protocol_name) }
786 }
787
788 pub fn take_event_stream(&self) -> NetworksEventStream {
794 NetworksEventStream { event_receiver: self.client.take_event_receiver() }
795 }
796
797 pub fn r#watch_default(
808 &self,
809 ) -> fidl::client::QueryResponseFut<
810 NetworksWatchDefaultResponse,
811 fidl::encoding::DefaultFuchsiaResourceDialect,
812 > {
813 NetworksProxyInterface::r#watch_default(self)
814 }
815
816 pub fn r#watch_properties(
829 &self,
830 mut payload: NetworksWatchPropertiesRequest,
831 ) -> fidl::client::QueryResponseFut<
832 NetworksWatchPropertiesResult,
833 fidl::encoding::DefaultFuchsiaResourceDialect,
834 > {
835 NetworksProxyInterface::r#watch_properties(self, payload)
836 }
837}
838
839impl NetworksProxyInterface for NetworksProxy {
840 type WatchDefaultResponseFut = fidl::client::QueryResponseFut<
841 NetworksWatchDefaultResponse,
842 fidl::encoding::DefaultFuchsiaResourceDialect,
843 >;
844 fn r#watch_default(&self) -> Self::WatchDefaultResponseFut {
845 fn _decode(
846 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
847 ) -> Result<NetworksWatchDefaultResponse, fidl::Error> {
848 let _response = fidl::client::decode_transaction_body::<
849 fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>,
850 fidl::encoding::DefaultFuchsiaResourceDialect,
851 0x346880b2d7db0f98,
852 >(_buf?)?
853 .into_result::<NetworksMarker>("watch_default")?;
854 Ok(_response)
855 }
856 self.client
857 .send_query_and_decode::<fidl::encoding::EmptyPayload, NetworksWatchDefaultResponse>(
858 (),
859 0x346880b2d7db0f98,
860 fidl::encoding::DynamicFlags::FLEXIBLE,
861 _decode,
862 )
863 }
864
865 type WatchPropertiesResponseFut = fidl::client::QueryResponseFut<
866 NetworksWatchPropertiesResult,
867 fidl::encoding::DefaultFuchsiaResourceDialect,
868 >;
869 fn r#watch_properties(
870 &self,
871 mut payload: NetworksWatchPropertiesRequest,
872 ) -> Self::WatchPropertiesResponseFut {
873 fn _decode(
874 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
875 ) -> Result<NetworksWatchPropertiesResult, fidl::Error> {
876 let _response = fidl::client::decode_transaction_body::<
877 fidl::encoding::FlexibleResultType<NetworksWatchPropertiesResponse, WatchError>,
878 fidl::encoding::DefaultFuchsiaResourceDialect,
879 0x24d2340905f7dcc6,
880 >(_buf?)?
881 .into_result::<NetworksMarker>("watch_properties")?;
882 Ok(_response.map(|x| x.updates))
883 }
884 self.client
885 .send_query_and_decode::<NetworksWatchPropertiesRequest, NetworksWatchPropertiesResult>(
886 &mut payload,
887 0x24d2340905f7dcc6,
888 fidl::encoding::DynamicFlags::FLEXIBLE,
889 _decode,
890 )
891 }
892}
893
894pub struct NetworksEventStream {
895 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
896}
897
898impl std::marker::Unpin for NetworksEventStream {}
899
900impl futures::stream::FusedStream for NetworksEventStream {
901 fn is_terminated(&self) -> bool {
902 self.event_receiver.is_terminated()
903 }
904}
905
906impl futures::Stream for NetworksEventStream {
907 type Item = Result<NetworksEvent, fidl::Error>;
908
909 fn poll_next(
910 mut self: std::pin::Pin<&mut Self>,
911 cx: &mut std::task::Context<'_>,
912 ) -> std::task::Poll<Option<Self::Item>> {
913 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
914 &mut self.event_receiver,
915 cx
916 )?) {
917 Some(buf) => std::task::Poll::Ready(Some(NetworksEvent::decode(buf))),
918 None => std::task::Poll::Ready(None),
919 }
920 }
921}
922
923#[derive(Debug)]
924pub enum NetworksEvent {
925 #[non_exhaustive]
926 _UnknownEvent {
927 ordinal: u64,
929 },
930}
931
932impl NetworksEvent {
933 fn decode(
935 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
936 ) -> Result<NetworksEvent, fidl::Error> {
937 let (bytes, _handles) = buf.split_mut();
938 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
939 debug_assert_eq!(tx_header.tx_id, 0);
940 match tx_header.ordinal {
941 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
942 Ok(NetworksEvent::_UnknownEvent { ordinal: tx_header.ordinal })
943 }
944 _ => Err(fidl::Error::UnknownOrdinal {
945 ordinal: tx_header.ordinal,
946 protocol_name: <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
947 }),
948 }
949 }
950}
951
952pub struct NetworksRequestStream {
954 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
955 is_terminated: bool,
956}
957
958impl std::marker::Unpin for NetworksRequestStream {}
959
960impl futures::stream::FusedStream for NetworksRequestStream {
961 fn is_terminated(&self) -> bool {
962 self.is_terminated
963 }
964}
965
966impl fidl::endpoints::RequestStream for NetworksRequestStream {
967 type Protocol = NetworksMarker;
968 type ControlHandle = NetworksControlHandle;
969
970 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
971 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
972 }
973
974 fn control_handle(&self) -> Self::ControlHandle {
975 NetworksControlHandle { inner: self.inner.clone() }
976 }
977
978 fn into_inner(
979 self,
980 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
981 {
982 (self.inner, self.is_terminated)
983 }
984
985 fn from_inner(
986 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
987 is_terminated: bool,
988 ) -> Self {
989 Self { inner, is_terminated }
990 }
991}
992
993impl futures::Stream for NetworksRequestStream {
994 type Item = Result<NetworksRequest, fidl::Error>;
995
996 fn poll_next(
997 mut self: std::pin::Pin<&mut Self>,
998 cx: &mut std::task::Context<'_>,
999 ) -> std::task::Poll<Option<Self::Item>> {
1000 let this = &mut *self;
1001 if this.inner.check_shutdown(cx) {
1002 this.is_terminated = true;
1003 return std::task::Poll::Ready(None);
1004 }
1005 if this.is_terminated {
1006 panic!("polled NetworksRequestStream after completion");
1007 }
1008 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1009 |bytes, handles| {
1010 match this.inner.channel().read_etc(cx, bytes, handles) {
1011 std::task::Poll::Ready(Ok(())) => {}
1012 std::task::Poll::Pending => return std::task::Poll::Pending,
1013 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1014 this.is_terminated = true;
1015 return std::task::Poll::Ready(None);
1016 }
1017 std::task::Poll::Ready(Err(e)) => {
1018 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1019 e.into(),
1020 ))));
1021 }
1022 }
1023
1024 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1026
1027 std::task::Poll::Ready(Some(match header.ordinal {
1028 0x346880b2d7db0f98 => {
1029 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1030 let mut req = fidl::new_empty!(
1031 fidl::encoding::EmptyPayload,
1032 fidl::encoding::DefaultFuchsiaResourceDialect
1033 );
1034 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1035 let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1036 Ok(NetworksRequest::WatchDefault {
1037 responder: NetworksWatchDefaultResponder {
1038 control_handle: std::mem::ManuallyDrop::new(control_handle),
1039 tx_id: header.tx_id,
1040 },
1041 })
1042 }
1043 0x24d2340905f7dcc6 => {
1044 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1045 let mut req = fidl::new_empty!(
1046 NetworksWatchPropertiesRequest,
1047 fidl::encoding::DefaultFuchsiaResourceDialect
1048 );
1049 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworksWatchPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
1050 let control_handle = NetworksControlHandle { inner: this.inner.clone() };
1051 Ok(NetworksRequest::WatchProperties {
1052 payload: req,
1053 responder: NetworksWatchPropertiesResponder {
1054 control_handle: std::mem::ManuallyDrop::new(control_handle),
1055 tx_id: header.tx_id,
1056 },
1057 })
1058 }
1059 _ if header.tx_id == 0
1060 && header
1061 .dynamic_flags()
1062 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1063 {
1064 Ok(NetworksRequest::_UnknownMethod {
1065 ordinal: header.ordinal,
1066 control_handle: NetworksControlHandle { inner: this.inner.clone() },
1067 method_type: fidl::MethodType::OneWay,
1068 })
1069 }
1070 _ if header
1071 .dynamic_flags()
1072 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1073 {
1074 this.inner.send_framework_err(
1075 fidl::encoding::FrameworkErr::UnknownMethod,
1076 header.tx_id,
1077 header.ordinal,
1078 header.dynamic_flags(),
1079 (bytes, handles),
1080 )?;
1081 Ok(NetworksRequest::_UnknownMethod {
1082 ordinal: header.ordinal,
1083 control_handle: NetworksControlHandle { inner: this.inner.clone() },
1084 method_type: fidl::MethodType::TwoWay,
1085 })
1086 }
1087 _ => Err(fidl::Error::UnknownOrdinal {
1088 ordinal: header.ordinal,
1089 protocol_name:
1090 <NetworksMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1091 }),
1092 }))
1093 },
1094 )
1095 }
1096}
1097
1098#[derive(Debug)]
1101pub enum NetworksRequest {
1102 WatchDefault { responder: NetworksWatchDefaultResponder },
1113 WatchProperties {
1126 payload: NetworksWatchPropertiesRequest,
1127 responder: NetworksWatchPropertiesResponder,
1128 },
1129 #[non_exhaustive]
1131 _UnknownMethod {
1132 ordinal: u64,
1134 control_handle: NetworksControlHandle,
1135 method_type: fidl::MethodType,
1136 },
1137}
1138
1139impl NetworksRequest {
1140 #[allow(irrefutable_let_patterns)]
1141 pub fn into_watch_default(self) -> Option<(NetworksWatchDefaultResponder)> {
1142 if let NetworksRequest::WatchDefault { responder } = self {
1143 Some((responder))
1144 } else {
1145 None
1146 }
1147 }
1148
1149 #[allow(irrefutable_let_patterns)]
1150 pub fn into_watch_properties(
1151 self,
1152 ) -> Option<(NetworksWatchPropertiesRequest, NetworksWatchPropertiesResponder)> {
1153 if let NetworksRequest::WatchProperties { payload, responder } = self {
1154 Some((payload, responder))
1155 } else {
1156 None
1157 }
1158 }
1159
1160 pub fn method_name(&self) -> &'static str {
1162 match *self {
1163 NetworksRequest::WatchDefault { .. } => "watch_default",
1164 NetworksRequest::WatchProperties { .. } => "watch_properties",
1165 NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1166 "unknown one-way method"
1167 }
1168 NetworksRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1169 "unknown two-way method"
1170 }
1171 }
1172 }
1173}
1174
1175#[derive(Debug, Clone)]
1176pub struct NetworksControlHandle {
1177 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1178}
1179
1180impl fidl::endpoints::ControlHandle for NetworksControlHandle {
1181 fn shutdown(&self) {
1182 self.inner.shutdown()
1183 }
1184 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1185 self.inner.shutdown_with_epitaph(status)
1186 }
1187
1188 fn is_closed(&self) -> bool {
1189 self.inner.channel().is_closed()
1190 }
1191 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1192 self.inner.channel().on_closed()
1193 }
1194
1195 #[cfg(target_os = "fuchsia")]
1196 fn signal_peer(
1197 &self,
1198 clear_mask: zx::Signals,
1199 set_mask: zx::Signals,
1200 ) -> Result<(), zx_status::Status> {
1201 use fidl::Peered;
1202 self.inner.channel().signal_peer(clear_mask, set_mask)
1203 }
1204}
1205
1206impl NetworksControlHandle {}
1207
1208#[must_use = "FIDL methods require a response to be sent"]
1209#[derive(Debug)]
1210pub struct NetworksWatchDefaultResponder {
1211 control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1212 tx_id: u32,
1213}
1214
1215impl std::ops::Drop for NetworksWatchDefaultResponder {
1219 fn drop(&mut self) {
1220 self.control_handle.shutdown();
1221 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1223 }
1224}
1225
1226impl fidl::endpoints::Responder for NetworksWatchDefaultResponder {
1227 type ControlHandle = NetworksControlHandle;
1228
1229 fn control_handle(&self) -> &NetworksControlHandle {
1230 &self.control_handle
1231 }
1232
1233 fn drop_without_shutdown(mut self) {
1234 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1236 std::mem::forget(self);
1238 }
1239}
1240
1241impl NetworksWatchDefaultResponder {
1242 pub fn send(self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1246 let _result = self.send_raw(payload);
1247 if _result.is_err() {
1248 self.control_handle.shutdown();
1249 }
1250 self.drop_without_shutdown();
1251 _result
1252 }
1253
1254 pub fn send_no_shutdown_on_err(
1256 self,
1257 mut payload: NetworksWatchDefaultResponse,
1258 ) -> Result<(), fidl::Error> {
1259 let _result = self.send_raw(payload);
1260 self.drop_without_shutdown();
1261 _result
1262 }
1263
1264 fn send_raw(&self, mut payload: NetworksWatchDefaultResponse) -> Result<(), fidl::Error> {
1265 self.control_handle
1266 .inner
1267 .send::<fidl::encoding::FlexibleType<NetworksWatchDefaultResponse>>(
1268 fidl::encoding::Flexible::new(&mut payload),
1269 self.tx_id,
1270 0x346880b2d7db0f98,
1271 fidl::encoding::DynamicFlags::FLEXIBLE,
1272 )
1273 }
1274}
1275
1276#[must_use = "FIDL methods require a response to be sent"]
1277#[derive(Debug)]
1278pub struct NetworksWatchPropertiesResponder {
1279 control_handle: std::mem::ManuallyDrop<NetworksControlHandle>,
1280 tx_id: u32,
1281}
1282
1283impl std::ops::Drop for NetworksWatchPropertiesResponder {
1287 fn drop(&mut self) {
1288 self.control_handle.shutdown();
1289 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1291 }
1292}
1293
1294impl fidl::endpoints::Responder for NetworksWatchPropertiesResponder {
1295 type ControlHandle = NetworksControlHandle;
1296
1297 fn control_handle(&self) -> &NetworksControlHandle {
1298 &self.control_handle
1299 }
1300
1301 fn drop_without_shutdown(mut self) {
1302 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1304 std::mem::forget(self);
1306 }
1307}
1308
1309impl NetworksWatchPropertiesResponder {
1310 pub fn send(
1314 self,
1315 mut result: Result<&[PropertyUpdate], WatchError>,
1316 ) -> Result<(), fidl::Error> {
1317 let _result = self.send_raw(result);
1318 if _result.is_err() {
1319 self.control_handle.shutdown();
1320 }
1321 self.drop_without_shutdown();
1322 _result
1323 }
1324
1325 pub fn send_no_shutdown_on_err(
1327 self,
1328 mut result: Result<&[PropertyUpdate], WatchError>,
1329 ) -> Result<(), fidl::Error> {
1330 let _result = self.send_raw(result);
1331 self.drop_without_shutdown();
1332 _result
1333 }
1334
1335 fn send_raw(
1336 &self,
1337 mut result: Result<&[PropertyUpdate], WatchError>,
1338 ) -> Result<(), fidl::Error> {
1339 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1340 NetworksWatchPropertiesResponse,
1341 WatchError,
1342 >>(
1343 fidl::encoding::FlexibleResult::new(result.map(|updates| (updates,))),
1344 self.tx_id,
1345 0x24d2340905f7dcc6,
1346 fidl::encoding::DynamicFlags::FLEXIBLE,
1347 )
1348 }
1349}
1350
1351mod internal {
1352 use super::*;
1353
1354 impl NetworkToken {
1355 #[inline(always)]
1356 fn max_ordinal_present(&self) -> u64 {
1357 if let Some(_) = self.value {
1358 return 1;
1359 }
1360 0
1361 }
1362 }
1363
1364 impl fidl::encoding::ResourceTypeMarker for NetworkToken {
1365 type Borrowed<'a> = &'a mut Self;
1366 fn take_or_borrow<'a>(
1367 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1368 ) -> Self::Borrowed<'a> {
1369 value
1370 }
1371 }
1372
1373 unsafe impl fidl::encoding::TypeMarker for NetworkToken {
1374 type Owned = Self;
1375
1376 #[inline(always)]
1377 fn inline_align(_context: fidl::encoding::Context) -> usize {
1378 8
1379 }
1380
1381 #[inline(always)]
1382 fn inline_size(_context: fidl::encoding::Context) -> usize {
1383 16
1384 }
1385 }
1386
1387 unsafe impl fidl::encoding::Encode<NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect>
1388 for &mut NetworkToken
1389 {
1390 unsafe fn encode(
1391 self,
1392 encoder: &mut fidl::encoding::Encoder<
1393 '_,
1394 fidl::encoding::DefaultFuchsiaResourceDialect,
1395 >,
1396 offset: usize,
1397 mut depth: fidl::encoding::Depth,
1398 ) -> fidl::Result<()> {
1399 encoder.debug_check_bounds::<NetworkToken>(offset);
1400 let max_ordinal: u64 = self.max_ordinal_present();
1402 encoder.write_num(max_ordinal, offset);
1403 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1404 if max_ordinal == 0 {
1406 return Ok(());
1407 }
1408 depth.increment()?;
1409 let envelope_size = 8;
1410 let bytes_len = max_ordinal as usize * envelope_size;
1411 #[allow(unused_variables)]
1412 let offset = encoder.out_of_line_offset(bytes_len);
1413 let mut _prev_end_offset: usize = 0;
1414 if 1 > max_ordinal {
1415 return Ok(());
1416 }
1417
1418 let cur_offset: usize = (1 - 1) * envelope_size;
1421
1422 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1424
1425 fidl::encoding::encode_in_envelope_optional::<
1430 fidl::encoding::HandleType<
1431 fidl::EventPair,
1432 { fidl::ObjectType::EVENTPAIR.into_raw() },
1433 2147483648,
1434 >,
1435 fidl::encoding::DefaultFuchsiaResourceDialect,
1436 >(
1437 self.value.as_mut().map(
1438 <fidl::encoding::HandleType<
1439 fidl::EventPair,
1440 { fidl::ObjectType::EVENTPAIR.into_raw() },
1441 2147483648,
1442 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1443 ),
1444 encoder,
1445 offset + cur_offset,
1446 depth,
1447 )?;
1448
1449 _prev_end_offset = cur_offset + envelope_size;
1450
1451 Ok(())
1452 }
1453 }
1454
1455 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkToken {
1456 #[inline(always)]
1457 fn new_empty() -> Self {
1458 Self::default()
1459 }
1460
1461 unsafe fn decode(
1462 &mut self,
1463 decoder: &mut fidl::encoding::Decoder<
1464 '_,
1465 fidl::encoding::DefaultFuchsiaResourceDialect,
1466 >,
1467 offset: usize,
1468 mut depth: fidl::encoding::Depth,
1469 ) -> fidl::Result<()> {
1470 decoder.debug_check_bounds::<Self>(offset);
1471 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1472 None => return Err(fidl::Error::NotNullable),
1473 Some(len) => len,
1474 };
1475 if len == 0 {
1477 return Ok(());
1478 };
1479 depth.increment()?;
1480 let envelope_size = 8;
1481 let bytes_len = len * envelope_size;
1482 let offset = decoder.out_of_line_offset(bytes_len)?;
1483 let mut _next_ordinal_to_read = 0;
1485 let mut next_offset = offset;
1486 let end_offset = offset + bytes_len;
1487 _next_ordinal_to_read += 1;
1488 if next_offset >= end_offset {
1489 return Ok(());
1490 }
1491
1492 while _next_ordinal_to_read < 1 {
1494 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1495 _next_ordinal_to_read += 1;
1496 next_offset += envelope_size;
1497 }
1498
1499 let next_out_of_line = decoder.next_out_of_line();
1500 let handles_before = decoder.remaining_handles();
1501 if let Some((inlined, num_bytes, num_handles)) =
1502 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1503 {
1504 let member_inline_size = <fidl::encoding::HandleType<
1505 fidl::EventPair,
1506 { fidl::ObjectType::EVENTPAIR.into_raw() },
1507 2147483648,
1508 > as fidl::encoding::TypeMarker>::inline_size(
1509 decoder.context
1510 );
1511 if inlined != (member_inline_size <= 4) {
1512 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1513 }
1514 let inner_offset;
1515 let mut inner_depth = depth.clone();
1516 if inlined {
1517 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1518 inner_offset = next_offset;
1519 } else {
1520 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1521 inner_depth.increment()?;
1522 }
1523 let val_ref =
1524 self.value.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1525 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1526 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1527 {
1528 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1529 }
1530 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1531 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1532 }
1533 }
1534
1535 next_offset += envelope_size;
1536
1537 while next_offset < end_offset {
1539 _next_ordinal_to_read += 1;
1540 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1541 next_offset += envelope_size;
1542 }
1543
1544 Ok(())
1545 }
1546 }
1547
1548 impl NetworksWatchPropertiesRequest {
1549 #[inline(always)]
1550 fn max_ordinal_present(&self) -> u64 {
1551 if let Some(_) = self.properties {
1552 return 2;
1553 }
1554 if let Some(_) = self.network {
1555 return 1;
1556 }
1557 0
1558 }
1559 }
1560
1561 impl fidl::encoding::ResourceTypeMarker for NetworksWatchPropertiesRequest {
1562 type Borrowed<'a> = &'a mut Self;
1563 fn take_or_borrow<'a>(
1564 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1565 ) -> Self::Borrowed<'a> {
1566 value
1567 }
1568 }
1569
1570 unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesRequest {
1571 type Owned = Self;
1572
1573 #[inline(always)]
1574 fn inline_align(_context: fidl::encoding::Context) -> usize {
1575 8
1576 }
1577
1578 #[inline(always)]
1579 fn inline_size(_context: fidl::encoding::Context) -> usize {
1580 16
1581 }
1582 }
1583
1584 unsafe impl
1585 fidl::encoding::Encode<
1586 NetworksWatchPropertiesRequest,
1587 fidl::encoding::DefaultFuchsiaResourceDialect,
1588 > for &mut NetworksWatchPropertiesRequest
1589 {
1590 unsafe fn encode(
1591 self,
1592 encoder: &mut fidl::encoding::Encoder<
1593 '_,
1594 fidl::encoding::DefaultFuchsiaResourceDialect,
1595 >,
1596 offset: usize,
1597 mut depth: fidl::encoding::Depth,
1598 ) -> fidl::Result<()> {
1599 encoder.debug_check_bounds::<NetworksWatchPropertiesRequest>(offset);
1600 let max_ordinal: u64 = self.max_ordinal_present();
1602 encoder.write_num(max_ordinal, offset);
1603 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1604 if max_ordinal == 0 {
1606 return Ok(());
1607 }
1608 depth.increment()?;
1609 let envelope_size = 8;
1610 let bytes_len = max_ordinal as usize * envelope_size;
1611 #[allow(unused_variables)]
1612 let offset = encoder.out_of_line_offset(bytes_len);
1613 let mut _prev_end_offset: usize = 0;
1614 if 1 > max_ordinal {
1615 return Ok(());
1616 }
1617
1618 let cur_offset: usize = (1 - 1) * envelope_size;
1621
1622 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1624
1625 fidl::encoding::encode_in_envelope_optional::<
1630 NetworkToken,
1631 fidl::encoding::DefaultFuchsiaResourceDialect,
1632 >(
1633 self.network
1634 .as_mut()
1635 .map(<NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1636 encoder,
1637 offset + cur_offset,
1638 depth,
1639 )?;
1640
1641 _prev_end_offset = cur_offset + envelope_size;
1642 if 2 > max_ordinal {
1643 return Ok(());
1644 }
1645
1646 let cur_offset: usize = (2 - 1) * envelope_size;
1649
1650 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1652
1653 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<Property>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1658 self.properties.as_ref().map(<fidl::encoding::UnboundedVector<Property> as fidl::encoding::ValueTypeMarker>::borrow),
1659 encoder, offset + cur_offset, depth
1660 )?;
1661
1662 _prev_end_offset = cur_offset + envelope_size;
1663
1664 Ok(())
1665 }
1666 }
1667
1668 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1669 for NetworksWatchPropertiesRequest
1670 {
1671 #[inline(always)]
1672 fn new_empty() -> Self {
1673 Self::default()
1674 }
1675
1676 unsafe fn decode(
1677 &mut self,
1678 decoder: &mut fidl::encoding::Decoder<
1679 '_,
1680 fidl::encoding::DefaultFuchsiaResourceDialect,
1681 >,
1682 offset: usize,
1683 mut depth: fidl::encoding::Depth,
1684 ) -> fidl::Result<()> {
1685 decoder.debug_check_bounds::<Self>(offset);
1686 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1687 None => return Err(fidl::Error::NotNullable),
1688 Some(len) => len,
1689 };
1690 if len == 0 {
1692 return Ok(());
1693 };
1694 depth.increment()?;
1695 let envelope_size = 8;
1696 let bytes_len = len * envelope_size;
1697 let offset = decoder.out_of_line_offset(bytes_len)?;
1698 let mut _next_ordinal_to_read = 0;
1700 let mut next_offset = offset;
1701 let end_offset = offset + bytes_len;
1702 _next_ordinal_to_read += 1;
1703 if next_offset >= end_offset {
1704 return Ok(());
1705 }
1706
1707 while _next_ordinal_to_read < 1 {
1709 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1710 _next_ordinal_to_read += 1;
1711 next_offset += envelope_size;
1712 }
1713
1714 let next_out_of_line = decoder.next_out_of_line();
1715 let handles_before = decoder.remaining_handles();
1716 if let Some((inlined, num_bytes, num_handles)) =
1717 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1718 {
1719 let member_inline_size =
1720 <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1721 if inlined != (member_inline_size <= 4) {
1722 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1723 }
1724 let inner_offset;
1725 let mut inner_depth = depth.clone();
1726 if inlined {
1727 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1728 inner_offset = next_offset;
1729 } else {
1730 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1731 inner_depth.increment()?;
1732 }
1733 let val_ref = self.network.get_or_insert_with(|| {
1734 fidl::new_empty!(NetworkToken, fidl::encoding::DefaultFuchsiaResourceDialect)
1735 });
1736 fidl::decode!(
1737 NetworkToken,
1738 fidl::encoding::DefaultFuchsiaResourceDialect,
1739 val_ref,
1740 decoder,
1741 inner_offset,
1742 inner_depth
1743 )?;
1744 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1745 {
1746 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1747 }
1748 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1749 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1750 }
1751 }
1752
1753 next_offset += envelope_size;
1754 _next_ordinal_to_read += 1;
1755 if next_offset >= end_offset {
1756 return Ok(());
1757 }
1758
1759 while _next_ordinal_to_read < 2 {
1761 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1762 _next_ordinal_to_read += 1;
1763 next_offset += envelope_size;
1764 }
1765
1766 let next_out_of_line = decoder.next_out_of_line();
1767 let handles_before = decoder.remaining_handles();
1768 if let Some((inlined, num_bytes, num_handles)) =
1769 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1770 {
1771 let member_inline_size = <fidl::encoding::UnboundedVector<Property> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1772 if inlined != (member_inline_size <= 4) {
1773 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1774 }
1775 let inner_offset;
1776 let mut inner_depth = depth.clone();
1777 if inlined {
1778 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1779 inner_offset = next_offset;
1780 } else {
1781 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1782 inner_depth.increment()?;
1783 }
1784 let val_ref = self.properties.get_or_insert_with(|| {
1785 fidl::new_empty!(
1786 fidl::encoding::UnboundedVector<Property>,
1787 fidl::encoding::DefaultFuchsiaResourceDialect
1788 )
1789 });
1790 fidl::decode!(
1791 fidl::encoding::UnboundedVector<Property>,
1792 fidl::encoding::DefaultFuchsiaResourceDialect,
1793 val_ref,
1794 decoder,
1795 inner_offset,
1796 inner_depth
1797 )?;
1798 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1799 {
1800 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1801 }
1802 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1803 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1804 }
1805 }
1806
1807 next_offset += envelope_size;
1808
1809 while next_offset < end_offset {
1811 _next_ordinal_to_read += 1;
1812 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1813 next_offset += envelope_size;
1814 }
1815
1816 Ok(())
1817 }
1818 }
1819
1820 impl fidl::encoding::ResourceTypeMarker for NetworksWatchDefaultResponse {
1821 type Borrowed<'a> = &'a mut Self;
1822 fn take_or_borrow<'a>(
1823 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1824 ) -> Self::Borrowed<'a> {
1825 value
1826 }
1827 }
1828
1829 unsafe impl fidl::encoding::TypeMarker for NetworksWatchDefaultResponse {
1830 type Owned = Self;
1831
1832 #[inline(always)]
1833 fn inline_align(_context: fidl::encoding::Context) -> usize {
1834 8
1835 }
1836
1837 #[inline(always)]
1838 fn inline_size(_context: fidl::encoding::Context) -> usize {
1839 16
1840 }
1841 }
1842
1843 unsafe impl
1844 fidl::encoding::Encode<
1845 NetworksWatchDefaultResponse,
1846 fidl::encoding::DefaultFuchsiaResourceDialect,
1847 > for &mut NetworksWatchDefaultResponse
1848 {
1849 #[inline]
1850 unsafe fn encode(
1851 self,
1852 encoder: &mut fidl::encoding::Encoder<
1853 '_,
1854 fidl::encoding::DefaultFuchsiaResourceDialect,
1855 >,
1856 offset: usize,
1857 _depth: fidl::encoding::Depth,
1858 ) -> fidl::Result<()> {
1859 encoder.debug_check_bounds::<NetworksWatchDefaultResponse>(offset);
1860 encoder.write_num::<u64>(self.ordinal(), offset);
1861 match self {
1862 NetworksWatchDefaultResponse::Network(ref mut val) => {
1863 fidl::encoding::encode_in_envelope::<
1864 NetworkToken,
1865 fidl::encoding::DefaultFuchsiaResourceDialect,
1866 >(
1867 <NetworkToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1868 encoder,
1869 offset + 8,
1870 _depth,
1871 )
1872 }
1873 NetworksWatchDefaultResponse::NoDefaultNetwork(ref val) => {
1874 fidl::encoding::encode_in_envelope::<
1875 Empty,
1876 fidl::encoding::DefaultFuchsiaResourceDialect,
1877 >(
1878 <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
1879 encoder,
1880 offset + 8,
1881 _depth,
1882 )
1883 }
1884 NetworksWatchDefaultResponse::__SourceBreaking { .. } => {
1885 Err(fidl::Error::UnknownUnionTag)
1886 }
1887 }
1888 }
1889 }
1890
1891 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1892 for NetworksWatchDefaultResponse
1893 {
1894 #[inline(always)]
1895 fn new_empty() -> Self {
1896 Self::__SourceBreaking { unknown_ordinal: 0 }
1897 }
1898
1899 #[inline]
1900 unsafe fn decode(
1901 &mut self,
1902 decoder: &mut fidl::encoding::Decoder<
1903 '_,
1904 fidl::encoding::DefaultFuchsiaResourceDialect,
1905 >,
1906 offset: usize,
1907 mut depth: fidl::encoding::Depth,
1908 ) -> fidl::Result<()> {
1909 decoder.debug_check_bounds::<Self>(offset);
1910 #[allow(unused_variables)]
1911 let next_out_of_line = decoder.next_out_of_line();
1912 let handles_before = decoder.remaining_handles();
1913 let (ordinal, inlined, num_bytes, num_handles) =
1914 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1915
1916 let member_inline_size = match ordinal {
1917 1 => <NetworkToken as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1918 2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1919 0 => return Err(fidl::Error::UnknownUnionTag),
1920 _ => num_bytes as usize,
1921 };
1922
1923 if inlined != (member_inline_size <= 4) {
1924 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1925 }
1926 let _inner_offset;
1927 if inlined {
1928 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1929 _inner_offset = offset + 8;
1930 } else {
1931 depth.increment()?;
1932 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1933 }
1934 match ordinal {
1935 1 => {
1936 #[allow(irrefutable_let_patterns)]
1937 if let NetworksWatchDefaultResponse::Network(_) = self {
1938 } else {
1940 *self = NetworksWatchDefaultResponse::Network(fidl::new_empty!(
1942 NetworkToken,
1943 fidl::encoding::DefaultFuchsiaResourceDialect
1944 ));
1945 }
1946 #[allow(irrefutable_let_patterns)]
1947 if let NetworksWatchDefaultResponse::Network(ref mut val) = self {
1948 fidl::decode!(
1949 NetworkToken,
1950 fidl::encoding::DefaultFuchsiaResourceDialect,
1951 val,
1952 decoder,
1953 _inner_offset,
1954 depth
1955 )?;
1956 } else {
1957 unreachable!()
1958 }
1959 }
1960 2 => {
1961 #[allow(irrefutable_let_patterns)]
1962 if let NetworksWatchDefaultResponse::NoDefaultNetwork(_) = self {
1963 } else {
1965 *self = NetworksWatchDefaultResponse::NoDefaultNetwork(fidl::new_empty!(
1967 Empty,
1968 fidl::encoding::DefaultFuchsiaResourceDialect
1969 ));
1970 }
1971 #[allow(irrefutable_let_patterns)]
1972 if let NetworksWatchDefaultResponse::NoDefaultNetwork(ref mut val) = self {
1973 fidl::decode!(
1974 Empty,
1975 fidl::encoding::DefaultFuchsiaResourceDialect,
1976 val,
1977 decoder,
1978 _inner_offset,
1979 depth
1980 )?;
1981 } else {
1982 unreachable!()
1983 }
1984 }
1985 #[allow(deprecated)]
1986 ordinal => {
1987 for _ in 0..num_handles {
1988 decoder.drop_next_handle()?;
1989 }
1990 *self =
1991 NetworksWatchDefaultResponse::__SourceBreaking { unknown_ordinal: ordinal };
1992 }
1993 }
1994 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1995 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1996 }
1997 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1998 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1999 }
2000 Ok(())
2001 }
2002 }
2003}