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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
407 self.inner.shutdown_with_epitaph(status)
408 }
409
410 fn is_closed(&self) -> bool {
411 self.inner.channel().is_closed()
412 }
413 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
414 self.inner.channel().on_closed()
415 }
416
417 #[cfg(target_os = "fuchsia")]
418 fn signal_peer(
419 &self,
420 clear_mask: zx::Signals,
421 set_mask: zx::Signals,
422 ) -> Result<(), zx_status::Status> {
423 use fidl::Peered;
424 self.inner.channel().signal_peer(clear_mask, set_mask)
425 }
426}
427
428impl ControlControlHandle {}
429
430#[must_use = "FIDL methods require a response to be sent"]
431#[derive(Debug)]
432pub struct ControlSetEnabledResponder {
433 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
434 tx_id: u32,
435}
436
437impl std::ops::Drop for ControlSetEnabledResponder {
441 fn drop(&mut self) {
442 self.control_handle.shutdown();
443 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
445 }
446}
447
448impl fidl::endpoints::Responder for ControlSetEnabledResponder {
449 type ControlHandle = ControlControlHandle;
450
451 fn control_handle(&self) -> &ControlControlHandle {
452 &self.control_handle
453 }
454
455 fn drop_without_shutdown(mut self) {
456 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
458 std::mem::forget(self);
460 }
461}
462
463impl ControlSetEnabledResponder {
464 pub fn send(self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
468 let _result = self.send_raw(result);
469 if _result.is_err() {
470 self.control_handle.shutdown();
471 }
472 self.drop_without_shutdown();
473 _result
474 }
475
476 pub fn send_no_shutdown_on_err(
478 self,
479 mut result: Result<bool, Error>,
480 ) -> Result<(), fidl::Error> {
481 let _result = self.send_raw(result);
482 self.drop_without_shutdown();
483 _result
484 }
485
486 fn send_raw(&self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
487 self.control_handle
488 .inner
489 .send::<fidl::encoding::ResultType<ControlSetEnabledResponse, Error>>(
490 result.map(|was_enabled| (was_enabled,)),
491 self.tx_id,
492 0x13b7914afdb709a6,
493 fidl::encoding::DynamicFlags::empty(),
494 )
495 }
496}
497
498#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
499pub struct FactoryMarker;
500
501impl fidl::endpoints::ProtocolMarker for FactoryMarker {
502 type Proxy = FactoryProxy;
503 type RequestStream = FactoryRequestStream;
504 #[cfg(target_os = "fuchsia")]
505 type SynchronousProxy = FactorySynchronousProxy;
506
507 const DEBUG_NAME: &'static str = "fuchsia.net.masquerade.Factory";
508}
509impl fidl::endpoints::DiscoverableProtocolMarker for FactoryMarker {}
510pub type FactoryCreateResult = Result<(), Error>;
511
512pub trait FactoryProxyInterface: Send + Sync {
513 type CreateResponseFut: std::future::Future<Output = Result<FactoryCreateResult, fidl::Error>>
514 + Send;
515 fn r#create(
516 &self,
517 config: &ControlConfig,
518 control: fidl::endpoints::ServerEnd<ControlMarker>,
519 ) -> Self::CreateResponseFut;
520}
521#[derive(Debug)]
522#[cfg(target_os = "fuchsia")]
523pub struct FactorySynchronousProxy {
524 client: fidl::client::sync::Client,
525}
526
527#[cfg(target_os = "fuchsia")]
528impl fidl::endpoints::SynchronousProxy for FactorySynchronousProxy {
529 type Proxy = FactoryProxy;
530 type Protocol = FactoryMarker;
531
532 fn from_channel(inner: fidl::Channel) -> Self {
533 Self::new(inner)
534 }
535
536 fn into_channel(self) -> fidl::Channel {
537 self.client.into_channel()
538 }
539
540 fn as_channel(&self) -> &fidl::Channel {
541 self.client.as_channel()
542 }
543}
544
545#[cfg(target_os = "fuchsia")]
546impl FactorySynchronousProxy {
547 pub fn new(channel: fidl::Channel) -> Self {
548 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
549 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
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(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 >>(
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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
925 self.inner.shutdown_with_epitaph(status)
926 }
927
928 fn is_closed(&self) -> bool {
929 self.inner.channel().is_closed()
930 }
931 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
932 self.inner.channel().on_closed()
933 }
934
935 #[cfg(target_os = "fuchsia")]
936 fn signal_peer(
937 &self,
938 clear_mask: zx::Signals,
939 set_mask: zx::Signals,
940 ) -> Result<(), zx_status::Status> {
941 use fidl::Peered;
942 self.inner.channel().signal_peer(clear_mask, set_mask)
943 }
944}
945
946impl FactoryControlHandle {}
947
948#[must_use = "FIDL methods require a response to be sent"]
949#[derive(Debug)]
950pub struct FactoryCreateResponder {
951 control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
952 tx_id: u32,
953}
954
955impl std::ops::Drop for FactoryCreateResponder {
959 fn drop(&mut self) {
960 self.control_handle.shutdown();
961 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
963 }
964}
965
966impl fidl::endpoints::Responder for FactoryCreateResponder {
967 type ControlHandle = FactoryControlHandle;
968
969 fn control_handle(&self) -> &FactoryControlHandle {
970 &self.control_handle
971 }
972
973 fn drop_without_shutdown(mut self) {
974 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
976 std::mem::forget(self);
978 }
979}
980
981impl FactoryCreateResponder {
982 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
986 let _result = self.send_raw(result);
987 if _result.is_err() {
988 self.control_handle.shutdown();
989 }
990 self.drop_without_shutdown();
991 _result
992 }
993
994 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
996 let _result = self.send_raw(result);
997 self.drop_without_shutdown();
998 _result
999 }
1000
1001 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1002 self.control_handle
1003 .inner
1004 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1005 result,
1006 self.tx_id,
1007 0x65f64a124fd0170e,
1008 fidl::encoding::DynamicFlags::empty(),
1009 )
1010 }
1011}
1012
1013mod internal {
1014 use super::*;
1015
1016 impl fidl::encoding::ResourceTypeMarker for FactoryCreateRequest {
1017 type Borrowed<'a> = &'a mut Self;
1018 fn take_or_borrow<'a>(
1019 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1020 ) -> Self::Borrowed<'a> {
1021 value
1022 }
1023 }
1024
1025 unsafe impl fidl::encoding::TypeMarker for FactoryCreateRequest {
1026 type Owned = Self;
1027
1028 #[inline(always)]
1029 fn inline_align(_context: fidl::encoding::Context) -> usize {
1030 8
1031 }
1032
1033 #[inline(always)]
1034 fn inline_size(_context: fidl::encoding::Context) -> usize {
1035 40
1036 }
1037 }
1038
1039 unsafe impl
1040 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1041 for &mut FactoryCreateRequest
1042 {
1043 #[inline]
1044 unsafe fn encode(
1045 self,
1046 encoder: &mut fidl::encoding::Encoder<
1047 '_,
1048 fidl::encoding::DefaultFuchsiaResourceDialect,
1049 >,
1050 offset: usize,
1051 _depth: fidl::encoding::Depth,
1052 ) -> fidl::Result<()> {
1053 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1054 fidl::encoding::Encode::<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1056 (
1057 <ControlConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1058 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
1059 ),
1060 encoder, offset, _depth
1061 )
1062 }
1063 }
1064 unsafe impl<
1065 T0: fidl::encoding::Encode<ControlConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1066 T1: fidl::encoding::Encode<
1067 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1068 fidl::encoding::DefaultFuchsiaResourceDialect,
1069 >,
1070 >
1071 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1072 for (T0, T1)
1073 {
1074 #[inline]
1075 unsafe fn encode(
1076 self,
1077 encoder: &mut fidl::encoding::Encoder<
1078 '_,
1079 fidl::encoding::DefaultFuchsiaResourceDialect,
1080 >,
1081 offset: usize,
1082 depth: fidl::encoding::Depth,
1083 ) -> fidl::Result<()> {
1084 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1085 unsafe {
1088 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1089 (ptr as *mut u64).write_unaligned(0);
1090 }
1091 self.0.encode(encoder, offset + 0, depth)?;
1093 self.1.encode(encoder, offset + 32, depth)?;
1094 Ok(())
1095 }
1096 }
1097
1098 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1099 for FactoryCreateRequest
1100 {
1101 #[inline(always)]
1102 fn new_empty() -> Self {
1103 Self {
1104 config: fidl::new_empty!(
1105 ControlConfig,
1106 fidl::encoding::DefaultFuchsiaResourceDialect
1107 ),
1108 control: fidl::new_empty!(
1109 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1110 fidl::encoding::DefaultFuchsiaResourceDialect
1111 ),
1112 }
1113 }
1114
1115 #[inline]
1116 unsafe fn decode(
1117 &mut self,
1118 decoder: &mut fidl::encoding::Decoder<
1119 '_,
1120 fidl::encoding::DefaultFuchsiaResourceDialect,
1121 >,
1122 offset: usize,
1123 _depth: fidl::encoding::Depth,
1124 ) -> fidl::Result<()> {
1125 decoder.debug_check_bounds::<Self>(offset);
1126 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1128 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1129 let mask = 0xffffffff00000000u64;
1130 let maskedval = padval & mask;
1131 if maskedval != 0 {
1132 return Err(fidl::Error::NonZeroPadding {
1133 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1134 });
1135 }
1136 fidl::decode!(
1137 ControlConfig,
1138 fidl::encoding::DefaultFuchsiaResourceDialect,
1139 &mut self.config,
1140 decoder,
1141 offset + 0,
1142 _depth
1143 )?;
1144 fidl::decode!(
1145 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1146 fidl::encoding::DefaultFuchsiaResourceDialect,
1147 &mut self.control,
1148 decoder,
1149 offset + 32,
1150 _depth
1151 )?;
1152 Ok(())
1153 }
1154 }
1155}