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 Self { client: fidl::client::sync::Client::new(channel) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<ControlEvent, fidl::Error> {
80 ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
81 }
82
83 pub fn r#set_enabled(
90 &self,
91 mut enabled: bool,
92 ___deadline: zx::MonotonicInstant,
93 ) -> Result<ControlSetEnabledResult, fidl::Error> {
94 let _response = self.client.send_query::<
95 ControlSetEnabledRequest,
96 fidl::encoding::ResultType<ControlSetEnabledResponse, Error>,
97 ControlMarker,
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 Self { client: fidl::client::sync::Client::new(channel) }
550 }
551
552 pub fn into_channel(self) -> fidl::Channel {
553 self.client.into_channel()
554 }
555
556 pub fn wait_for_event(
559 &self,
560 deadline: zx::MonotonicInstant,
561 ) -> Result<FactoryEvent, fidl::Error> {
562 FactoryEvent::decode(self.client.wait_for_event::<FactoryMarker>(deadline)?)
563 }
564
565 pub fn r#create(
580 &self,
581 mut config: &ControlConfig,
582 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
583 ___deadline: zx::MonotonicInstant,
584 ) -> Result<FactoryCreateResult, fidl::Error> {
585 let _response = self.client.send_query::<FactoryCreateRequest, fidl::encoding::ResultType<
586 fidl::encoding::EmptyStruct,
587 Error,
588 >, FactoryMarker>(
589 (config, control),
590 0x65f64a124fd0170e,
591 fidl::encoding::DynamicFlags::empty(),
592 ___deadline,
593 )?;
594 Ok(_response.map(|x| x))
595 }
596}
597
598#[cfg(target_os = "fuchsia")]
599impl From<FactorySynchronousProxy> for zx::NullableHandle {
600 fn from(value: FactorySynchronousProxy) -> Self {
601 value.into_channel().into()
602 }
603}
604
605#[cfg(target_os = "fuchsia")]
606impl From<fidl::Channel> for FactorySynchronousProxy {
607 fn from(value: fidl::Channel) -> Self {
608 Self::new(value)
609 }
610}
611
612#[cfg(target_os = "fuchsia")]
613impl fidl::endpoints::FromClient for FactorySynchronousProxy {
614 type Protocol = FactoryMarker;
615
616 fn from_client(value: fidl::endpoints::ClientEnd<FactoryMarker>) -> Self {
617 Self::new(value.into_channel())
618 }
619}
620
621#[derive(Debug, Clone)]
622pub struct FactoryProxy {
623 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
624}
625
626impl fidl::endpoints::Proxy for FactoryProxy {
627 type Protocol = FactoryMarker;
628
629 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
630 Self::new(inner)
631 }
632
633 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
634 self.client.into_channel().map_err(|client| Self { client })
635 }
636
637 fn as_channel(&self) -> &::fidl::AsyncChannel {
638 self.client.as_channel()
639 }
640}
641
642impl FactoryProxy {
643 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
645 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
646 Self { client: fidl::client::Client::new(channel, protocol_name) }
647 }
648
649 pub fn take_event_stream(&self) -> FactoryEventStream {
655 FactoryEventStream { event_receiver: self.client.take_event_receiver() }
656 }
657
658 pub fn r#create(
673 &self,
674 mut config: &ControlConfig,
675 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
676 ) -> fidl::client::QueryResponseFut<
677 FactoryCreateResult,
678 fidl::encoding::DefaultFuchsiaResourceDialect,
679 > {
680 FactoryProxyInterface::r#create(self, config, control)
681 }
682}
683
684impl FactoryProxyInterface for FactoryProxy {
685 type CreateResponseFut = fidl::client::QueryResponseFut<
686 FactoryCreateResult,
687 fidl::encoding::DefaultFuchsiaResourceDialect,
688 >;
689 fn r#create(
690 &self,
691 mut config: &ControlConfig,
692 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
693 ) -> Self::CreateResponseFut {
694 fn _decode(
695 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
696 ) -> Result<FactoryCreateResult, fidl::Error> {
697 let _response = fidl::client::decode_transaction_body::<
698 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
699 fidl::encoding::DefaultFuchsiaResourceDialect,
700 0x65f64a124fd0170e,
701 >(_buf?)?;
702 Ok(_response.map(|x| x))
703 }
704 self.client.send_query_and_decode::<FactoryCreateRequest, FactoryCreateResult>(
705 (config, control),
706 0x65f64a124fd0170e,
707 fidl::encoding::DynamicFlags::empty(),
708 _decode,
709 )
710 }
711}
712
713pub struct FactoryEventStream {
714 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
715}
716
717impl std::marker::Unpin for FactoryEventStream {}
718
719impl futures::stream::FusedStream for FactoryEventStream {
720 fn is_terminated(&self) -> bool {
721 self.event_receiver.is_terminated()
722 }
723}
724
725impl futures::Stream for FactoryEventStream {
726 type Item = Result<FactoryEvent, fidl::Error>;
727
728 fn poll_next(
729 mut self: std::pin::Pin<&mut Self>,
730 cx: &mut std::task::Context<'_>,
731 ) -> std::task::Poll<Option<Self::Item>> {
732 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
733 &mut self.event_receiver,
734 cx
735 )?) {
736 Some(buf) => std::task::Poll::Ready(Some(FactoryEvent::decode(buf))),
737 None => std::task::Poll::Ready(None),
738 }
739 }
740}
741
742#[derive(Debug)]
743pub enum FactoryEvent {}
744
745impl FactoryEvent {
746 fn decode(
748 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
749 ) -> Result<FactoryEvent, fidl::Error> {
750 let (bytes, _handles) = buf.split_mut();
751 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
752 debug_assert_eq!(tx_header.tx_id, 0);
753 match tx_header.ordinal {
754 _ => Err(fidl::Error::UnknownOrdinal {
755 ordinal: tx_header.ordinal,
756 protocol_name: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
757 }),
758 }
759 }
760}
761
762pub struct FactoryRequestStream {
764 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
765 is_terminated: bool,
766}
767
768impl std::marker::Unpin for FactoryRequestStream {}
769
770impl futures::stream::FusedStream for FactoryRequestStream {
771 fn is_terminated(&self) -> bool {
772 self.is_terminated
773 }
774}
775
776impl fidl::endpoints::RequestStream for FactoryRequestStream {
777 type Protocol = FactoryMarker;
778 type ControlHandle = FactoryControlHandle;
779
780 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
781 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
782 }
783
784 fn control_handle(&self) -> Self::ControlHandle {
785 FactoryControlHandle { inner: self.inner.clone() }
786 }
787
788 fn into_inner(
789 self,
790 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
791 {
792 (self.inner, self.is_terminated)
793 }
794
795 fn from_inner(
796 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
797 is_terminated: bool,
798 ) -> Self {
799 Self { inner, is_terminated }
800 }
801}
802
803impl futures::Stream for FactoryRequestStream {
804 type Item = Result<FactoryRequest, fidl::Error>;
805
806 fn poll_next(
807 mut self: std::pin::Pin<&mut Self>,
808 cx: &mut std::task::Context<'_>,
809 ) -> std::task::Poll<Option<Self::Item>> {
810 let this = &mut *self;
811 if this.inner.check_shutdown(cx) {
812 this.is_terminated = true;
813 return std::task::Poll::Ready(None);
814 }
815 if this.is_terminated {
816 panic!("polled FactoryRequestStream after completion");
817 }
818 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
819 |bytes, handles| {
820 match this.inner.channel().read_etc(cx, bytes, handles) {
821 std::task::Poll::Ready(Ok(())) => {}
822 std::task::Poll::Pending => return std::task::Poll::Pending,
823 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
824 this.is_terminated = true;
825 return std::task::Poll::Ready(None);
826 }
827 std::task::Poll::Ready(Err(e)) => {
828 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
829 e.into(),
830 ))));
831 }
832 }
833
834 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
836
837 std::task::Poll::Ready(Some(match header.ordinal {
838 0x65f64a124fd0170e => {
839 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
840 let mut req = fidl::new_empty!(
841 FactoryCreateRequest,
842 fidl::encoding::DefaultFuchsiaResourceDialect
843 );
844 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryCreateRequest>(&header, _body_bytes, handles, &mut req)?;
845 let control_handle = FactoryControlHandle { inner: this.inner.clone() };
846 Ok(FactoryRequest::Create {
847 config: req.config,
848 control: req.control,
849
850 responder: FactoryCreateResponder {
851 control_handle: std::mem::ManuallyDrop::new(control_handle),
852 tx_id: header.tx_id,
853 },
854 })
855 }
856 _ => Err(fidl::Error::UnknownOrdinal {
857 ordinal: header.ordinal,
858 protocol_name:
859 <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
860 }),
861 }))
862 },
863 )
864 }
865}
866
867#[derive(Debug)]
872pub enum FactoryRequest {
873 Create {
888 config: ControlConfig,
889 control: fidl::endpoints::ServerEnd<ControlMarker>,
890 responder: FactoryCreateResponder,
891 },
892}
893
894impl FactoryRequest {
895 #[allow(irrefutable_let_patterns)]
896 pub fn into_create(
897 self,
898 ) -> Option<(ControlConfig, fidl::endpoints::ServerEnd<ControlMarker>, FactoryCreateResponder)>
899 {
900 if let FactoryRequest::Create { config, control, responder } = self {
901 Some((config, control, responder))
902 } else {
903 None
904 }
905 }
906
907 pub fn method_name(&self) -> &'static str {
909 match *self {
910 FactoryRequest::Create { .. } => "create",
911 }
912 }
913}
914
915#[derive(Debug, Clone)]
916pub struct FactoryControlHandle {
917 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
918}
919
920impl fidl::endpoints::ControlHandle for FactoryControlHandle {
921 fn shutdown(&self) {
922 self.inner.shutdown()
923 }
924
925 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
926 self.inner.shutdown_with_epitaph(status)
927 }
928
929 fn is_closed(&self) -> bool {
930 self.inner.channel().is_closed()
931 }
932 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
933 self.inner.channel().on_closed()
934 }
935
936 #[cfg(target_os = "fuchsia")]
937 fn signal_peer(
938 &self,
939 clear_mask: zx::Signals,
940 set_mask: zx::Signals,
941 ) -> Result<(), zx_status::Status> {
942 use fidl::Peered;
943 self.inner.channel().signal_peer(clear_mask, set_mask)
944 }
945}
946
947impl FactoryControlHandle {}
948
949#[must_use = "FIDL methods require a response to be sent"]
950#[derive(Debug)]
951pub struct FactoryCreateResponder {
952 control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
953 tx_id: u32,
954}
955
956impl std::ops::Drop for FactoryCreateResponder {
960 fn drop(&mut self) {
961 self.control_handle.shutdown();
962 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
964 }
965}
966
967impl fidl::endpoints::Responder for FactoryCreateResponder {
968 type ControlHandle = FactoryControlHandle;
969
970 fn control_handle(&self) -> &FactoryControlHandle {
971 &self.control_handle
972 }
973
974 fn drop_without_shutdown(mut self) {
975 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
977 std::mem::forget(self);
979 }
980}
981
982impl FactoryCreateResponder {
983 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
987 let _result = self.send_raw(result);
988 if _result.is_err() {
989 self.control_handle.shutdown();
990 }
991 self.drop_without_shutdown();
992 _result
993 }
994
995 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
997 let _result = self.send_raw(result);
998 self.drop_without_shutdown();
999 _result
1000 }
1001
1002 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1003 self.control_handle
1004 .inner
1005 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1006 result,
1007 self.tx_id,
1008 0x65f64a124fd0170e,
1009 fidl::encoding::DynamicFlags::empty(),
1010 )
1011 }
1012}
1013
1014mod internal {
1015 use super::*;
1016
1017 impl fidl::encoding::ResourceTypeMarker for FactoryCreateRequest {
1018 type Borrowed<'a> = &'a mut Self;
1019 fn take_or_borrow<'a>(
1020 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1021 ) -> Self::Borrowed<'a> {
1022 value
1023 }
1024 }
1025
1026 unsafe impl fidl::encoding::TypeMarker for FactoryCreateRequest {
1027 type Owned = Self;
1028
1029 #[inline(always)]
1030 fn inline_align(_context: fidl::encoding::Context) -> usize {
1031 8
1032 }
1033
1034 #[inline(always)]
1035 fn inline_size(_context: fidl::encoding::Context) -> usize {
1036 40
1037 }
1038 }
1039
1040 unsafe impl
1041 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1042 for &mut FactoryCreateRequest
1043 {
1044 #[inline]
1045 unsafe fn encode(
1046 self,
1047 encoder: &mut fidl::encoding::Encoder<
1048 '_,
1049 fidl::encoding::DefaultFuchsiaResourceDialect,
1050 >,
1051 offset: usize,
1052 _depth: fidl::encoding::Depth,
1053 ) -> fidl::Result<()> {
1054 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1055 fidl::encoding::Encode::<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1057 (
1058 <ControlConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1059 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
1060 ),
1061 encoder, offset, _depth
1062 )
1063 }
1064 }
1065 unsafe impl<
1066 T0: fidl::encoding::Encode<ControlConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1067 T1: fidl::encoding::Encode<
1068 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1069 fidl::encoding::DefaultFuchsiaResourceDialect,
1070 >,
1071 >
1072 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1073 for (T0, T1)
1074 {
1075 #[inline]
1076 unsafe fn encode(
1077 self,
1078 encoder: &mut fidl::encoding::Encoder<
1079 '_,
1080 fidl::encoding::DefaultFuchsiaResourceDialect,
1081 >,
1082 offset: usize,
1083 depth: fidl::encoding::Depth,
1084 ) -> fidl::Result<()> {
1085 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1086 unsafe {
1089 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1090 (ptr as *mut u64).write_unaligned(0);
1091 }
1092 self.0.encode(encoder, offset + 0, depth)?;
1094 self.1.encode(encoder, offset + 32, depth)?;
1095 Ok(())
1096 }
1097 }
1098
1099 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1100 for FactoryCreateRequest
1101 {
1102 #[inline(always)]
1103 fn new_empty() -> Self {
1104 Self {
1105 config: fidl::new_empty!(
1106 ControlConfig,
1107 fidl::encoding::DefaultFuchsiaResourceDialect
1108 ),
1109 control: fidl::new_empty!(
1110 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1111 fidl::encoding::DefaultFuchsiaResourceDialect
1112 ),
1113 }
1114 }
1115
1116 #[inline]
1117 unsafe fn decode(
1118 &mut self,
1119 decoder: &mut fidl::encoding::Decoder<
1120 '_,
1121 fidl::encoding::DefaultFuchsiaResourceDialect,
1122 >,
1123 offset: usize,
1124 _depth: fidl::encoding::Depth,
1125 ) -> fidl::Result<()> {
1126 decoder.debug_check_bounds::<Self>(offset);
1127 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1129 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1130 let mask = 0xffffffff00000000u64;
1131 let maskedval = padval & mask;
1132 if maskedval != 0 {
1133 return Err(fidl::Error::NonZeroPadding {
1134 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1135 });
1136 }
1137 fidl::decode!(
1138 ControlConfig,
1139 fidl::encoding::DefaultFuchsiaResourceDialect,
1140 &mut self.config,
1141 decoder,
1142 offset + 0,
1143 _depth
1144 )?;
1145 fidl::decode!(
1146 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1147 fidl::encoding::DefaultFuchsiaResourceDialect,
1148 &mut self.control,
1149 decoder,
1150 offset + 32,
1151 _depth
1152 )?;
1153 Ok(())
1154 }
1155 }
1156}