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_masquerade__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct FactoryCreateRequest {
16 pub config: ControlConfig,
17 pub control: fidl::endpoints::ServerEnd<ControlMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FactoryCreateRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct ControlMarker;
24
25impl fidl::endpoints::ProtocolMarker for ControlMarker {
26 type Proxy = ControlProxy;
27 type RequestStream = ControlRequestStream;
28 #[cfg(target_os = "fuchsia")]
29 type SynchronousProxy = ControlSynchronousProxy;
30
31 const DEBUG_NAME: &'static str = "(anonymous) Control";
32}
33pub type ControlSetEnabledResult = Result<bool, Error>;
34
35pub trait ControlProxyInterface: Send + Sync {
36 type SetEnabledResponseFut: std::future::Future<Output = Result<ControlSetEnabledResult, fidl::Error>>
37 + Send;
38 fn r#set_enabled(&self, enabled: bool) -> Self::SetEnabledResponseFut;
39}
40#[derive(Debug)]
41#[cfg(target_os = "fuchsia")]
42pub struct ControlSynchronousProxy {
43 client: fidl::client::sync::Client,
44}
45
46#[cfg(target_os = "fuchsia")]
47impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
48 type Proxy = ControlProxy;
49 type Protocol = ControlMarker;
50
51 fn from_channel(inner: fidl::Channel) -> Self {
52 Self::new(inner)
53 }
54
55 fn into_channel(self) -> fidl::Channel {
56 self.client.into_channel()
57 }
58
59 fn as_channel(&self) -> &fidl::Channel {
60 self.client.as_channel()
61 }
62}
63
64#[cfg(target_os = "fuchsia")]
65impl ControlSynchronousProxy {
66 pub fn new(channel: fidl::Channel) -> Self {
67 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
68 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
69 }
70
71 pub fn into_channel(self) -> fidl::Channel {
72 self.client.into_channel()
73 }
74
75 pub fn wait_for_event(
78 &self,
79 deadline: zx::MonotonicInstant,
80 ) -> Result<ControlEvent, fidl::Error> {
81 ControlEvent::decode(self.client.wait_for_event(deadline)?)
82 }
83
84 pub fn r#set_enabled(
91 &self,
92 mut enabled: bool,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<ControlSetEnabledResult, fidl::Error> {
95 let _response = self.client.send_query::<
96 ControlSetEnabledRequest,
97 fidl::encoding::ResultType<ControlSetEnabledResponse, Error>,
98 >(
99 (enabled,),
100 0x13b7914afdb709a6,
101 fidl::encoding::DynamicFlags::empty(),
102 ___deadline,
103 )?;
104 Ok(_response.map(|x| x.was_enabled))
105 }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<ControlSynchronousProxy> for zx::NullableHandle {
110 fn from(value: ControlSynchronousProxy) -> Self {
111 value.into_channel().into()
112 }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for ControlSynchronousProxy {
117 fn from(value: fidl::Channel) -> Self {
118 Self::new(value)
119 }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for ControlSynchronousProxy {
124 type Protocol = ControlMarker;
125
126 fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
127 Self::new(value.into_channel())
128 }
129}
130
131#[derive(Debug, Clone)]
132pub struct ControlProxy {
133 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for ControlProxy {
137 type Protocol = ControlMarker;
138
139 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140 Self::new(inner)
141 }
142
143 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144 self.client.into_channel().map_err(|client| Self { client })
145 }
146
147 fn as_channel(&self) -> &::fidl::AsyncChannel {
148 self.client.as_channel()
149 }
150}
151
152impl ControlProxy {
153 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156 Self { client: fidl::client::Client::new(channel, protocol_name) }
157 }
158
159 pub fn take_event_stream(&self) -> ControlEventStream {
165 ControlEventStream { event_receiver: self.client.take_event_receiver() }
166 }
167
168 pub fn r#set_enabled(
175 &self,
176 mut enabled: bool,
177 ) -> fidl::client::QueryResponseFut<
178 ControlSetEnabledResult,
179 fidl::encoding::DefaultFuchsiaResourceDialect,
180 > {
181 ControlProxyInterface::r#set_enabled(self, enabled)
182 }
183}
184
185impl ControlProxyInterface for ControlProxy {
186 type SetEnabledResponseFut = fidl::client::QueryResponseFut<
187 ControlSetEnabledResult,
188 fidl::encoding::DefaultFuchsiaResourceDialect,
189 >;
190 fn r#set_enabled(&self, mut enabled: bool) -> Self::SetEnabledResponseFut {
191 fn _decode(
192 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
193 ) -> Result<ControlSetEnabledResult, fidl::Error> {
194 let _response = fidl::client::decode_transaction_body::<
195 fidl::encoding::ResultType<ControlSetEnabledResponse, Error>,
196 fidl::encoding::DefaultFuchsiaResourceDialect,
197 0x13b7914afdb709a6,
198 >(_buf?)?;
199 Ok(_response.map(|x| x.was_enabled))
200 }
201 self.client.send_query_and_decode::<ControlSetEnabledRequest, ControlSetEnabledResult>(
202 (enabled,),
203 0x13b7914afdb709a6,
204 fidl::encoding::DynamicFlags::empty(),
205 _decode,
206 )
207 }
208}
209
210pub struct ControlEventStream {
211 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
212}
213
214impl std::marker::Unpin for ControlEventStream {}
215
216impl futures::stream::FusedStream for ControlEventStream {
217 fn is_terminated(&self) -> bool {
218 self.event_receiver.is_terminated()
219 }
220}
221
222impl futures::Stream for ControlEventStream {
223 type Item = Result<ControlEvent, fidl::Error>;
224
225 fn poll_next(
226 mut self: std::pin::Pin<&mut Self>,
227 cx: &mut std::task::Context<'_>,
228 ) -> std::task::Poll<Option<Self::Item>> {
229 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
230 &mut self.event_receiver,
231 cx
232 )?) {
233 Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
234 None => std::task::Poll::Ready(None),
235 }
236 }
237}
238
239#[derive(Debug)]
240pub enum ControlEvent {}
241
242impl ControlEvent {
243 fn decode(
245 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
246 ) -> Result<ControlEvent, fidl::Error> {
247 let (bytes, _handles) = buf.split_mut();
248 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
249 debug_assert_eq!(tx_header.tx_id, 0);
250 match tx_header.ordinal {
251 _ => Err(fidl::Error::UnknownOrdinal {
252 ordinal: tx_header.ordinal,
253 protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
254 }),
255 }
256 }
257}
258
259pub struct ControlRequestStream {
261 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
262 is_terminated: bool,
263}
264
265impl std::marker::Unpin for ControlRequestStream {}
266
267impl futures::stream::FusedStream for ControlRequestStream {
268 fn is_terminated(&self) -> bool {
269 self.is_terminated
270 }
271}
272
273impl fidl::endpoints::RequestStream for ControlRequestStream {
274 type Protocol = ControlMarker;
275 type ControlHandle = ControlControlHandle;
276
277 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
278 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
279 }
280
281 fn control_handle(&self) -> Self::ControlHandle {
282 ControlControlHandle { inner: self.inner.clone() }
283 }
284
285 fn into_inner(
286 self,
287 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
288 {
289 (self.inner, self.is_terminated)
290 }
291
292 fn from_inner(
293 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
294 is_terminated: bool,
295 ) -> Self {
296 Self { inner, is_terminated }
297 }
298}
299
300impl futures::Stream for ControlRequestStream {
301 type Item = Result<ControlRequest, fidl::Error>;
302
303 fn poll_next(
304 mut self: std::pin::Pin<&mut Self>,
305 cx: &mut std::task::Context<'_>,
306 ) -> std::task::Poll<Option<Self::Item>> {
307 let this = &mut *self;
308 if this.inner.check_shutdown(cx) {
309 this.is_terminated = true;
310 return std::task::Poll::Ready(None);
311 }
312 if this.is_terminated {
313 panic!("polled ControlRequestStream after completion");
314 }
315 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
316 |bytes, handles| {
317 match this.inner.channel().read_etc(cx, bytes, handles) {
318 std::task::Poll::Ready(Ok(())) => {}
319 std::task::Poll::Pending => return std::task::Poll::Pending,
320 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
321 this.is_terminated = true;
322 return std::task::Poll::Ready(None);
323 }
324 std::task::Poll::Ready(Err(e)) => {
325 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
326 e.into(),
327 ))));
328 }
329 }
330
331 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
333
334 std::task::Poll::Ready(Some(match header.ordinal {
335 0x13b7914afdb709a6 => {
336 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
337 let mut req = fidl::new_empty!(
338 ControlSetEnabledRequest,
339 fidl::encoding::DefaultFuchsiaResourceDialect
340 );
341 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetEnabledRequest>(&header, _body_bytes, handles, &mut req)?;
342 let control_handle = ControlControlHandle { inner: this.inner.clone() };
343 Ok(ControlRequest::SetEnabled {
344 enabled: req.enabled,
345
346 responder: ControlSetEnabledResponder {
347 control_handle: std::mem::ManuallyDrop::new(control_handle),
348 tx_id: header.tx_id,
349 },
350 })
351 }
352 _ => Err(fidl::Error::UnknownOrdinal {
353 ordinal: header.ordinal,
354 protocol_name:
355 <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
356 }),
357 }))
358 },
359 )
360 }
361}
362
363#[derive(Debug)]
369pub enum ControlRequest {
370 SetEnabled { enabled: bool, responder: ControlSetEnabledResponder },
377}
378
379impl ControlRequest {
380 #[allow(irrefutable_let_patterns)]
381 pub fn into_set_enabled(self) -> Option<(bool, ControlSetEnabledResponder)> {
382 if let ControlRequest::SetEnabled { enabled, responder } = self {
383 Some((enabled, responder))
384 } else {
385 None
386 }
387 }
388
389 pub fn method_name(&self) -> &'static str {
391 match *self {
392 ControlRequest::SetEnabled { .. } => "set_enabled",
393 }
394 }
395}
396
397#[derive(Debug, Clone)]
398pub struct ControlControlHandle {
399 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
400}
401
402impl fidl::endpoints::ControlHandle for ControlControlHandle {
403 fn shutdown(&self) {
404 self.inner.shutdown()
405 }
406
407 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
408 self.inner.shutdown_with_epitaph(status)
409 }
410
411 fn is_closed(&self) -> bool {
412 self.inner.channel().is_closed()
413 }
414 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
415 self.inner.channel().on_closed()
416 }
417
418 #[cfg(target_os = "fuchsia")]
419 fn signal_peer(
420 &self,
421 clear_mask: zx::Signals,
422 set_mask: zx::Signals,
423 ) -> Result<(), zx_status::Status> {
424 use fidl::Peered;
425 self.inner.channel().signal_peer(clear_mask, set_mask)
426 }
427}
428
429impl ControlControlHandle {}
430
431#[must_use = "FIDL methods require a response to be sent"]
432#[derive(Debug)]
433pub struct ControlSetEnabledResponder {
434 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
435 tx_id: u32,
436}
437
438impl std::ops::Drop for ControlSetEnabledResponder {
442 fn drop(&mut self) {
443 self.control_handle.shutdown();
444 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
446 }
447}
448
449impl fidl::endpoints::Responder for ControlSetEnabledResponder {
450 type ControlHandle = ControlControlHandle;
451
452 fn control_handle(&self) -> &ControlControlHandle {
453 &self.control_handle
454 }
455
456 fn drop_without_shutdown(mut self) {
457 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
459 std::mem::forget(self);
461 }
462}
463
464impl ControlSetEnabledResponder {
465 pub fn send(self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
469 let _result = self.send_raw(result);
470 if _result.is_err() {
471 self.control_handle.shutdown();
472 }
473 self.drop_without_shutdown();
474 _result
475 }
476
477 pub fn send_no_shutdown_on_err(
479 self,
480 mut result: Result<bool, Error>,
481 ) -> Result<(), fidl::Error> {
482 let _result = self.send_raw(result);
483 self.drop_without_shutdown();
484 _result
485 }
486
487 fn send_raw(&self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
488 self.control_handle
489 .inner
490 .send::<fidl::encoding::ResultType<ControlSetEnabledResponse, Error>>(
491 result.map(|was_enabled| (was_enabled,)),
492 self.tx_id,
493 0x13b7914afdb709a6,
494 fidl::encoding::DynamicFlags::empty(),
495 )
496 }
497}
498
499#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
500pub struct FactoryMarker;
501
502impl fidl::endpoints::ProtocolMarker for FactoryMarker {
503 type Proxy = FactoryProxy;
504 type RequestStream = FactoryRequestStream;
505 #[cfg(target_os = "fuchsia")]
506 type SynchronousProxy = FactorySynchronousProxy;
507
508 const DEBUG_NAME: &'static str = "fuchsia.net.masquerade.Factory";
509}
510impl fidl::endpoints::DiscoverableProtocolMarker for FactoryMarker {}
511pub type FactoryCreateResult = Result<(), Error>;
512
513pub trait FactoryProxyInterface: Send + Sync {
514 type CreateResponseFut: std::future::Future<Output = Result<FactoryCreateResult, fidl::Error>>
515 + Send;
516 fn r#create(
517 &self,
518 config: &ControlConfig,
519 control: fidl::endpoints::ServerEnd<ControlMarker>,
520 ) -> Self::CreateResponseFut;
521}
522#[derive(Debug)]
523#[cfg(target_os = "fuchsia")]
524pub struct FactorySynchronousProxy {
525 client: fidl::client::sync::Client,
526}
527
528#[cfg(target_os = "fuchsia")]
529impl fidl::endpoints::SynchronousProxy for FactorySynchronousProxy {
530 type Proxy = FactoryProxy;
531 type Protocol = FactoryMarker;
532
533 fn from_channel(inner: fidl::Channel) -> Self {
534 Self::new(inner)
535 }
536
537 fn into_channel(self) -> fidl::Channel {
538 self.client.into_channel()
539 }
540
541 fn as_channel(&self) -> &fidl::Channel {
542 self.client.as_channel()
543 }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl FactorySynchronousProxy {
548 pub fn new(channel: fidl::Channel) -> Self {
549 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
550 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
551 }
552
553 pub fn into_channel(self) -> fidl::Channel {
554 self.client.into_channel()
555 }
556
557 pub fn wait_for_event(
560 &self,
561 deadline: zx::MonotonicInstant,
562 ) -> Result<FactoryEvent, fidl::Error> {
563 FactoryEvent::decode(self.client.wait_for_event(deadline)?)
564 }
565
566 pub fn r#create(
581 &self,
582 mut config: &ControlConfig,
583 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
584 ___deadline: zx::MonotonicInstant,
585 ) -> Result<FactoryCreateResult, fidl::Error> {
586 let _response = self.client.send_query::<FactoryCreateRequest, fidl::encoding::ResultType<
587 fidl::encoding::EmptyStruct,
588 Error,
589 >>(
590 (config, control),
591 0x65f64a124fd0170e,
592 fidl::encoding::DynamicFlags::empty(),
593 ___deadline,
594 )?;
595 Ok(_response.map(|x| x))
596 }
597}
598
599#[cfg(target_os = "fuchsia")]
600impl From<FactorySynchronousProxy> for zx::NullableHandle {
601 fn from(value: FactorySynchronousProxy) -> Self {
602 value.into_channel().into()
603 }
604}
605
606#[cfg(target_os = "fuchsia")]
607impl From<fidl::Channel> for FactorySynchronousProxy {
608 fn from(value: fidl::Channel) -> Self {
609 Self::new(value)
610 }
611}
612
613#[cfg(target_os = "fuchsia")]
614impl fidl::endpoints::FromClient for FactorySynchronousProxy {
615 type Protocol = FactoryMarker;
616
617 fn from_client(value: fidl::endpoints::ClientEnd<FactoryMarker>) -> Self {
618 Self::new(value.into_channel())
619 }
620}
621
622#[derive(Debug, Clone)]
623pub struct FactoryProxy {
624 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
625}
626
627impl fidl::endpoints::Proxy for FactoryProxy {
628 type Protocol = FactoryMarker;
629
630 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
631 Self::new(inner)
632 }
633
634 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
635 self.client.into_channel().map_err(|client| Self { client })
636 }
637
638 fn as_channel(&self) -> &::fidl::AsyncChannel {
639 self.client.as_channel()
640 }
641}
642
643impl FactoryProxy {
644 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
646 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
647 Self { client: fidl::client::Client::new(channel, protocol_name) }
648 }
649
650 pub fn take_event_stream(&self) -> FactoryEventStream {
656 FactoryEventStream { event_receiver: self.client.take_event_receiver() }
657 }
658
659 pub fn r#create(
674 &self,
675 mut config: &ControlConfig,
676 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
677 ) -> fidl::client::QueryResponseFut<
678 FactoryCreateResult,
679 fidl::encoding::DefaultFuchsiaResourceDialect,
680 > {
681 FactoryProxyInterface::r#create(self, config, control)
682 }
683}
684
685impl FactoryProxyInterface for FactoryProxy {
686 type CreateResponseFut = fidl::client::QueryResponseFut<
687 FactoryCreateResult,
688 fidl::encoding::DefaultFuchsiaResourceDialect,
689 >;
690 fn r#create(
691 &self,
692 mut config: &ControlConfig,
693 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
694 ) -> Self::CreateResponseFut {
695 fn _decode(
696 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
697 ) -> Result<FactoryCreateResult, fidl::Error> {
698 let _response = fidl::client::decode_transaction_body::<
699 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
700 fidl::encoding::DefaultFuchsiaResourceDialect,
701 0x65f64a124fd0170e,
702 >(_buf?)?;
703 Ok(_response.map(|x| x))
704 }
705 self.client.send_query_and_decode::<FactoryCreateRequest, FactoryCreateResult>(
706 (config, control),
707 0x65f64a124fd0170e,
708 fidl::encoding::DynamicFlags::empty(),
709 _decode,
710 )
711 }
712}
713
714pub struct FactoryEventStream {
715 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
716}
717
718impl std::marker::Unpin for FactoryEventStream {}
719
720impl futures::stream::FusedStream for FactoryEventStream {
721 fn is_terminated(&self) -> bool {
722 self.event_receiver.is_terminated()
723 }
724}
725
726impl futures::Stream for FactoryEventStream {
727 type Item = Result<FactoryEvent, fidl::Error>;
728
729 fn poll_next(
730 mut self: std::pin::Pin<&mut Self>,
731 cx: &mut std::task::Context<'_>,
732 ) -> std::task::Poll<Option<Self::Item>> {
733 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
734 &mut self.event_receiver,
735 cx
736 )?) {
737 Some(buf) => std::task::Poll::Ready(Some(FactoryEvent::decode(buf))),
738 None => std::task::Poll::Ready(None),
739 }
740 }
741}
742
743#[derive(Debug)]
744pub enum FactoryEvent {}
745
746impl FactoryEvent {
747 fn decode(
749 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
750 ) -> Result<FactoryEvent, fidl::Error> {
751 let (bytes, _handles) = buf.split_mut();
752 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
753 debug_assert_eq!(tx_header.tx_id, 0);
754 match tx_header.ordinal {
755 _ => Err(fidl::Error::UnknownOrdinal {
756 ordinal: tx_header.ordinal,
757 protocol_name: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
758 }),
759 }
760 }
761}
762
763pub struct FactoryRequestStream {
765 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
766 is_terminated: bool,
767}
768
769impl std::marker::Unpin for FactoryRequestStream {}
770
771impl futures::stream::FusedStream for FactoryRequestStream {
772 fn is_terminated(&self) -> bool {
773 self.is_terminated
774 }
775}
776
777impl fidl::endpoints::RequestStream for FactoryRequestStream {
778 type Protocol = FactoryMarker;
779 type ControlHandle = FactoryControlHandle;
780
781 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
782 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
783 }
784
785 fn control_handle(&self) -> Self::ControlHandle {
786 FactoryControlHandle { inner: self.inner.clone() }
787 }
788
789 fn into_inner(
790 self,
791 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
792 {
793 (self.inner, self.is_terminated)
794 }
795
796 fn from_inner(
797 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
798 is_terminated: bool,
799 ) -> Self {
800 Self { inner, is_terminated }
801 }
802}
803
804impl futures::Stream for FactoryRequestStream {
805 type Item = Result<FactoryRequest, fidl::Error>;
806
807 fn poll_next(
808 mut self: std::pin::Pin<&mut Self>,
809 cx: &mut std::task::Context<'_>,
810 ) -> std::task::Poll<Option<Self::Item>> {
811 let this = &mut *self;
812 if this.inner.check_shutdown(cx) {
813 this.is_terminated = true;
814 return std::task::Poll::Ready(None);
815 }
816 if this.is_terminated {
817 panic!("polled FactoryRequestStream after completion");
818 }
819 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
820 |bytes, handles| {
821 match this.inner.channel().read_etc(cx, bytes, handles) {
822 std::task::Poll::Ready(Ok(())) => {}
823 std::task::Poll::Pending => return std::task::Poll::Pending,
824 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
825 this.is_terminated = true;
826 return std::task::Poll::Ready(None);
827 }
828 std::task::Poll::Ready(Err(e)) => {
829 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
830 e.into(),
831 ))));
832 }
833 }
834
835 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
837
838 std::task::Poll::Ready(Some(match header.ordinal {
839 0x65f64a124fd0170e => {
840 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
841 let mut req = fidl::new_empty!(
842 FactoryCreateRequest,
843 fidl::encoding::DefaultFuchsiaResourceDialect
844 );
845 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryCreateRequest>(&header, _body_bytes, handles, &mut req)?;
846 let control_handle = FactoryControlHandle { inner: this.inner.clone() };
847 Ok(FactoryRequest::Create {
848 config: req.config,
849 control: req.control,
850
851 responder: FactoryCreateResponder {
852 control_handle: std::mem::ManuallyDrop::new(control_handle),
853 tx_id: header.tx_id,
854 },
855 })
856 }
857 _ => Err(fidl::Error::UnknownOrdinal {
858 ordinal: header.ordinal,
859 protocol_name:
860 <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
861 }),
862 }))
863 },
864 )
865 }
866}
867
868#[derive(Debug)]
873pub enum FactoryRequest {
874 Create {
889 config: ControlConfig,
890 control: fidl::endpoints::ServerEnd<ControlMarker>,
891 responder: FactoryCreateResponder,
892 },
893}
894
895impl FactoryRequest {
896 #[allow(irrefutable_let_patterns)]
897 pub fn into_create(
898 self,
899 ) -> Option<(ControlConfig, fidl::endpoints::ServerEnd<ControlMarker>, FactoryCreateResponder)>
900 {
901 if let FactoryRequest::Create { config, control, responder } = self {
902 Some((config, control, responder))
903 } else {
904 None
905 }
906 }
907
908 pub fn method_name(&self) -> &'static str {
910 match *self {
911 FactoryRequest::Create { .. } => "create",
912 }
913 }
914}
915
916#[derive(Debug, Clone)]
917pub struct FactoryControlHandle {
918 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
919}
920
921impl fidl::endpoints::ControlHandle for FactoryControlHandle {
922 fn shutdown(&self) {
923 self.inner.shutdown()
924 }
925
926 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
927 self.inner.shutdown_with_epitaph(status)
928 }
929
930 fn is_closed(&self) -> bool {
931 self.inner.channel().is_closed()
932 }
933 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
934 self.inner.channel().on_closed()
935 }
936
937 #[cfg(target_os = "fuchsia")]
938 fn signal_peer(
939 &self,
940 clear_mask: zx::Signals,
941 set_mask: zx::Signals,
942 ) -> Result<(), zx_status::Status> {
943 use fidl::Peered;
944 self.inner.channel().signal_peer(clear_mask, set_mask)
945 }
946}
947
948impl FactoryControlHandle {}
949
950#[must_use = "FIDL methods require a response to be sent"]
951#[derive(Debug)]
952pub struct FactoryCreateResponder {
953 control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
954 tx_id: u32,
955}
956
957impl std::ops::Drop for FactoryCreateResponder {
961 fn drop(&mut self) {
962 self.control_handle.shutdown();
963 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
965 }
966}
967
968impl fidl::endpoints::Responder for FactoryCreateResponder {
969 type ControlHandle = FactoryControlHandle;
970
971 fn control_handle(&self) -> &FactoryControlHandle {
972 &self.control_handle
973 }
974
975 fn drop_without_shutdown(mut self) {
976 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
978 std::mem::forget(self);
980 }
981}
982
983impl FactoryCreateResponder {
984 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
988 let _result = self.send_raw(result);
989 if _result.is_err() {
990 self.control_handle.shutdown();
991 }
992 self.drop_without_shutdown();
993 _result
994 }
995
996 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
998 let _result = self.send_raw(result);
999 self.drop_without_shutdown();
1000 _result
1001 }
1002
1003 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1004 self.control_handle
1005 .inner
1006 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1007 result,
1008 self.tx_id,
1009 0x65f64a124fd0170e,
1010 fidl::encoding::DynamicFlags::empty(),
1011 )
1012 }
1013}
1014
1015mod internal {
1016 use super::*;
1017
1018 impl fidl::encoding::ResourceTypeMarker for FactoryCreateRequest {
1019 type Borrowed<'a> = &'a mut Self;
1020 fn take_or_borrow<'a>(
1021 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1022 ) -> Self::Borrowed<'a> {
1023 value
1024 }
1025 }
1026
1027 unsafe impl fidl::encoding::TypeMarker for FactoryCreateRequest {
1028 type Owned = Self;
1029
1030 #[inline(always)]
1031 fn inline_align(_context: fidl::encoding::Context) -> usize {
1032 8
1033 }
1034
1035 #[inline(always)]
1036 fn inline_size(_context: fidl::encoding::Context) -> usize {
1037 40
1038 }
1039 }
1040
1041 unsafe impl
1042 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1043 for &mut FactoryCreateRequest
1044 {
1045 #[inline]
1046 unsafe fn encode(
1047 self,
1048 encoder: &mut fidl::encoding::Encoder<
1049 '_,
1050 fidl::encoding::DefaultFuchsiaResourceDialect,
1051 >,
1052 offset: usize,
1053 _depth: fidl::encoding::Depth,
1054 ) -> fidl::Result<()> {
1055 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1056 fidl::encoding::Encode::<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1058 (
1059 <ControlConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1060 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
1061 ),
1062 encoder, offset, _depth
1063 )
1064 }
1065 }
1066 unsafe impl<
1067 T0: fidl::encoding::Encode<ControlConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1068 T1: fidl::encoding::Encode<
1069 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1070 fidl::encoding::DefaultFuchsiaResourceDialect,
1071 >,
1072 >
1073 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1074 for (T0, T1)
1075 {
1076 #[inline]
1077 unsafe fn encode(
1078 self,
1079 encoder: &mut fidl::encoding::Encoder<
1080 '_,
1081 fidl::encoding::DefaultFuchsiaResourceDialect,
1082 >,
1083 offset: usize,
1084 depth: fidl::encoding::Depth,
1085 ) -> fidl::Result<()> {
1086 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1087 unsafe {
1090 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1091 (ptr as *mut u64).write_unaligned(0);
1092 }
1093 self.0.encode(encoder, offset + 0, depth)?;
1095 self.1.encode(encoder, offset + 32, depth)?;
1096 Ok(())
1097 }
1098 }
1099
1100 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1101 for FactoryCreateRequest
1102 {
1103 #[inline(always)]
1104 fn new_empty() -> Self {
1105 Self {
1106 config: fidl::new_empty!(
1107 ControlConfig,
1108 fidl::encoding::DefaultFuchsiaResourceDialect
1109 ),
1110 control: fidl::new_empty!(
1111 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1112 fidl::encoding::DefaultFuchsiaResourceDialect
1113 ),
1114 }
1115 }
1116
1117 #[inline]
1118 unsafe fn decode(
1119 &mut self,
1120 decoder: &mut fidl::encoding::Decoder<
1121 '_,
1122 fidl::encoding::DefaultFuchsiaResourceDialect,
1123 >,
1124 offset: usize,
1125 _depth: fidl::encoding::Depth,
1126 ) -> fidl::Result<()> {
1127 decoder.debug_check_bounds::<Self>(offset);
1128 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1130 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1131 let mask = 0xffffffff00000000u64;
1132 let maskedval = padval & mask;
1133 if maskedval != 0 {
1134 return Err(fidl::Error::NonZeroPadding {
1135 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1136 });
1137 }
1138 fidl::decode!(
1139 ControlConfig,
1140 fidl::encoding::DefaultFuchsiaResourceDialect,
1141 &mut self.config,
1142 decoder,
1143 offset + 0,
1144 _depth
1145 )?;
1146 fidl::decode!(
1147 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1148 fidl::encoding::DefaultFuchsiaResourceDialect,
1149 &mut self.control,
1150 decoder,
1151 offset + 32,
1152 _depth
1153 )?;
1154 Ok(())
1155 }
1156 }
1157}