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_bluetooth_snoop_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct SnoopStartRequest {
16 pub follow: Option<bool>,
17 pub host_device: Option<String>,
18 pub client: Option<fidl::endpoints::ClientEnd<PacketObserverMarker>>,
19 #[doc(hidden)]
20 pub __source_breaking: fidl::marker::SourceBreaking,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SnoopStartRequest {}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct PacketObserverMarker;
27
28impl fidl::endpoints::ProtocolMarker for PacketObserverMarker {
29 type Proxy = PacketObserverProxy;
30 type RequestStream = PacketObserverRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = PacketObserverSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "(anonymous) PacketObserver";
35}
36
37pub trait PacketObserverProxyInterface: Send + Sync {
38 type ObserveResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
39 fn r#observe(&self, payload: &DevicePackets) -> Self::ObserveResponseFut;
40 fn r#error(&self, payload: &CaptureError) -> Result<(), fidl::Error>;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct PacketObserverSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for PacketObserverSynchronousProxy {
50 type Proxy = PacketObserverProxy;
51 type Protocol = PacketObserverMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl PacketObserverSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 let protocol_name = <PacketObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<PacketObserverEvent, fidl::Error> {
83 PacketObserverEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#observe(
89 &self,
90 mut payload: &DevicePackets,
91 ___deadline: zx::MonotonicInstant,
92 ) -> Result<(), fidl::Error> {
93 let _response = self
94 .client
95 .send_query::<DevicePackets, fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
96 payload,
97 0x2a82a5a9a18b79c9,
98 fidl::encoding::DynamicFlags::FLEXIBLE,
99 ___deadline,
100 )?
101 .into_result::<PacketObserverMarker>("observe")?;
102 Ok(_response)
103 }
104
105 pub fn r#error(&self, mut payload: &CaptureError) -> Result<(), fidl::Error> {
108 self.client.send::<CaptureError>(
109 payload,
110 0x6596e43f4f0761e4,
111 fidl::encoding::DynamicFlags::FLEXIBLE,
112 )
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl From<PacketObserverSynchronousProxy> for zx::Handle {
118 fn from(value: PacketObserverSynchronousProxy) -> Self {
119 value.into_channel().into()
120 }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl From<fidl::Channel> for PacketObserverSynchronousProxy {
125 fn from(value: fidl::Channel) -> Self {
126 Self::new(value)
127 }
128}
129
130#[derive(Debug, Clone)]
131pub struct PacketObserverProxy {
132 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
133}
134
135impl fidl::endpoints::Proxy for PacketObserverProxy {
136 type Protocol = PacketObserverMarker;
137
138 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
139 Self::new(inner)
140 }
141
142 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
143 self.client.into_channel().map_err(|client| Self { client })
144 }
145
146 fn as_channel(&self) -> &::fidl::AsyncChannel {
147 self.client.as_channel()
148 }
149}
150
151impl PacketObserverProxy {
152 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
154 let protocol_name = <PacketObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
155 Self { client: fidl::client::Client::new(channel, protocol_name) }
156 }
157
158 pub fn take_event_stream(&self) -> PacketObserverEventStream {
164 PacketObserverEventStream { event_receiver: self.client.take_event_receiver() }
165 }
166
167 pub fn r#observe(
170 &self,
171 mut payload: &DevicePackets,
172 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
173 PacketObserverProxyInterface::r#observe(self, payload)
174 }
175
176 pub fn r#error(&self, mut payload: &CaptureError) -> Result<(), fidl::Error> {
179 PacketObserverProxyInterface::r#error(self, payload)
180 }
181}
182
183impl PacketObserverProxyInterface for PacketObserverProxy {
184 type ObserveResponseFut =
185 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
186 fn r#observe(&self, mut payload: &DevicePackets) -> Self::ObserveResponseFut {
187 fn _decode(
188 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
189 ) -> Result<(), fidl::Error> {
190 let _response = fidl::client::decode_transaction_body::<
191 fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 0x2a82a5a9a18b79c9,
194 >(_buf?)?
195 .into_result::<PacketObserverMarker>("observe")?;
196 Ok(_response)
197 }
198 self.client.send_query_and_decode::<DevicePackets, ()>(
199 payload,
200 0x2a82a5a9a18b79c9,
201 fidl::encoding::DynamicFlags::FLEXIBLE,
202 _decode,
203 )
204 }
205
206 fn r#error(&self, mut payload: &CaptureError) -> Result<(), fidl::Error> {
207 self.client.send::<CaptureError>(
208 payload,
209 0x6596e43f4f0761e4,
210 fidl::encoding::DynamicFlags::FLEXIBLE,
211 )
212 }
213}
214
215pub struct PacketObserverEventStream {
216 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl std::marker::Unpin for PacketObserverEventStream {}
220
221impl futures::stream::FusedStream for PacketObserverEventStream {
222 fn is_terminated(&self) -> bool {
223 self.event_receiver.is_terminated()
224 }
225}
226
227impl futures::Stream for PacketObserverEventStream {
228 type Item = Result<PacketObserverEvent, fidl::Error>;
229
230 fn poll_next(
231 mut self: std::pin::Pin<&mut Self>,
232 cx: &mut std::task::Context<'_>,
233 ) -> std::task::Poll<Option<Self::Item>> {
234 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
235 &mut self.event_receiver,
236 cx
237 )?) {
238 Some(buf) => std::task::Poll::Ready(Some(PacketObserverEvent::decode(buf))),
239 None => std::task::Poll::Ready(None),
240 }
241 }
242}
243
244#[derive(Debug)]
245pub enum PacketObserverEvent {
246 #[non_exhaustive]
247 _UnknownEvent {
248 ordinal: u64,
250 },
251}
252
253impl PacketObserverEvent {
254 fn decode(
256 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
257 ) -> Result<PacketObserverEvent, fidl::Error> {
258 let (bytes, _handles) = buf.split_mut();
259 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
260 debug_assert_eq!(tx_header.tx_id, 0);
261 match tx_header.ordinal {
262 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
263 Ok(PacketObserverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
264 }
265 _ => Err(fidl::Error::UnknownOrdinal {
266 ordinal: tx_header.ordinal,
267 protocol_name:
268 <PacketObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
269 }),
270 }
271 }
272}
273
274pub struct PacketObserverRequestStream {
276 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
277 is_terminated: bool,
278}
279
280impl std::marker::Unpin for PacketObserverRequestStream {}
281
282impl futures::stream::FusedStream for PacketObserverRequestStream {
283 fn is_terminated(&self) -> bool {
284 self.is_terminated
285 }
286}
287
288impl fidl::endpoints::RequestStream for PacketObserverRequestStream {
289 type Protocol = PacketObserverMarker;
290 type ControlHandle = PacketObserverControlHandle;
291
292 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
293 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
294 }
295
296 fn control_handle(&self) -> Self::ControlHandle {
297 PacketObserverControlHandle { inner: self.inner.clone() }
298 }
299
300 fn into_inner(
301 self,
302 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
303 {
304 (self.inner, self.is_terminated)
305 }
306
307 fn from_inner(
308 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
309 is_terminated: bool,
310 ) -> Self {
311 Self { inner, is_terminated }
312 }
313}
314
315impl futures::Stream for PacketObserverRequestStream {
316 type Item = Result<PacketObserverRequest, fidl::Error>;
317
318 fn poll_next(
319 mut self: std::pin::Pin<&mut Self>,
320 cx: &mut std::task::Context<'_>,
321 ) -> std::task::Poll<Option<Self::Item>> {
322 let this = &mut *self;
323 if this.inner.check_shutdown(cx) {
324 this.is_terminated = true;
325 return std::task::Poll::Ready(None);
326 }
327 if this.is_terminated {
328 panic!("polled PacketObserverRequestStream after completion");
329 }
330 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
331 |bytes, handles| {
332 match this.inner.channel().read_etc(cx, bytes, handles) {
333 std::task::Poll::Ready(Ok(())) => {}
334 std::task::Poll::Pending => return std::task::Poll::Pending,
335 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
336 this.is_terminated = true;
337 return std::task::Poll::Ready(None);
338 }
339 std::task::Poll::Ready(Err(e)) => {
340 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
341 e.into(),
342 ))))
343 }
344 }
345
346 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
348
349 std::task::Poll::Ready(Some(match header.ordinal {
350 0x2a82a5a9a18b79c9 => {
351 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
352 let mut req = fidl::new_empty!(
353 DevicePackets,
354 fidl::encoding::DefaultFuchsiaResourceDialect
355 );
356 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePackets>(&header, _body_bytes, handles, &mut req)?;
357 let control_handle =
358 PacketObserverControlHandle { inner: this.inner.clone() };
359 Ok(PacketObserverRequest::Observe {
360 payload: req,
361 responder: PacketObserverObserveResponder {
362 control_handle: std::mem::ManuallyDrop::new(control_handle),
363 tx_id: header.tx_id,
364 },
365 })
366 }
367 0x6596e43f4f0761e4 => {
368 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
369 let mut req = fidl::new_empty!(
370 CaptureError,
371 fidl::encoding::DefaultFuchsiaResourceDialect
372 );
373 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CaptureError>(&header, _body_bytes, handles, &mut req)?;
374 let control_handle =
375 PacketObserverControlHandle { inner: this.inner.clone() };
376 Ok(PacketObserverRequest::Error { payload: req, control_handle })
377 }
378 _ if header.tx_id == 0
379 && header
380 .dynamic_flags()
381 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
382 {
383 Ok(PacketObserverRequest::_UnknownMethod {
384 ordinal: header.ordinal,
385 control_handle: PacketObserverControlHandle {
386 inner: this.inner.clone(),
387 },
388 method_type: fidl::MethodType::OneWay,
389 })
390 }
391 _ if header
392 .dynamic_flags()
393 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
394 {
395 this.inner.send_framework_err(
396 fidl::encoding::FrameworkErr::UnknownMethod,
397 header.tx_id,
398 header.ordinal,
399 header.dynamic_flags(),
400 (bytes, handles),
401 )?;
402 Ok(PacketObserverRequest::_UnknownMethod {
403 ordinal: header.ordinal,
404 control_handle: PacketObserverControlHandle {
405 inner: this.inner.clone(),
406 },
407 method_type: fidl::MethodType::TwoWay,
408 })
409 }
410 _ => Err(fidl::Error::UnknownOrdinal {
411 ordinal: header.ordinal,
412 protocol_name:
413 <PacketObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
414 }),
415 }))
416 },
417 )
418 }
419}
420
421#[derive(Debug)]
422pub enum PacketObserverRequest {
423 Observe { payload: DevicePackets, responder: PacketObserverObserveResponder },
426 Error { payload: CaptureError, control_handle: PacketObserverControlHandle },
429 #[non_exhaustive]
431 _UnknownMethod {
432 ordinal: u64,
434 control_handle: PacketObserverControlHandle,
435 method_type: fidl::MethodType,
436 },
437}
438
439impl PacketObserverRequest {
440 #[allow(irrefutable_let_patterns)]
441 pub fn into_observe(self) -> Option<(DevicePackets, PacketObserverObserveResponder)> {
442 if let PacketObserverRequest::Observe { payload, responder } = self {
443 Some((payload, responder))
444 } else {
445 None
446 }
447 }
448
449 #[allow(irrefutable_let_patterns)]
450 pub fn into_error(self) -> Option<(CaptureError, PacketObserverControlHandle)> {
451 if let PacketObserverRequest::Error { payload, control_handle } = self {
452 Some((payload, control_handle))
453 } else {
454 None
455 }
456 }
457
458 pub fn method_name(&self) -> &'static str {
460 match *self {
461 PacketObserverRequest::Observe { .. } => "observe",
462 PacketObserverRequest::Error { .. } => "error",
463 PacketObserverRequest::_UnknownMethod {
464 method_type: fidl::MethodType::OneWay, ..
465 } => "unknown one-way method",
466 PacketObserverRequest::_UnknownMethod {
467 method_type: fidl::MethodType::TwoWay, ..
468 } => "unknown two-way method",
469 }
470 }
471}
472
473#[derive(Debug, Clone)]
474pub struct PacketObserverControlHandle {
475 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
476}
477
478impl fidl::endpoints::ControlHandle for PacketObserverControlHandle {
479 fn shutdown(&self) {
480 self.inner.shutdown()
481 }
482 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
483 self.inner.shutdown_with_epitaph(status)
484 }
485
486 fn is_closed(&self) -> bool {
487 self.inner.channel().is_closed()
488 }
489 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
490 self.inner.channel().on_closed()
491 }
492
493 #[cfg(target_os = "fuchsia")]
494 fn signal_peer(
495 &self,
496 clear_mask: zx::Signals,
497 set_mask: zx::Signals,
498 ) -> Result<(), zx_status::Status> {
499 use fidl::Peered;
500 self.inner.channel().signal_peer(clear_mask, set_mask)
501 }
502}
503
504impl PacketObserverControlHandle {}
505
506#[must_use = "FIDL methods require a response to be sent"]
507#[derive(Debug)]
508pub struct PacketObserverObserveResponder {
509 control_handle: std::mem::ManuallyDrop<PacketObserverControlHandle>,
510 tx_id: u32,
511}
512
513impl std::ops::Drop for PacketObserverObserveResponder {
517 fn drop(&mut self) {
518 self.control_handle.shutdown();
519 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
521 }
522}
523
524impl fidl::endpoints::Responder for PacketObserverObserveResponder {
525 type ControlHandle = PacketObserverControlHandle;
526
527 fn control_handle(&self) -> &PacketObserverControlHandle {
528 &self.control_handle
529 }
530
531 fn drop_without_shutdown(mut self) {
532 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
534 std::mem::forget(self);
536 }
537}
538
539impl PacketObserverObserveResponder {
540 pub fn send(self) -> Result<(), fidl::Error> {
544 let _result = self.send_raw();
545 if _result.is_err() {
546 self.control_handle.shutdown();
547 }
548 self.drop_without_shutdown();
549 _result
550 }
551
552 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
554 let _result = self.send_raw();
555 self.drop_without_shutdown();
556 _result
557 }
558
559 fn send_raw(&self) -> Result<(), fidl::Error> {
560 self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
561 fidl::encoding::Flexible::new(()),
562 self.tx_id,
563 0x2a82a5a9a18b79c9,
564 fidl::encoding::DynamicFlags::FLEXIBLE,
565 )
566 }
567}
568
569#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
570pub struct SnoopMarker;
571
572impl fidl::endpoints::ProtocolMarker for SnoopMarker {
573 type Proxy = SnoopProxy;
574 type RequestStream = SnoopRequestStream;
575 #[cfg(target_os = "fuchsia")]
576 type SynchronousProxy = SnoopSynchronousProxy;
577
578 const DEBUG_NAME: &'static str = "fuchsia.bluetooth.snoop.Snoop";
579}
580impl fidl::endpoints::DiscoverableProtocolMarker for SnoopMarker {}
581
582pub trait SnoopProxyInterface: Send + Sync {
583 fn r#start(&self, payload: SnoopStartRequest) -> Result<(), fidl::Error>;
584}
585#[derive(Debug)]
586#[cfg(target_os = "fuchsia")]
587pub struct SnoopSynchronousProxy {
588 client: fidl::client::sync::Client,
589}
590
591#[cfg(target_os = "fuchsia")]
592impl fidl::endpoints::SynchronousProxy for SnoopSynchronousProxy {
593 type Proxy = SnoopProxy;
594 type Protocol = SnoopMarker;
595
596 fn from_channel(inner: fidl::Channel) -> Self {
597 Self::new(inner)
598 }
599
600 fn into_channel(self) -> fidl::Channel {
601 self.client.into_channel()
602 }
603
604 fn as_channel(&self) -> &fidl::Channel {
605 self.client.as_channel()
606 }
607}
608
609#[cfg(target_os = "fuchsia")]
610impl SnoopSynchronousProxy {
611 pub fn new(channel: fidl::Channel) -> Self {
612 let protocol_name = <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
613 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
614 }
615
616 pub fn into_channel(self) -> fidl::Channel {
617 self.client.into_channel()
618 }
619
620 pub fn wait_for_event(
623 &self,
624 deadline: zx::MonotonicInstant,
625 ) -> Result<SnoopEvent, fidl::Error> {
626 SnoopEvent::decode(self.client.wait_for_event(deadline)?)
627 }
628
629 pub fn r#start(&self, mut payload: SnoopStartRequest) -> Result<(), fidl::Error> {
641 self.client.send::<SnoopStartRequest>(
642 &mut payload,
643 0xa520491a4a82f24,
644 fidl::encoding::DynamicFlags::FLEXIBLE,
645 )
646 }
647}
648
649#[cfg(target_os = "fuchsia")]
650impl From<SnoopSynchronousProxy> for zx::Handle {
651 fn from(value: SnoopSynchronousProxy) -> Self {
652 value.into_channel().into()
653 }
654}
655
656#[cfg(target_os = "fuchsia")]
657impl From<fidl::Channel> for SnoopSynchronousProxy {
658 fn from(value: fidl::Channel) -> Self {
659 Self::new(value)
660 }
661}
662
663#[derive(Debug, Clone)]
664pub struct SnoopProxy {
665 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
666}
667
668impl fidl::endpoints::Proxy for SnoopProxy {
669 type Protocol = SnoopMarker;
670
671 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
672 Self::new(inner)
673 }
674
675 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
676 self.client.into_channel().map_err(|client| Self { client })
677 }
678
679 fn as_channel(&self) -> &::fidl::AsyncChannel {
680 self.client.as_channel()
681 }
682}
683
684impl SnoopProxy {
685 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
687 let protocol_name = <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
688 Self { client: fidl::client::Client::new(channel, protocol_name) }
689 }
690
691 pub fn take_event_stream(&self) -> SnoopEventStream {
697 SnoopEventStream { event_receiver: self.client.take_event_receiver() }
698 }
699
700 pub fn r#start(&self, mut payload: SnoopStartRequest) -> Result<(), fidl::Error> {
712 SnoopProxyInterface::r#start(self, payload)
713 }
714}
715
716impl SnoopProxyInterface for SnoopProxy {
717 fn r#start(&self, mut payload: SnoopStartRequest) -> Result<(), fidl::Error> {
718 self.client.send::<SnoopStartRequest>(
719 &mut payload,
720 0xa520491a4a82f24,
721 fidl::encoding::DynamicFlags::FLEXIBLE,
722 )
723 }
724}
725
726pub struct SnoopEventStream {
727 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
728}
729
730impl std::marker::Unpin for SnoopEventStream {}
731
732impl futures::stream::FusedStream for SnoopEventStream {
733 fn is_terminated(&self) -> bool {
734 self.event_receiver.is_terminated()
735 }
736}
737
738impl futures::Stream for SnoopEventStream {
739 type Item = Result<SnoopEvent, fidl::Error>;
740
741 fn poll_next(
742 mut self: std::pin::Pin<&mut Self>,
743 cx: &mut std::task::Context<'_>,
744 ) -> std::task::Poll<Option<Self::Item>> {
745 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
746 &mut self.event_receiver,
747 cx
748 )?) {
749 Some(buf) => std::task::Poll::Ready(Some(SnoopEvent::decode(buf))),
750 None => std::task::Poll::Ready(None),
751 }
752 }
753}
754
755#[derive(Debug)]
756pub enum SnoopEvent {
757 #[non_exhaustive]
758 _UnknownEvent {
759 ordinal: u64,
761 },
762}
763
764impl SnoopEvent {
765 fn decode(
767 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
768 ) -> Result<SnoopEvent, fidl::Error> {
769 let (bytes, _handles) = buf.split_mut();
770 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
771 debug_assert_eq!(tx_header.tx_id, 0);
772 match tx_header.ordinal {
773 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
774 Ok(SnoopEvent::_UnknownEvent { ordinal: tx_header.ordinal })
775 }
776 _ => Err(fidl::Error::UnknownOrdinal {
777 ordinal: tx_header.ordinal,
778 protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
779 }),
780 }
781 }
782}
783
784pub struct SnoopRequestStream {
786 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
787 is_terminated: bool,
788}
789
790impl std::marker::Unpin for SnoopRequestStream {}
791
792impl futures::stream::FusedStream for SnoopRequestStream {
793 fn is_terminated(&self) -> bool {
794 self.is_terminated
795 }
796}
797
798impl fidl::endpoints::RequestStream for SnoopRequestStream {
799 type Protocol = SnoopMarker;
800 type ControlHandle = SnoopControlHandle;
801
802 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
803 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
804 }
805
806 fn control_handle(&self) -> Self::ControlHandle {
807 SnoopControlHandle { inner: self.inner.clone() }
808 }
809
810 fn into_inner(
811 self,
812 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
813 {
814 (self.inner, self.is_terminated)
815 }
816
817 fn from_inner(
818 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
819 is_terminated: bool,
820 ) -> Self {
821 Self { inner, is_terminated }
822 }
823}
824
825impl futures::Stream for SnoopRequestStream {
826 type Item = Result<SnoopRequest, fidl::Error>;
827
828 fn poll_next(
829 mut self: std::pin::Pin<&mut Self>,
830 cx: &mut std::task::Context<'_>,
831 ) -> std::task::Poll<Option<Self::Item>> {
832 let this = &mut *self;
833 if this.inner.check_shutdown(cx) {
834 this.is_terminated = true;
835 return std::task::Poll::Ready(None);
836 }
837 if this.is_terminated {
838 panic!("polled SnoopRequestStream after completion");
839 }
840 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
841 |bytes, handles| {
842 match this.inner.channel().read_etc(cx, bytes, handles) {
843 std::task::Poll::Ready(Ok(())) => {}
844 std::task::Poll::Pending => return std::task::Poll::Pending,
845 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
846 this.is_terminated = true;
847 return std::task::Poll::Ready(None);
848 }
849 std::task::Poll::Ready(Err(e)) => {
850 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
851 e.into(),
852 ))))
853 }
854 }
855
856 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
858
859 std::task::Poll::Ready(Some(match header.ordinal {
860 0xa520491a4a82f24 => {
861 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
862 let mut req = fidl::new_empty!(
863 SnoopStartRequest,
864 fidl::encoding::DefaultFuchsiaResourceDialect
865 );
866 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopStartRequest>(&header, _body_bytes, handles, &mut req)?;
867 let control_handle = SnoopControlHandle { inner: this.inner.clone() };
868 Ok(SnoopRequest::Start { payload: req, control_handle })
869 }
870 _ if header.tx_id == 0
871 && header
872 .dynamic_flags()
873 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
874 {
875 Ok(SnoopRequest::_UnknownMethod {
876 ordinal: header.ordinal,
877 control_handle: SnoopControlHandle { inner: this.inner.clone() },
878 method_type: fidl::MethodType::OneWay,
879 })
880 }
881 _ if header
882 .dynamic_flags()
883 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
884 {
885 this.inner.send_framework_err(
886 fidl::encoding::FrameworkErr::UnknownMethod,
887 header.tx_id,
888 header.ordinal,
889 header.dynamic_flags(),
890 (bytes, handles),
891 )?;
892 Ok(SnoopRequest::_UnknownMethod {
893 ordinal: header.ordinal,
894 control_handle: SnoopControlHandle { inner: this.inner.clone() },
895 method_type: fidl::MethodType::TwoWay,
896 })
897 }
898 _ => Err(fidl::Error::UnknownOrdinal {
899 ordinal: header.ordinal,
900 protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
901 }),
902 }))
903 },
904 )
905 }
906}
907
908#[derive(Debug)]
910pub enum SnoopRequest {
911 Start { payload: SnoopStartRequest, control_handle: SnoopControlHandle },
923 #[non_exhaustive]
925 _UnknownMethod {
926 ordinal: u64,
928 control_handle: SnoopControlHandle,
929 method_type: fidl::MethodType,
930 },
931}
932
933impl SnoopRequest {
934 #[allow(irrefutable_let_patterns)]
935 pub fn into_start(self) -> Option<(SnoopStartRequest, SnoopControlHandle)> {
936 if let SnoopRequest::Start { payload, control_handle } = self {
937 Some((payload, control_handle))
938 } else {
939 None
940 }
941 }
942
943 pub fn method_name(&self) -> &'static str {
945 match *self {
946 SnoopRequest::Start { .. } => "start",
947 SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
948 "unknown one-way method"
949 }
950 SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
951 "unknown two-way method"
952 }
953 }
954 }
955}
956
957#[derive(Debug, Clone)]
958pub struct SnoopControlHandle {
959 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
960}
961
962impl fidl::endpoints::ControlHandle for SnoopControlHandle {
963 fn shutdown(&self) {
964 self.inner.shutdown()
965 }
966 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
967 self.inner.shutdown_with_epitaph(status)
968 }
969
970 fn is_closed(&self) -> bool {
971 self.inner.channel().is_closed()
972 }
973 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
974 self.inner.channel().on_closed()
975 }
976
977 #[cfg(target_os = "fuchsia")]
978 fn signal_peer(
979 &self,
980 clear_mask: zx::Signals,
981 set_mask: zx::Signals,
982 ) -> Result<(), zx_status::Status> {
983 use fidl::Peered;
984 self.inner.channel().signal_peer(clear_mask, set_mask)
985 }
986}
987
988impl SnoopControlHandle {}
989
990mod internal {
991 use super::*;
992
993 impl SnoopStartRequest {
994 #[inline(always)]
995 fn max_ordinal_present(&self) -> u64 {
996 if let Some(_) = self.client {
997 return 3;
998 }
999 if let Some(_) = self.host_device {
1000 return 2;
1001 }
1002 if let Some(_) = self.follow {
1003 return 1;
1004 }
1005 0
1006 }
1007 }
1008
1009 impl fidl::encoding::ResourceTypeMarker for SnoopStartRequest {
1010 type Borrowed<'a> = &'a mut Self;
1011 fn take_or_borrow<'a>(
1012 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1013 ) -> Self::Borrowed<'a> {
1014 value
1015 }
1016 }
1017
1018 unsafe impl fidl::encoding::TypeMarker for SnoopStartRequest {
1019 type Owned = Self;
1020
1021 #[inline(always)]
1022 fn inline_align(_context: fidl::encoding::Context) -> usize {
1023 8
1024 }
1025
1026 #[inline(always)]
1027 fn inline_size(_context: fidl::encoding::Context) -> usize {
1028 16
1029 }
1030 }
1031
1032 unsafe impl
1033 fidl::encoding::Encode<SnoopStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1034 for &mut SnoopStartRequest
1035 {
1036 unsafe fn encode(
1037 self,
1038 encoder: &mut fidl::encoding::Encoder<
1039 '_,
1040 fidl::encoding::DefaultFuchsiaResourceDialect,
1041 >,
1042 offset: usize,
1043 mut depth: fidl::encoding::Depth,
1044 ) -> fidl::Result<()> {
1045 encoder.debug_check_bounds::<SnoopStartRequest>(offset);
1046 let max_ordinal: u64 = self.max_ordinal_present();
1048 encoder.write_num(max_ordinal, offset);
1049 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1050 if max_ordinal == 0 {
1052 return Ok(());
1053 }
1054 depth.increment()?;
1055 let envelope_size = 8;
1056 let bytes_len = max_ordinal as usize * envelope_size;
1057 #[allow(unused_variables)]
1058 let offset = encoder.out_of_line_offset(bytes_len);
1059 let mut _prev_end_offset: usize = 0;
1060 if 1 > max_ordinal {
1061 return Ok(());
1062 }
1063
1064 let cur_offset: usize = (1 - 1) * envelope_size;
1067
1068 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1070
1071 fidl::encoding::encode_in_envelope_optional::<
1076 bool,
1077 fidl::encoding::DefaultFuchsiaResourceDialect,
1078 >(
1079 self.follow.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1080 encoder,
1081 offset + cur_offset,
1082 depth,
1083 )?;
1084
1085 _prev_end_offset = cur_offset + envelope_size;
1086 if 2 > max_ordinal {
1087 return Ok(());
1088 }
1089
1090 let cur_offset: usize = (2 - 1) * envelope_size;
1093
1094 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1096
1097 fidl::encoding::encode_in_envelope_optional::<
1102 fidl::encoding::BoundedString<255>,
1103 fidl::encoding::DefaultFuchsiaResourceDialect,
1104 >(
1105 self.host_device.as_ref().map(
1106 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
1107 ),
1108 encoder,
1109 offset + cur_offset,
1110 depth,
1111 )?;
1112
1113 _prev_end_offset = cur_offset + envelope_size;
1114 if 3 > max_ordinal {
1115 return Ok(());
1116 }
1117
1118 let cur_offset: usize = (3 - 1) * envelope_size;
1121
1122 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1124
1125 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PacketObserverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1130 self.client.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PacketObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1131 encoder, offset + cur_offset, depth
1132 )?;
1133
1134 _prev_end_offset = cur_offset + envelope_size;
1135
1136 Ok(())
1137 }
1138 }
1139
1140 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1141 for SnoopStartRequest
1142 {
1143 #[inline(always)]
1144 fn new_empty() -> Self {
1145 Self::default()
1146 }
1147
1148 unsafe fn decode(
1149 &mut self,
1150 decoder: &mut fidl::encoding::Decoder<
1151 '_,
1152 fidl::encoding::DefaultFuchsiaResourceDialect,
1153 >,
1154 offset: usize,
1155 mut depth: fidl::encoding::Depth,
1156 ) -> fidl::Result<()> {
1157 decoder.debug_check_bounds::<Self>(offset);
1158 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1159 None => return Err(fidl::Error::NotNullable),
1160 Some(len) => len,
1161 };
1162 if len == 0 {
1164 return Ok(());
1165 };
1166 depth.increment()?;
1167 let envelope_size = 8;
1168 let bytes_len = len * envelope_size;
1169 let offset = decoder.out_of_line_offset(bytes_len)?;
1170 let mut _next_ordinal_to_read = 0;
1172 let mut next_offset = offset;
1173 let end_offset = offset + bytes_len;
1174 _next_ordinal_to_read += 1;
1175 if next_offset >= end_offset {
1176 return Ok(());
1177 }
1178
1179 while _next_ordinal_to_read < 1 {
1181 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1182 _next_ordinal_to_read += 1;
1183 next_offset += envelope_size;
1184 }
1185
1186 let next_out_of_line = decoder.next_out_of_line();
1187 let handles_before = decoder.remaining_handles();
1188 if let Some((inlined, num_bytes, num_handles)) =
1189 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1190 {
1191 let member_inline_size =
1192 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1193 if inlined != (member_inline_size <= 4) {
1194 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1195 }
1196 let inner_offset;
1197 let mut inner_depth = depth.clone();
1198 if inlined {
1199 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1200 inner_offset = next_offset;
1201 } else {
1202 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1203 inner_depth.increment()?;
1204 }
1205 let val_ref = self.follow.get_or_insert_with(|| {
1206 fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1207 });
1208 fidl::decode!(
1209 bool,
1210 fidl::encoding::DefaultFuchsiaResourceDialect,
1211 val_ref,
1212 decoder,
1213 inner_offset,
1214 inner_depth
1215 )?;
1216 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1217 {
1218 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1219 }
1220 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1221 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1222 }
1223 }
1224
1225 next_offset += envelope_size;
1226 _next_ordinal_to_read += 1;
1227 if next_offset >= end_offset {
1228 return Ok(());
1229 }
1230
1231 while _next_ordinal_to_read < 2 {
1233 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1234 _next_ordinal_to_read += 1;
1235 next_offset += envelope_size;
1236 }
1237
1238 let next_out_of_line = decoder.next_out_of_line();
1239 let handles_before = decoder.remaining_handles();
1240 if let Some((inlined, num_bytes, num_handles)) =
1241 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1242 {
1243 let member_inline_size =
1244 <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
1245 decoder.context,
1246 );
1247 if inlined != (member_inline_size <= 4) {
1248 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1249 }
1250 let inner_offset;
1251 let mut inner_depth = depth.clone();
1252 if inlined {
1253 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1254 inner_offset = next_offset;
1255 } else {
1256 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1257 inner_depth.increment()?;
1258 }
1259 let val_ref = self.host_device.get_or_insert_with(|| {
1260 fidl::new_empty!(
1261 fidl::encoding::BoundedString<255>,
1262 fidl::encoding::DefaultFuchsiaResourceDialect
1263 )
1264 });
1265 fidl::decode!(
1266 fidl::encoding::BoundedString<255>,
1267 fidl::encoding::DefaultFuchsiaResourceDialect,
1268 val_ref,
1269 decoder,
1270 inner_offset,
1271 inner_depth
1272 )?;
1273 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1274 {
1275 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1276 }
1277 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1278 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1279 }
1280 }
1281
1282 next_offset += envelope_size;
1283 _next_ordinal_to_read += 1;
1284 if next_offset >= end_offset {
1285 return Ok(());
1286 }
1287
1288 while _next_ordinal_to_read < 3 {
1290 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1291 _next_ordinal_to_read += 1;
1292 next_offset += envelope_size;
1293 }
1294
1295 let next_out_of_line = decoder.next_out_of_line();
1296 let handles_before = decoder.remaining_handles();
1297 if let Some((inlined, num_bytes, num_handles)) =
1298 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1299 {
1300 let member_inline_size = <fidl::encoding::Endpoint<
1301 fidl::endpoints::ClientEnd<PacketObserverMarker>,
1302 > as fidl::encoding::TypeMarker>::inline_size(
1303 decoder.context
1304 );
1305 if inlined != (member_inline_size <= 4) {
1306 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1307 }
1308 let inner_offset;
1309 let mut inner_depth = depth.clone();
1310 if inlined {
1311 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1312 inner_offset = next_offset;
1313 } else {
1314 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1315 inner_depth.increment()?;
1316 }
1317 let val_ref = self.client.get_or_insert_with(|| {
1318 fidl::new_empty!(
1319 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PacketObserverMarker>>,
1320 fidl::encoding::DefaultFuchsiaResourceDialect
1321 )
1322 });
1323 fidl::decode!(
1324 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PacketObserverMarker>>,
1325 fidl::encoding::DefaultFuchsiaResourceDialect,
1326 val_ref,
1327 decoder,
1328 inner_offset,
1329 inner_depth
1330 )?;
1331 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1332 {
1333 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1334 }
1335 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1336 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1337 }
1338 }
1339
1340 next_offset += envelope_size;
1341
1342 while next_offset < end_offset {
1344 _next_ordinal_to_read += 1;
1345 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1346 next_offset += envelope_size;
1347 }
1348
1349 Ok(())
1350 }
1351 }
1352}