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 ControlControlHandle {
403 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
404 self.inner.shutdown_with_epitaph(status.into())
405 }
406}
407
408impl fidl::endpoints::ControlHandle for ControlControlHandle {
409 fn shutdown(&self) {
410 self.inner.shutdown()
411 }
412
413 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
414 self.inner.shutdown_with_epitaph(status)
415 }
416
417 fn is_closed(&self) -> bool {
418 self.inner.channel().is_closed()
419 }
420 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
421 self.inner.channel().on_closed()
422 }
423
424 #[cfg(target_os = "fuchsia")]
425 fn signal_peer(
426 &self,
427 clear_mask: zx::Signals,
428 set_mask: zx::Signals,
429 ) -> Result<(), zx_status::Status> {
430 use fidl::Peered;
431 self.inner.channel().signal_peer(clear_mask, set_mask)
432 }
433}
434
435impl ControlControlHandle {}
436
437#[must_use = "FIDL methods require a response to be sent"]
438#[derive(Debug)]
439pub struct ControlSetEnabledResponder {
440 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
441 tx_id: u32,
442}
443
444impl std::ops::Drop for ControlSetEnabledResponder {
448 fn drop(&mut self) {
449 self.control_handle.shutdown();
450 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
452 }
453}
454
455impl fidl::endpoints::Responder for ControlSetEnabledResponder {
456 type ControlHandle = ControlControlHandle;
457
458 fn control_handle(&self) -> &ControlControlHandle {
459 &self.control_handle
460 }
461
462 fn drop_without_shutdown(mut self) {
463 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
465 std::mem::forget(self);
467 }
468}
469
470impl ControlSetEnabledResponder {
471 pub fn send(self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
475 let _result = self.send_raw(result);
476 if _result.is_err() {
477 self.control_handle.shutdown();
478 }
479 self.drop_without_shutdown();
480 _result
481 }
482
483 pub fn send_no_shutdown_on_err(
485 self,
486 mut result: Result<bool, Error>,
487 ) -> Result<(), fidl::Error> {
488 let _result = self.send_raw(result);
489 self.drop_without_shutdown();
490 _result
491 }
492
493 fn send_raw(&self, mut result: Result<bool, Error>) -> Result<(), fidl::Error> {
494 self.control_handle
495 .inner
496 .send::<fidl::encoding::ResultType<ControlSetEnabledResponse, Error>>(
497 result.map(|was_enabled| (was_enabled,)),
498 self.tx_id,
499 0x13b7914afdb709a6,
500 fidl::encoding::DynamicFlags::empty(),
501 )
502 }
503}
504
505#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
506pub struct FactoryMarker;
507
508impl fidl::endpoints::ProtocolMarker for FactoryMarker {
509 type Proxy = FactoryProxy;
510 type RequestStream = FactoryRequestStream;
511 #[cfg(target_os = "fuchsia")]
512 type SynchronousProxy = FactorySynchronousProxy;
513
514 const DEBUG_NAME: &'static str = "fuchsia.net.masquerade.Factory";
515}
516impl fidl::endpoints::DiscoverableProtocolMarker for FactoryMarker {}
517pub type FactoryCreateResult = Result<(), Error>;
518
519pub trait FactoryProxyInterface: Send + Sync {
520 type CreateResponseFut: std::future::Future<Output = Result<FactoryCreateResult, fidl::Error>>
521 + Send;
522 fn r#create(
523 &self,
524 config: &ControlConfig,
525 control: fidl::endpoints::ServerEnd<ControlMarker>,
526 ) -> Self::CreateResponseFut;
527}
528#[derive(Debug)]
529#[cfg(target_os = "fuchsia")]
530pub struct FactorySynchronousProxy {
531 client: fidl::client::sync::Client,
532}
533
534#[cfg(target_os = "fuchsia")]
535impl fidl::endpoints::SynchronousProxy for FactorySynchronousProxy {
536 type Proxy = FactoryProxy;
537 type Protocol = FactoryMarker;
538
539 fn from_channel(inner: fidl::Channel) -> Self {
540 Self::new(inner)
541 }
542
543 fn into_channel(self) -> fidl::Channel {
544 self.client.into_channel()
545 }
546
547 fn as_channel(&self) -> &fidl::Channel {
548 self.client.as_channel()
549 }
550}
551
552#[cfg(target_os = "fuchsia")]
553impl FactorySynchronousProxy {
554 pub fn new(channel: fidl::Channel) -> Self {
555 Self { client: fidl::client::sync::Client::new(channel) }
556 }
557
558 pub fn into_channel(self) -> fidl::Channel {
559 self.client.into_channel()
560 }
561
562 pub fn wait_for_event(
565 &self,
566 deadline: zx::MonotonicInstant,
567 ) -> Result<FactoryEvent, fidl::Error> {
568 FactoryEvent::decode(self.client.wait_for_event::<FactoryMarker>(deadline)?)
569 }
570
571 pub fn r#create(
586 &self,
587 mut config: &ControlConfig,
588 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
589 ___deadline: zx::MonotonicInstant,
590 ) -> Result<FactoryCreateResult, fidl::Error> {
591 let _response = self.client.send_query::<FactoryCreateRequest, fidl::encoding::ResultType<
592 fidl::encoding::EmptyStruct,
593 Error,
594 >, FactoryMarker>(
595 (config, control),
596 0x65f64a124fd0170e,
597 fidl::encoding::DynamicFlags::empty(),
598 ___deadline,
599 )?;
600 Ok(_response.map(|x| x))
601 }
602}
603
604#[cfg(target_os = "fuchsia")]
605impl From<FactorySynchronousProxy> for zx::NullableHandle {
606 fn from(value: FactorySynchronousProxy) -> Self {
607 value.into_channel().into()
608 }
609}
610
611#[cfg(target_os = "fuchsia")]
612impl From<fidl::Channel> for FactorySynchronousProxy {
613 fn from(value: fidl::Channel) -> Self {
614 Self::new(value)
615 }
616}
617
618#[cfg(target_os = "fuchsia")]
619impl fidl::endpoints::FromClient for FactorySynchronousProxy {
620 type Protocol = FactoryMarker;
621
622 fn from_client(value: fidl::endpoints::ClientEnd<FactoryMarker>) -> Self {
623 Self::new(value.into_channel())
624 }
625}
626
627#[derive(Debug, Clone)]
628pub struct FactoryProxy {
629 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
630}
631
632impl fidl::endpoints::Proxy for FactoryProxy {
633 type Protocol = FactoryMarker;
634
635 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
636 Self::new(inner)
637 }
638
639 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
640 self.client.into_channel().map_err(|client| Self { client })
641 }
642
643 fn as_channel(&self) -> &::fidl::AsyncChannel {
644 self.client.as_channel()
645 }
646}
647
648impl FactoryProxy {
649 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
651 let protocol_name = <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
652 Self { client: fidl::client::Client::new(channel, protocol_name) }
653 }
654
655 pub fn take_event_stream(&self) -> FactoryEventStream {
661 FactoryEventStream { event_receiver: self.client.take_event_receiver() }
662 }
663
664 pub fn r#create(
679 &self,
680 mut config: &ControlConfig,
681 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
682 ) -> fidl::client::QueryResponseFut<
683 FactoryCreateResult,
684 fidl::encoding::DefaultFuchsiaResourceDialect,
685 > {
686 FactoryProxyInterface::r#create(self, config, control)
687 }
688}
689
690impl FactoryProxyInterface for FactoryProxy {
691 type CreateResponseFut = fidl::client::QueryResponseFut<
692 FactoryCreateResult,
693 fidl::encoding::DefaultFuchsiaResourceDialect,
694 >;
695 fn r#create(
696 &self,
697 mut config: &ControlConfig,
698 mut control: fidl::endpoints::ServerEnd<ControlMarker>,
699 ) -> Self::CreateResponseFut {
700 fn _decode(
701 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
702 ) -> Result<FactoryCreateResult, fidl::Error> {
703 let _response = fidl::client::decode_transaction_body::<
704 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
705 fidl::encoding::DefaultFuchsiaResourceDialect,
706 0x65f64a124fd0170e,
707 >(_buf?)?;
708 Ok(_response.map(|x| x))
709 }
710 self.client.send_query_and_decode::<FactoryCreateRequest, FactoryCreateResult>(
711 (config, control),
712 0x65f64a124fd0170e,
713 fidl::encoding::DynamicFlags::empty(),
714 _decode,
715 )
716 }
717}
718
719pub struct FactoryEventStream {
720 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
721}
722
723impl std::marker::Unpin for FactoryEventStream {}
724
725impl futures::stream::FusedStream for FactoryEventStream {
726 fn is_terminated(&self) -> bool {
727 self.event_receiver.is_terminated()
728 }
729}
730
731impl futures::Stream for FactoryEventStream {
732 type Item = Result<FactoryEvent, fidl::Error>;
733
734 fn poll_next(
735 mut self: std::pin::Pin<&mut Self>,
736 cx: &mut std::task::Context<'_>,
737 ) -> std::task::Poll<Option<Self::Item>> {
738 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
739 &mut self.event_receiver,
740 cx
741 )?) {
742 Some(buf) => std::task::Poll::Ready(Some(FactoryEvent::decode(buf))),
743 None => std::task::Poll::Ready(None),
744 }
745 }
746}
747
748#[derive(Debug)]
749pub enum FactoryEvent {}
750
751impl FactoryEvent {
752 fn decode(
754 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
755 ) -> Result<FactoryEvent, fidl::Error> {
756 let (bytes, _handles) = buf.split_mut();
757 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
758 debug_assert_eq!(tx_header.tx_id, 0);
759 match tx_header.ordinal {
760 _ => Err(fidl::Error::UnknownOrdinal {
761 ordinal: tx_header.ordinal,
762 protocol_name: <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
763 }),
764 }
765 }
766}
767
768pub struct FactoryRequestStream {
770 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
771 is_terminated: bool,
772}
773
774impl std::marker::Unpin for FactoryRequestStream {}
775
776impl futures::stream::FusedStream for FactoryRequestStream {
777 fn is_terminated(&self) -> bool {
778 self.is_terminated
779 }
780}
781
782impl fidl::endpoints::RequestStream for FactoryRequestStream {
783 type Protocol = FactoryMarker;
784 type ControlHandle = FactoryControlHandle;
785
786 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
787 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
788 }
789
790 fn control_handle(&self) -> Self::ControlHandle {
791 FactoryControlHandle { inner: self.inner.clone() }
792 }
793
794 fn into_inner(
795 self,
796 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
797 {
798 (self.inner, self.is_terminated)
799 }
800
801 fn from_inner(
802 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
803 is_terminated: bool,
804 ) -> Self {
805 Self { inner, is_terminated }
806 }
807}
808
809impl futures::Stream for FactoryRequestStream {
810 type Item = Result<FactoryRequest, fidl::Error>;
811
812 fn poll_next(
813 mut self: std::pin::Pin<&mut Self>,
814 cx: &mut std::task::Context<'_>,
815 ) -> std::task::Poll<Option<Self::Item>> {
816 let this = &mut *self;
817 if this.inner.check_shutdown(cx) {
818 this.is_terminated = true;
819 return std::task::Poll::Ready(None);
820 }
821 if this.is_terminated {
822 panic!("polled FactoryRequestStream after completion");
823 }
824 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
825 |bytes, handles| {
826 match this.inner.channel().read_etc(cx, bytes, handles) {
827 std::task::Poll::Ready(Ok(())) => {}
828 std::task::Poll::Pending => return std::task::Poll::Pending,
829 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
830 this.is_terminated = true;
831 return std::task::Poll::Ready(None);
832 }
833 std::task::Poll::Ready(Err(e)) => {
834 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
835 e.into(),
836 ))));
837 }
838 }
839
840 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
842
843 std::task::Poll::Ready(Some(match header.ordinal {
844 0x65f64a124fd0170e => {
845 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
846 let mut req = fidl::new_empty!(
847 FactoryCreateRequest,
848 fidl::encoding::DefaultFuchsiaResourceDialect
849 );
850 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryCreateRequest>(&header, _body_bytes, handles, &mut req)?;
851 let control_handle = FactoryControlHandle { inner: this.inner.clone() };
852 Ok(FactoryRequest::Create {
853 config: req.config,
854 control: req.control,
855
856 responder: FactoryCreateResponder {
857 control_handle: std::mem::ManuallyDrop::new(control_handle),
858 tx_id: header.tx_id,
859 },
860 })
861 }
862 _ => Err(fidl::Error::UnknownOrdinal {
863 ordinal: header.ordinal,
864 protocol_name:
865 <FactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
866 }),
867 }))
868 },
869 )
870 }
871}
872
873#[derive(Debug)]
878pub enum FactoryRequest {
879 Create {
894 config: ControlConfig,
895 control: fidl::endpoints::ServerEnd<ControlMarker>,
896 responder: FactoryCreateResponder,
897 },
898}
899
900impl FactoryRequest {
901 #[allow(irrefutable_let_patterns)]
902 pub fn into_create(
903 self,
904 ) -> Option<(ControlConfig, fidl::endpoints::ServerEnd<ControlMarker>, FactoryCreateResponder)>
905 {
906 if let FactoryRequest::Create { config, control, responder } = self {
907 Some((config, control, responder))
908 } else {
909 None
910 }
911 }
912
913 pub fn method_name(&self) -> &'static str {
915 match *self {
916 FactoryRequest::Create { .. } => "create",
917 }
918 }
919}
920
921#[derive(Debug, Clone)]
922pub struct FactoryControlHandle {
923 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
924}
925
926impl FactoryControlHandle {
927 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
928 self.inner.shutdown_with_epitaph(status.into())
929 }
930}
931
932impl fidl::endpoints::ControlHandle for FactoryControlHandle {
933 fn shutdown(&self) {
934 self.inner.shutdown()
935 }
936
937 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
938 self.inner.shutdown_with_epitaph(status)
939 }
940
941 fn is_closed(&self) -> bool {
942 self.inner.channel().is_closed()
943 }
944 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
945 self.inner.channel().on_closed()
946 }
947
948 #[cfg(target_os = "fuchsia")]
949 fn signal_peer(
950 &self,
951 clear_mask: zx::Signals,
952 set_mask: zx::Signals,
953 ) -> Result<(), zx_status::Status> {
954 use fidl::Peered;
955 self.inner.channel().signal_peer(clear_mask, set_mask)
956 }
957}
958
959impl FactoryControlHandle {}
960
961#[must_use = "FIDL methods require a response to be sent"]
962#[derive(Debug)]
963pub struct FactoryCreateResponder {
964 control_handle: std::mem::ManuallyDrop<FactoryControlHandle>,
965 tx_id: u32,
966}
967
968impl std::ops::Drop for FactoryCreateResponder {
972 fn drop(&mut self) {
973 self.control_handle.shutdown();
974 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
976 }
977}
978
979impl fidl::endpoints::Responder for FactoryCreateResponder {
980 type ControlHandle = FactoryControlHandle;
981
982 fn control_handle(&self) -> &FactoryControlHandle {
983 &self.control_handle
984 }
985
986 fn drop_without_shutdown(mut self) {
987 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
989 std::mem::forget(self);
991 }
992}
993
994impl FactoryCreateResponder {
995 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
999 let _result = self.send_raw(result);
1000 if _result.is_err() {
1001 self.control_handle.shutdown();
1002 }
1003 self.drop_without_shutdown();
1004 _result
1005 }
1006
1007 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1009 let _result = self.send_raw(result);
1010 self.drop_without_shutdown();
1011 _result
1012 }
1013
1014 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1015 self.control_handle
1016 .inner
1017 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1018 result,
1019 self.tx_id,
1020 0x65f64a124fd0170e,
1021 fidl::encoding::DynamicFlags::empty(),
1022 )
1023 }
1024}
1025
1026mod internal {
1027 use super::*;
1028
1029 impl fidl::encoding::ResourceTypeMarker for FactoryCreateRequest {
1030 type Borrowed<'a> = &'a mut Self;
1031 fn take_or_borrow<'a>(
1032 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1033 ) -> Self::Borrowed<'a> {
1034 value
1035 }
1036 }
1037
1038 unsafe impl fidl::encoding::TypeMarker for FactoryCreateRequest {
1039 type Owned = Self;
1040
1041 #[inline(always)]
1042 fn inline_align(_context: fidl::encoding::Context) -> usize {
1043 8
1044 }
1045
1046 #[inline(always)]
1047 fn inline_size(_context: fidl::encoding::Context) -> usize {
1048 40
1049 }
1050 }
1051
1052 unsafe impl
1053 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1054 for &mut FactoryCreateRequest
1055 {
1056 #[inline]
1057 unsafe fn encode(
1058 self,
1059 encoder: &mut fidl::encoding::Encoder<
1060 '_,
1061 fidl::encoding::DefaultFuchsiaResourceDialect,
1062 >,
1063 offset: usize,
1064 _depth: fidl::encoding::Depth,
1065 ) -> fidl::Result<()> {
1066 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1067 fidl::encoding::Encode::<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1069 (
1070 <ControlConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1071 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
1072 ),
1073 encoder, offset, _depth
1074 )
1075 }
1076 }
1077 unsafe impl<
1078 T0: fidl::encoding::Encode<ControlConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1079 T1: fidl::encoding::Encode<
1080 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1081 fidl::encoding::DefaultFuchsiaResourceDialect,
1082 >,
1083 >
1084 fidl::encoding::Encode<FactoryCreateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1085 for (T0, T1)
1086 {
1087 #[inline]
1088 unsafe fn encode(
1089 self,
1090 encoder: &mut fidl::encoding::Encoder<
1091 '_,
1092 fidl::encoding::DefaultFuchsiaResourceDialect,
1093 >,
1094 offset: usize,
1095 depth: fidl::encoding::Depth,
1096 ) -> fidl::Result<()> {
1097 encoder.debug_check_bounds::<FactoryCreateRequest>(offset);
1098 unsafe {
1101 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1102 (ptr as *mut u64).write_unaligned(0);
1103 }
1104 self.0.encode(encoder, offset + 0, depth)?;
1106 self.1.encode(encoder, offset + 32, depth)?;
1107 Ok(())
1108 }
1109 }
1110
1111 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1112 for FactoryCreateRequest
1113 {
1114 #[inline(always)]
1115 fn new_empty() -> Self {
1116 Self {
1117 config: fidl::new_empty!(
1118 ControlConfig,
1119 fidl::encoding::DefaultFuchsiaResourceDialect
1120 ),
1121 control: fidl::new_empty!(
1122 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1123 fidl::encoding::DefaultFuchsiaResourceDialect
1124 ),
1125 }
1126 }
1127
1128 #[inline]
1129 unsafe fn decode(
1130 &mut self,
1131 decoder: &mut fidl::encoding::Decoder<
1132 '_,
1133 fidl::encoding::DefaultFuchsiaResourceDialect,
1134 >,
1135 offset: usize,
1136 _depth: fidl::encoding::Depth,
1137 ) -> fidl::Result<()> {
1138 decoder.debug_check_bounds::<Self>(offset);
1139 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1141 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1142 let mask = 0xffffffff00000000u64;
1143 let maskedval = padval & mask;
1144 if maskedval != 0 {
1145 return Err(fidl::Error::NonZeroPadding {
1146 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1147 });
1148 }
1149 fidl::decode!(
1150 ControlConfig,
1151 fidl::encoding::DefaultFuchsiaResourceDialect,
1152 &mut self.config,
1153 decoder,
1154 offset + 0,
1155 _depth
1156 )?;
1157 fidl::decode!(
1158 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
1159 fidl::encoding::DefaultFuchsiaResourceDialect,
1160 &mut self.control,
1161 decoder,
1162 offset + 32,
1163 _depth
1164 )?;
1165 Ok(())
1166 }
1167 }
1168}