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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13pub const MAX_GUEST_NAME_LENGTH: u64 = 32;
14
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum ControllerCreateGuestError {
18 AlreadyRunning = 1,
20 LaunchFailed = 2,
22 AttachFailed = 3,
24}
25
26impl ControllerCreateGuestError {
27 #[inline]
28 pub fn from_primitive(prim: u32) -> Option<Self> {
29 match prim {
30 1 => Some(Self::AlreadyRunning),
31 2 => Some(Self::LaunchFailed),
32 3 => Some(Self::AttachFailed),
33 _ => None,
34 }
35 }
36
37 #[inline]
38 pub const fn into_primitive(self) -> u32 {
39 self as u32
40 }
41
42 #[deprecated = "Strict enums should not use `is_unknown`"]
43 #[inline]
44 pub fn is_unknown(&self) -> bool {
45 false
46 }
47}
48
49#[derive(Debug, PartialEq)]
50pub struct ControllerCreateGuestRequest {
51 pub name: String,
52 pub network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
53 pub mac: Option<Box<fidl_fuchsia_net::MacAddress>>,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
57 for ControllerCreateGuestRequest
58{
59}
60
61#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62pub struct ControllerCreateGuestResponse {
63 pub s: fidl::endpoints::ClientEnd<GuestMarker>,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
67 for ControllerCreateGuestResponse
68{
69}
70
71#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
72pub struct ControllerMarker;
73
74impl fidl::endpoints::ProtocolMarker for ControllerMarker {
75 type Proxy = ControllerProxy;
76 type RequestStream = ControllerRequestStream;
77 #[cfg(target_os = "fuchsia")]
78 type SynchronousProxy = ControllerSynchronousProxy;
79
80 const DEBUG_NAME: &'static str = "fuchsia.netemul.guest.Controller";
81}
82impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
83pub type ControllerCreateGuestResult =
84 Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>;
85
86pub trait ControllerProxyInterface: Send + Sync {
87 type CreateGuestResponseFut: std::future::Future<Output = Result<ControllerCreateGuestResult, fidl::Error>>
88 + Send;
89 fn r#create_guest(
90 &self,
91 name: &str,
92 network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
93 mac: Option<&fidl_fuchsia_net::MacAddress>,
94 ) -> Self::CreateGuestResponseFut;
95}
96#[derive(Debug)]
97#[cfg(target_os = "fuchsia")]
98pub struct ControllerSynchronousProxy {
99 client: fidl::client::sync::Client,
100}
101
102#[cfg(target_os = "fuchsia")]
103impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
104 type Proxy = ControllerProxy;
105 type Protocol = ControllerMarker;
106
107 fn from_channel(inner: fidl::Channel) -> Self {
108 Self::new(inner)
109 }
110
111 fn into_channel(self) -> fidl::Channel {
112 self.client.into_channel()
113 }
114
115 fn as_channel(&self) -> &fidl::Channel {
116 self.client.as_channel()
117 }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl ControllerSynchronousProxy {
122 pub fn new(channel: fidl::Channel) -> Self {
123 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
124 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
125 }
126
127 pub fn into_channel(self) -> fidl::Channel {
128 self.client.into_channel()
129 }
130
131 pub fn wait_for_event(
134 &self,
135 deadline: zx::MonotonicInstant,
136 ) -> Result<ControllerEvent, fidl::Error> {
137 ControllerEvent::decode(self.client.wait_for_event(deadline)?)
138 }
139
140 pub fn r#create_guest(
154 &self,
155 mut name: &str,
156 mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
157 mut mac: Option<&fidl_fuchsia_net::MacAddress>,
158 ___deadline: zx::MonotonicInstant,
159 ) -> Result<ControllerCreateGuestResult, fidl::Error> {
160 let _response =
161 self.client.send_query::<ControllerCreateGuestRequest, fidl::encoding::ResultType<
162 ControllerCreateGuestResponse,
163 ControllerCreateGuestError,
164 >>(
165 (name, network, mac),
166 0x5c49cf5272f818c0,
167 fidl::encoding::DynamicFlags::empty(),
168 ___deadline,
169 )?;
170 Ok(_response.map(|x| x.s))
171 }
172}
173
174#[derive(Debug, Clone)]
175pub struct ControllerProxy {
176 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
177}
178
179impl fidl::endpoints::Proxy for ControllerProxy {
180 type Protocol = ControllerMarker;
181
182 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
183 Self::new(inner)
184 }
185
186 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
187 self.client.into_channel().map_err(|client| Self { client })
188 }
189
190 fn as_channel(&self) -> &::fidl::AsyncChannel {
191 self.client.as_channel()
192 }
193}
194
195impl ControllerProxy {
196 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
198 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
199 Self { client: fidl::client::Client::new(channel, protocol_name) }
200 }
201
202 pub fn take_event_stream(&self) -> ControllerEventStream {
208 ControllerEventStream { event_receiver: self.client.take_event_receiver() }
209 }
210
211 pub fn r#create_guest(
225 &self,
226 mut name: &str,
227 mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
228 mut mac: Option<&fidl_fuchsia_net::MacAddress>,
229 ) -> fidl::client::QueryResponseFut<
230 ControllerCreateGuestResult,
231 fidl::encoding::DefaultFuchsiaResourceDialect,
232 > {
233 ControllerProxyInterface::r#create_guest(self, name, network, mac)
234 }
235}
236
237impl ControllerProxyInterface for ControllerProxy {
238 type CreateGuestResponseFut = fidl::client::QueryResponseFut<
239 ControllerCreateGuestResult,
240 fidl::encoding::DefaultFuchsiaResourceDialect,
241 >;
242 fn r#create_guest(
243 &self,
244 mut name: &str,
245 mut network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
246 mut mac: Option<&fidl_fuchsia_net::MacAddress>,
247 ) -> Self::CreateGuestResponseFut {
248 fn _decode(
249 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
250 ) -> Result<ControllerCreateGuestResult, fidl::Error> {
251 let _response = fidl::client::decode_transaction_body::<
252 fidl::encoding::ResultType<
253 ControllerCreateGuestResponse,
254 ControllerCreateGuestError,
255 >,
256 fidl::encoding::DefaultFuchsiaResourceDialect,
257 0x5c49cf5272f818c0,
258 >(_buf?)?;
259 Ok(_response.map(|x| x.s))
260 }
261 self.client
262 .send_query_and_decode::<ControllerCreateGuestRequest, ControllerCreateGuestResult>(
263 (name, network, mac),
264 0x5c49cf5272f818c0,
265 fidl::encoding::DynamicFlags::empty(),
266 _decode,
267 )
268 }
269}
270
271pub struct ControllerEventStream {
272 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
273}
274
275impl std::marker::Unpin for ControllerEventStream {}
276
277impl futures::stream::FusedStream for ControllerEventStream {
278 fn is_terminated(&self) -> bool {
279 self.event_receiver.is_terminated()
280 }
281}
282
283impl futures::Stream for ControllerEventStream {
284 type Item = Result<ControllerEvent, fidl::Error>;
285
286 fn poll_next(
287 mut self: std::pin::Pin<&mut Self>,
288 cx: &mut std::task::Context<'_>,
289 ) -> std::task::Poll<Option<Self::Item>> {
290 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
291 &mut self.event_receiver,
292 cx
293 )?) {
294 Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
295 None => std::task::Poll::Ready(None),
296 }
297 }
298}
299
300#[derive(Debug)]
301pub enum ControllerEvent {}
302
303impl ControllerEvent {
304 fn decode(
306 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
307 ) -> Result<ControllerEvent, fidl::Error> {
308 let (bytes, _handles) = buf.split_mut();
309 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310 debug_assert_eq!(tx_header.tx_id, 0);
311 match tx_header.ordinal {
312 _ => Err(fidl::Error::UnknownOrdinal {
313 ordinal: tx_header.ordinal,
314 protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
315 }),
316 }
317 }
318}
319
320pub struct ControllerRequestStream {
322 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
323 is_terminated: bool,
324}
325
326impl std::marker::Unpin for ControllerRequestStream {}
327
328impl futures::stream::FusedStream for ControllerRequestStream {
329 fn is_terminated(&self) -> bool {
330 self.is_terminated
331 }
332}
333
334impl fidl::endpoints::RequestStream for ControllerRequestStream {
335 type Protocol = ControllerMarker;
336 type ControlHandle = ControllerControlHandle;
337
338 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
339 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
340 }
341
342 fn control_handle(&self) -> Self::ControlHandle {
343 ControllerControlHandle { inner: self.inner.clone() }
344 }
345
346 fn into_inner(
347 self,
348 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
349 {
350 (self.inner, self.is_terminated)
351 }
352
353 fn from_inner(
354 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355 is_terminated: bool,
356 ) -> Self {
357 Self { inner, is_terminated }
358 }
359}
360
361impl futures::Stream for ControllerRequestStream {
362 type Item = Result<ControllerRequest, fidl::Error>;
363
364 fn poll_next(
365 mut self: std::pin::Pin<&mut Self>,
366 cx: &mut std::task::Context<'_>,
367 ) -> std::task::Poll<Option<Self::Item>> {
368 let this = &mut *self;
369 if this.inner.check_shutdown(cx) {
370 this.is_terminated = true;
371 return std::task::Poll::Ready(None);
372 }
373 if this.is_terminated {
374 panic!("polled ControllerRequestStream after completion");
375 }
376 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
377 |bytes, handles| {
378 match this.inner.channel().read_etc(cx, bytes, handles) {
379 std::task::Poll::Ready(Ok(())) => {}
380 std::task::Poll::Pending => return std::task::Poll::Pending,
381 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
382 this.is_terminated = true;
383 return std::task::Poll::Ready(None);
384 }
385 std::task::Poll::Ready(Err(e)) => {
386 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
387 e.into(),
388 ))))
389 }
390 }
391
392 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
394
395 std::task::Poll::Ready(Some(match header.ordinal {
396 0x5c49cf5272f818c0 => {
397 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
398 let mut req = fidl::new_empty!(
399 ControllerCreateGuestRequest,
400 fidl::encoding::DefaultFuchsiaResourceDialect
401 );
402 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerCreateGuestRequest>(&header, _body_bytes, handles, &mut req)?;
403 let control_handle = ControllerControlHandle { inner: this.inner.clone() };
404 Ok(ControllerRequest::CreateGuest {
405 name: req.name,
406 network: req.network,
407 mac: req.mac,
408
409 responder: ControllerCreateGuestResponder {
410 control_handle: std::mem::ManuallyDrop::new(control_handle),
411 tx_id: header.tx_id,
412 },
413 })
414 }
415 _ => Err(fidl::Error::UnknownOrdinal {
416 ordinal: header.ordinal,
417 protocol_name:
418 <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
419 }),
420 }))
421 },
422 )
423 }
424}
425
426#[derive(Debug)]
428pub enum ControllerRequest {
429 CreateGuest {
443 name: String,
444 network: fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
445 mac: Option<Box<fidl_fuchsia_net::MacAddress>>,
446 responder: ControllerCreateGuestResponder,
447 },
448}
449
450impl ControllerRequest {
451 #[allow(irrefutable_let_patterns)]
452 pub fn into_create_guest(
453 self,
454 ) -> Option<(
455 String,
456 fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
457 Option<Box<fidl_fuchsia_net::MacAddress>>,
458 ControllerCreateGuestResponder,
459 )> {
460 if let ControllerRequest::CreateGuest { name, network, mac, responder } = self {
461 Some((name, network, mac, responder))
462 } else {
463 None
464 }
465 }
466
467 pub fn method_name(&self) -> &'static str {
469 match *self {
470 ControllerRequest::CreateGuest { .. } => "create_guest",
471 }
472 }
473}
474
475#[derive(Debug, Clone)]
476pub struct ControllerControlHandle {
477 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
478}
479
480impl fidl::endpoints::ControlHandle for ControllerControlHandle {
481 fn shutdown(&self) {
482 self.inner.shutdown()
483 }
484 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
485 self.inner.shutdown_with_epitaph(status)
486 }
487
488 fn is_closed(&self) -> bool {
489 self.inner.channel().is_closed()
490 }
491 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
492 self.inner.channel().on_closed()
493 }
494
495 #[cfg(target_os = "fuchsia")]
496 fn signal_peer(
497 &self,
498 clear_mask: zx::Signals,
499 set_mask: zx::Signals,
500 ) -> Result<(), zx_status::Status> {
501 use fidl::Peered;
502 self.inner.channel().signal_peer(clear_mask, set_mask)
503 }
504}
505
506impl ControllerControlHandle {}
507
508#[must_use = "FIDL methods require a response to be sent"]
509#[derive(Debug)]
510pub struct ControllerCreateGuestResponder {
511 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
512 tx_id: u32,
513}
514
515impl std::ops::Drop for ControllerCreateGuestResponder {
519 fn drop(&mut self) {
520 self.control_handle.shutdown();
521 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
523 }
524}
525
526impl fidl::endpoints::Responder for ControllerCreateGuestResponder {
527 type ControlHandle = ControllerControlHandle;
528
529 fn control_handle(&self) -> &ControllerControlHandle {
530 &self.control_handle
531 }
532
533 fn drop_without_shutdown(mut self) {
534 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
536 std::mem::forget(self);
538 }
539}
540
541impl ControllerCreateGuestResponder {
542 pub fn send(
546 self,
547 mut result: Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
548 ) -> Result<(), fidl::Error> {
549 let _result = self.send_raw(result);
550 if _result.is_err() {
551 self.control_handle.shutdown();
552 }
553 self.drop_without_shutdown();
554 _result
555 }
556
557 pub fn send_no_shutdown_on_err(
559 self,
560 mut result: Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
561 ) -> Result<(), fidl::Error> {
562 let _result = self.send_raw(result);
563 self.drop_without_shutdown();
564 _result
565 }
566
567 fn send_raw(
568 &self,
569 mut result: Result<fidl::endpoints::ClientEnd<GuestMarker>, ControllerCreateGuestError>,
570 ) -> Result<(), fidl::Error> {
571 self.control_handle.inner.send::<fidl::encoding::ResultType<
572 ControllerCreateGuestResponse,
573 ControllerCreateGuestError,
574 >>(
575 result.map(|s| (s,)),
576 self.tx_id,
577 0x5c49cf5272f818c0,
578 fidl::encoding::DynamicFlags::empty(),
579 )
580 }
581}
582
583#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
584pub struct GuestMarker;
585
586impl fidl::endpoints::ProtocolMarker for GuestMarker {
587 type Proxy = GuestProxy;
588 type RequestStream = GuestRequestStream;
589 #[cfg(target_os = "fuchsia")]
590 type SynchronousProxy = GuestSynchronousProxy;
591
592 const DEBUG_NAME: &'static str = "(anonymous) Guest";
593}
594
595pub trait GuestProxyInterface: Send + Sync {
596 type PutFileResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
597 fn r#put_file(
598 &self,
599 local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
600 remote_path: &str,
601 ) -> Self::PutFileResponseFut;
602 type GetFileResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
603 fn r#get_file(
604 &self,
605 remote_path: &str,
606 local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
607 ) -> Self::GetFileResponseFut;
608 fn r#execute_command(
609 &self,
610 command: &str,
611 env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
612 stdin: Option<fidl::Socket>,
613 stdout: Option<fidl::Socket>,
614 stderr: Option<fidl::Socket>,
615 command_listener: fidl::endpoints::ServerEnd<
616 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
617 >,
618 ) -> Result<(), fidl::Error>;
619 type ShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
620 fn r#shutdown(&self) -> Self::ShutdownResponseFut;
621}
622#[derive(Debug)]
623#[cfg(target_os = "fuchsia")]
624pub struct GuestSynchronousProxy {
625 client: fidl::client::sync::Client,
626}
627
628#[cfg(target_os = "fuchsia")]
629impl fidl::endpoints::SynchronousProxy for GuestSynchronousProxy {
630 type Proxy = GuestProxy;
631 type Protocol = GuestMarker;
632
633 fn from_channel(inner: fidl::Channel) -> Self {
634 Self::new(inner)
635 }
636
637 fn into_channel(self) -> fidl::Channel {
638 self.client.into_channel()
639 }
640
641 fn as_channel(&self) -> &fidl::Channel {
642 self.client.as_channel()
643 }
644}
645
646#[cfg(target_os = "fuchsia")]
647impl GuestSynchronousProxy {
648 pub fn new(channel: fidl::Channel) -> Self {
649 let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
650 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
651 }
652
653 pub fn into_channel(self) -> fidl::Channel {
654 self.client.into_channel()
655 }
656
657 pub fn wait_for_event(
660 &self,
661 deadline: zx::MonotonicInstant,
662 ) -> Result<GuestEvent, fidl::Error> {
663 GuestEvent::decode(self.client.wait_for_event(deadline)?)
664 }
665
666 pub fn r#put_file(
669 &self,
670 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
671 mut remote_path: &str,
672 ___deadline: zx::MonotonicInstant,
673 ) -> Result<i32, fidl::Error> {
674 let _response = self.client.send_query::<
675 fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest,
676 fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse,
677 >(
678 (local_file, remote_path,),
679 0x223bc20da4a7cddd,
680 fidl::encoding::DynamicFlags::empty(),
681 ___deadline,
682 )?;
683 Ok(_response.status)
684 }
685
686 pub fn r#get_file(
689 &self,
690 mut remote_path: &str,
691 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
692 ___deadline: zx::MonotonicInstant,
693 ) -> Result<i32, fidl::Error> {
694 let _response = self.client.send_query::<
695 fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest,
696 fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse,
697 >(
698 (remote_path, local_file,),
699 0x7696bea472ca0f2d,
700 fidl::encoding::DynamicFlags::empty(),
701 ___deadline,
702 )?;
703 Ok(_response.status)
704 }
705
706 pub fn r#execute_command(
709 &self,
710 mut command: &str,
711 mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
712 mut stdin: Option<fidl::Socket>,
713 mut stdout: Option<fidl::Socket>,
714 mut stderr: Option<fidl::Socket>,
715 mut command_listener: fidl::endpoints::ServerEnd<
716 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
717 >,
718 ) -> Result<(), fidl::Error> {
719 self.client.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(
720 (command, env, stdin, stdout, stderr, command_listener,),
721 0x612641220a1556d8,
722 fidl::encoding::DynamicFlags::empty(),
723 )
724 }
725
726 pub fn r#shutdown(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
729 let _response =
730 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
731 (),
732 0x287e71d61642d1cc,
733 fidl::encoding::DynamicFlags::empty(),
734 ___deadline,
735 )?;
736 Ok(_response)
737 }
738}
739
740#[derive(Debug, Clone)]
741pub struct GuestProxy {
742 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
743}
744
745impl fidl::endpoints::Proxy for GuestProxy {
746 type Protocol = GuestMarker;
747
748 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
749 Self::new(inner)
750 }
751
752 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
753 self.client.into_channel().map_err(|client| Self { client })
754 }
755
756 fn as_channel(&self) -> &::fidl::AsyncChannel {
757 self.client.as_channel()
758 }
759}
760
761impl GuestProxy {
762 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
764 let protocol_name = <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
765 Self { client: fidl::client::Client::new(channel, protocol_name) }
766 }
767
768 pub fn take_event_stream(&self) -> GuestEventStream {
774 GuestEventStream { event_receiver: self.client.take_event_receiver() }
775 }
776
777 pub fn r#put_file(
780 &self,
781 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
782 mut remote_path: &str,
783 ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
784 GuestProxyInterface::r#put_file(self, local_file, remote_path)
785 }
786
787 pub fn r#get_file(
790 &self,
791 mut remote_path: &str,
792 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
793 ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
794 GuestProxyInterface::r#get_file(self, remote_path, local_file)
795 }
796
797 pub fn r#execute_command(
800 &self,
801 mut command: &str,
802 mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
803 mut stdin: Option<fidl::Socket>,
804 mut stdout: Option<fidl::Socket>,
805 mut stderr: Option<fidl::Socket>,
806 mut command_listener: fidl::endpoints::ServerEnd<
807 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
808 >,
809 ) -> Result<(), fidl::Error> {
810 GuestProxyInterface::r#execute_command(
811 self,
812 command,
813 env,
814 stdin,
815 stdout,
816 stderr,
817 command_listener,
818 )
819 }
820
821 pub fn r#shutdown(
824 &self,
825 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
826 GuestProxyInterface::r#shutdown(self)
827 }
828}
829
830impl GuestProxyInterface for GuestProxy {
831 type PutFileResponseFut =
832 fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
833 fn r#put_file(
834 &self,
835 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
836 mut remote_path: &str,
837 ) -> Self::PutFileResponseFut {
838 fn _decode(
839 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
840 ) -> Result<i32, fidl::Error> {
841 let _response = fidl::client::decode_transaction_body::<
842 fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse,
843 fidl::encoding::DefaultFuchsiaResourceDialect,
844 0x223bc20da4a7cddd,
845 >(_buf?)?;
846 Ok(_response.status)
847 }
848 self.client.send_query_and_decode::<
849 fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest,
850 i32,
851 >(
852 (local_file, remote_path,),
853 0x223bc20da4a7cddd,
854 fidl::encoding::DynamicFlags::empty(),
855 _decode,
856 )
857 }
858
859 type GetFileResponseFut =
860 fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
861 fn r#get_file(
862 &self,
863 mut remote_path: &str,
864 mut local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
865 ) -> Self::GetFileResponseFut {
866 fn _decode(
867 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
868 ) -> Result<i32, fidl::Error> {
869 let _response = fidl::client::decode_transaction_body::<
870 fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse,
871 fidl::encoding::DefaultFuchsiaResourceDialect,
872 0x7696bea472ca0f2d,
873 >(_buf?)?;
874 Ok(_response.status)
875 }
876 self.client.send_query_and_decode::<
877 fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest,
878 i32,
879 >(
880 (remote_path, local_file,),
881 0x7696bea472ca0f2d,
882 fidl::encoding::DynamicFlags::empty(),
883 _decode,
884 )
885 }
886
887 fn r#execute_command(
888 &self,
889 mut command: &str,
890 mut env: &[fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable],
891 mut stdin: Option<fidl::Socket>,
892 mut stdout: Option<fidl::Socket>,
893 mut stderr: Option<fidl::Socket>,
894 mut command_listener: fidl::endpoints::ServerEnd<
895 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
896 >,
897 ) -> Result<(), fidl::Error> {
898 self.client.send::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(
899 (command, env, stdin, stdout, stderr, command_listener,),
900 0x612641220a1556d8,
901 fidl::encoding::DynamicFlags::empty(),
902 )
903 }
904
905 type ShutdownResponseFut =
906 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
907 fn r#shutdown(&self) -> Self::ShutdownResponseFut {
908 fn _decode(
909 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
910 ) -> Result<(), fidl::Error> {
911 let _response = fidl::client::decode_transaction_body::<
912 fidl::encoding::EmptyPayload,
913 fidl::encoding::DefaultFuchsiaResourceDialect,
914 0x287e71d61642d1cc,
915 >(_buf?)?;
916 Ok(_response)
917 }
918 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
919 (),
920 0x287e71d61642d1cc,
921 fidl::encoding::DynamicFlags::empty(),
922 _decode,
923 )
924 }
925}
926
927pub struct GuestEventStream {
928 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
929}
930
931impl std::marker::Unpin for GuestEventStream {}
932
933impl futures::stream::FusedStream for GuestEventStream {
934 fn is_terminated(&self) -> bool {
935 self.event_receiver.is_terminated()
936 }
937}
938
939impl futures::Stream for GuestEventStream {
940 type Item = Result<GuestEvent, fidl::Error>;
941
942 fn poll_next(
943 mut self: std::pin::Pin<&mut Self>,
944 cx: &mut std::task::Context<'_>,
945 ) -> std::task::Poll<Option<Self::Item>> {
946 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
947 &mut self.event_receiver,
948 cx
949 )?) {
950 Some(buf) => std::task::Poll::Ready(Some(GuestEvent::decode(buf))),
951 None => std::task::Poll::Ready(None),
952 }
953 }
954}
955
956#[derive(Debug)]
957pub enum GuestEvent {}
958
959impl GuestEvent {
960 fn decode(
962 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
963 ) -> Result<GuestEvent, fidl::Error> {
964 let (bytes, _handles) = buf.split_mut();
965 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
966 debug_assert_eq!(tx_header.tx_id, 0);
967 match tx_header.ordinal {
968 _ => Err(fidl::Error::UnknownOrdinal {
969 ordinal: tx_header.ordinal,
970 protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
971 }),
972 }
973 }
974}
975
976pub struct GuestRequestStream {
978 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
979 is_terminated: bool,
980}
981
982impl std::marker::Unpin for GuestRequestStream {}
983
984impl futures::stream::FusedStream for GuestRequestStream {
985 fn is_terminated(&self) -> bool {
986 self.is_terminated
987 }
988}
989
990impl fidl::endpoints::RequestStream for GuestRequestStream {
991 type Protocol = GuestMarker;
992 type ControlHandle = GuestControlHandle;
993
994 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
995 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
996 }
997
998 fn control_handle(&self) -> Self::ControlHandle {
999 GuestControlHandle { inner: self.inner.clone() }
1000 }
1001
1002 fn into_inner(
1003 self,
1004 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1005 {
1006 (self.inner, self.is_terminated)
1007 }
1008
1009 fn from_inner(
1010 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1011 is_terminated: bool,
1012 ) -> Self {
1013 Self { inner, is_terminated }
1014 }
1015}
1016
1017impl futures::Stream for GuestRequestStream {
1018 type Item = Result<GuestRequest, fidl::Error>;
1019
1020 fn poll_next(
1021 mut self: std::pin::Pin<&mut Self>,
1022 cx: &mut std::task::Context<'_>,
1023 ) -> std::task::Poll<Option<Self::Item>> {
1024 let this = &mut *self;
1025 if this.inner.check_shutdown(cx) {
1026 this.is_terminated = true;
1027 return std::task::Poll::Ready(None);
1028 }
1029 if this.is_terminated {
1030 panic!("polled GuestRequestStream after completion");
1031 }
1032 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1033 |bytes, handles| {
1034 match this.inner.channel().read_etc(cx, bytes, handles) {
1035 std::task::Poll::Ready(Ok(())) => {}
1036 std::task::Poll::Pending => return std::task::Poll::Pending,
1037 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1038 this.is_terminated = true;
1039 return std::task::Poll::Ready(None);
1040 }
1041 std::task::Poll::Ready(Err(e)) => {
1042 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1043 e.into(),
1044 ))))
1045 }
1046 }
1047
1048 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1050
1051 std::task::Poll::Ready(Some(match header.ordinal {
1052 0x223bc20da4a7cddd => {
1053 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1054 let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1055 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileRequest>(&header, _body_bytes, handles, &mut req)?;
1056 let control_handle = GuestControlHandle { inner: this.inner.clone() };
1057 Ok(GuestRequest::PutFile {
1058 local_file: req.local_file,
1059 remote_path: req.remote_path,
1060
1061 responder: GuestPutFileResponder {
1062 control_handle: std::mem::ManuallyDrop::new(control_handle),
1063 tx_id: header.tx_id,
1064 },
1065 })
1066 }
1067 0x7696bea472ca0f2d => {
1068 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1069 let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1070 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileRequest>(&header, _body_bytes, handles, &mut req)?;
1071 let control_handle = GuestControlHandle { inner: this.inner.clone() };
1072 Ok(GuestRequest::GetFile {
1073 remote_path: req.remote_path,
1074 local_file: req.local_file,
1075
1076 responder: GuestGetFileResponder {
1077 control_handle: std::mem::ManuallyDrop::new(control_handle),
1078 tx_id: header.tx_id,
1079 },
1080 })
1081 }
1082 0x612641220a1556d8 => {
1083 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1084 let mut req = fidl::new_empty!(fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1085 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_virtualization_guest_interaction::InteractionExecuteCommandRequest>(&header, _body_bytes, handles, &mut req)?;
1086 let control_handle = GuestControlHandle { inner: this.inner.clone() };
1087 Ok(GuestRequest::ExecuteCommand {
1088 command: req.command,
1089 env: req.env,
1090 stdin: req.stdin,
1091 stdout: req.stdout,
1092 stderr: req.stderr,
1093 command_listener: req.command_listener,
1094
1095 control_handle,
1096 })
1097 }
1098 0x287e71d61642d1cc => {
1099 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1100 let mut req = fidl::new_empty!(
1101 fidl::encoding::EmptyPayload,
1102 fidl::encoding::DefaultFuchsiaResourceDialect
1103 );
1104 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1105 let control_handle = GuestControlHandle { inner: this.inner.clone() };
1106 Ok(GuestRequest::Shutdown {
1107 responder: GuestShutdownResponder {
1108 control_handle: std::mem::ManuallyDrop::new(control_handle),
1109 tx_id: header.tx_id,
1110 },
1111 })
1112 }
1113 _ => Err(fidl::Error::UnknownOrdinal {
1114 ordinal: header.ordinal,
1115 protocol_name: <GuestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1116 }),
1117 }))
1118 },
1119 )
1120 }
1121}
1122
1123#[derive(Debug)]
1132pub enum GuestRequest {
1133 PutFile {
1136 local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1137 remote_path: String,
1138 responder: GuestPutFileResponder,
1139 },
1140 GetFile {
1143 remote_path: String,
1144 local_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1145 responder: GuestGetFileResponder,
1146 },
1147 ExecuteCommand {
1150 command: String,
1151 env: Vec<fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable>,
1152 stdin: Option<fidl::Socket>,
1153 stdout: Option<fidl::Socket>,
1154 stderr: Option<fidl::Socket>,
1155 command_listener: fidl::endpoints::ServerEnd<
1156 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
1157 >,
1158 control_handle: GuestControlHandle,
1159 },
1160 Shutdown { responder: GuestShutdownResponder },
1163}
1164
1165impl GuestRequest {
1166 #[allow(irrefutable_let_patterns)]
1167 pub fn into_put_file(
1168 self,
1169 ) -> Option<(
1170 fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1171 String,
1172 GuestPutFileResponder,
1173 )> {
1174 if let GuestRequest::PutFile { local_file, remote_path, responder } = self {
1175 Some((local_file, remote_path, responder))
1176 } else {
1177 None
1178 }
1179 }
1180
1181 #[allow(irrefutable_let_patterns)]
1182 pub fn into_get_file(
1183 self,
1184 ) -> Option<(
1185 String,
1186 fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1187 GuestGetFileResponder,
1188 )> {
1189 if let GuestRequest::GetFile { remote_path, local_file, responder } = self {
1190 Some((remote_path, local_file, responder))
1191 } else {
1192 None
1193 }
1194 }
1195
1196 #[allow(irrefutable_let_patterns)]
1197 pub fn into_execute_command(
1198 self,
1199 ) -> Option<(
1200 String,
1201 Vec<fidl_fuchsia_virtualization_guest_interaction::EnvironmentVariable>,
1202 Option<fidl::Socket>,
1203 Option<fidl::Socket>,
1204 Option<fidl::Socket>,
1205 fidl::endpoints::ServerEnd<
1206 fidl_fuchsia_virtualization_guest_interaction::CommandListenerMarker,
1207 >,
1208 GuestControlHandle,
1209 )> {
1210 if let GuestRequest::ExecuteCommand {
1211 command,
1212 env,
1213 stdin,
1214 stdout,
1215 stderr,
1216 command_listener,
1217 control_handle,
1218 } = self
1219 {
1220 Some((command, env, stdin, stdout, stderr, command_listener, control_handle))
1221 } else {
1222 None
1223 }
1224 }
1225
1226 #[allow(irrefutable_let_patterns)]
1227 pub fn into_shutdown(self) -> Option<(GuestShutdownResponder)> {
1228 if let GuestRequest::Shutdown { responder } = self {
1229 Some((responder))
1230 } else {
1231 None
1232 }
1233 }
1234
1235 pub fn method_name(&self) -> &'static str {
1237 match *self {
1238 GuestRequest::PutFile { .. } => "put_file",
1239 GuestRequest::GetFile { .. } => "get_file",
1240 GuestRequest::ExecuteCommand { .. } => "execute_command",
1241 GuestRequest::Shutdown { .. } => "shutdown",
1242 }
1243 }
1244}
1245
1246#[derive(Debug, Clone)]
1247pub struct GuestControlHandle {
1248 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1249}
1250
1251impl fidl::endpoints::ControlHandle for GuestControlHandle {
1252 fn shutdown(&self) {
1253 self.inner.shutdown()
1254 }
1255 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1256 self.inner.shutdown_with_epitaph(status)
1257 }
1258
1259 fn is_closed(&self) -> bool {
1260 self.inner.channel().is_closed()
1261 }
1262 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1263 self.inner.channel().on_closed()
1264 }
1265
1266 #[cfg(target_os = "fuchsia")]
1267 fn signal_peer(
1268 &self,
1269 clear_mask: zx::Signals,
1270 set_mask: zx::Signals,
1271 ) -> Result<(), zx_status::Status> {
1272 use fidl::Peered;
1273 self.inner.channel().signal_peer(clear_mask, set_mask)
1274 }
1275}
1276
1277impl GuestControlHandle {}
1278
1279#[must_use = "FIDL methods require a response to be sent"]
1280#[derive(Debug)]
1281pub struct GuestPutFileResponder {
1282 control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
1283 tx_id: u32,
1284}
1285
1286impl std::ops::Drop for GuestPutFileResponder {
1290 fn drop(&mut self) {
1291 self.control_handle.shutdown();
1292 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1294 }
1295}
1296
1297impl fidl::endpoints::Responder for GuestPutFileResponder {
1298 type ControlHandle = GuestControlHandle;
1299
1300 fn control_handle(&self) -> &GuestControlHandle {
1301 &self.control_handle
1302 }
1303
1304 fn drop_without_shutdown(mut self) {
1305 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1307 std::mem::forget(self);
1309 }
1310}
1311
1312impl GuestPutFileResponder {
1313 pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
1317 let _result = self.send_raw(status);
1318 if _result.is_err() {
1319 self.control_handle.shutdown();
1320 }
1321 self.drop_without_shutdown();
1322 _result
1323 }
1324
1325 pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
1327 let _result = self.send_raw(status);
1328 self.drop_without_shutdown();
1329 _result
1330 }
1331
1332 fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
1333 self.control_handle
1334 .inner
1335 .send::<fidl_fuchsia_virtualization_guest_interaction::InteractionPutFileResponse>(
1336 (status,),
1337 self.tx_id,
1338 0x223bc20da4a7cddd,
1339 fidl::encoding::DynamicFlags::empty(),
1340 )
1341 }
1342}
1343
1344#[must_use = "FIDL methods require a response to be sent"]
1345#[derive(Debug)]
1346pub struct GuestGetFileResponder {
1347 control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
1348 tx_id: u32,
1349}
1350
1351impl std::ops::Drop for GuestGetFileResponder {
1355 fn drop(&mut self) {
1356 self.control_handle.shutdown();
1357 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1359 }
1360}
1361
1362impl fidl::endpoints::Responder for GuestGetFileResponder {
1363 type ControlHandle = GuestControlHandle;
1364
1365 fn control_handle(&self) -> &GuestControlHandle {
1366 &self.control_handle
1367 }
1368
1369 fn drop_without_shutdown(mut self) {
1370 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1372 std::mem::forget(self);
1374 }
1375}
1376
1377impl GuestGetFileResponder {
1378 pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
1382 let _result = self.send_raw(status);
1383 if _result.is_err() {
1384 self.control_handle.shutdown();
1385 }
1386 self.drop_without_shutdown();
1387 _result
1388 }
1389
1390 pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
1392 let _result = self.send_raw(status);
1393 self.drop_without_shutdown();
1394 _result
1395 }
1396
1397 fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
1398 self.control_handle
1399 .inner
1400 .send::<fidl_fuchsia_virtualization_guest_interaction::InteractionGetFileResponse>(
1401 (status,),
1402 self.tx_id,
1403 0x7696bea472ca0f2d,
1404 fidl::encoding::DynamicFlags::empty(),
1405 )
1406 }
1407}
1408
1409#[must_use = "FIDL methods require a response to be sent"]
1410#[derive(Debug)]
1411pub struct GuestShutdownResponder {
1412 control_handle: std::mem::ManuallyDrop<GuestControlHandle>,
1413 tx_id: u32,
1414}
1415
1416impl std::ops::Drop for GuestShutdownResponder {
1420 fn drop(&mut self) {
1421 self.control_handle.shutdown();
1422 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1424 }
1425}
1426
1427impl fidl::endpoints::Responder for GuestShutdownResponder {
1428 type ControlHandle = GuestControlHandle;
1429
1430 fn control_handle(&self) -> &GuestControlHandle {
1431 &self.control_handle
1432 }
1433
1434 fn drop_without_shutdown(mut self) {
1435 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1437 std::mem::forget(self);
1439 }
1440}
1441
1442impl GuestShutdownResponder {
1443 pub fn send(self) -> Result<(), fidl::Error> {
1447 let _result = self.send_raw();
1448 if _result.is_err() {
1449 self.control_handle.shutdown();
1450 }
1451 self.drop_without_shutdown();
1452 _result
1453 }
1454
1455 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1457 let _result = self.send_raw();
1458 self.drop_without_shutdown();
1459 _result
1460 }
1461
1462 fn send_raw(&self) -> Result<(), fidl::Error> {
1463 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1464 (),
1465 self.tx_id,
1466 0x287e71d61642d1cc,
1467 fidl::encoding::DynamicFlags::empty(),
1468 )
1469 }
1470}
1471
1472mod internal {
1473 use super::*;
1474 unsafe impl fidl::encoding::TypeMarker for ControllerCreateGuestError {
1475 type Owned = Self;
1476
1477 #[inline(always)]
1478 fn inline_align(_context: fidl::encoding::Context) -> usize {
1479 std::mem::align_of::<u32>()
1480 }
1481
1482 #[inline(always)]
1483 fn inline_size(_context: fidl::encoding::Context) -> usize {
1484 std::mem::size_of::<u32>()
1485 }
1486
1487 #[inline(always)]
1488 fn encode_is_copy() -> bool {
1489 true
1490 }
1491
1492 #[inline(always)]
1493 fn decode_is_copy() -> bool {
1494 false
1495 }
1496 }
1497
1498 impl fidl::encoding::ValueTypeMarker for ControllerCreateGuestError {
1499 type Borrowed<'a> = Self;
1500 #[inline(always)]
1501 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1502 *value
1503 }
1504 }
1505
1506 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1507 for ControllerCreateGuestError
1508 {
1509 #[inline]
1510 unsafe fn encode(
1511 self,
1512 encoder: &mut fidl::encoding::Encoder<'_, D>,
1513 offset: usize,
1514 _depth: fidl::encoding::Depth,
1515 ) -> fidl::Result<()> {
1516 encoder.debug_check_bounds::<Self>(offset);
1517 encoder.write_num(self.into_primitive(), offset);
1518 Ok(())
1519 }
1520 }
1521
1522 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1523 for ControllerCreateGuestError
1524 {
1525 #[inline(always)]
1526 fn new_empty() -> Self {
1527 Self::AlreadyRunning
1528 }
1529
1530 #[inline]
1531 unsafe fn decode(
1532 &mut self,
1533 decoder: &mut fidl::encoding::Decoder<'_, D>,
1534 offset: usize,
1535 _depth: fidl::encoding::Depth,
1536 ) -> fidl::Result<()> {
1537 decoder.debug_check_bounds::<Self>(offset);
1538 let prim = decoder.read_num::<u32>(offset);
1539
1540 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1541 Ok(())
1542 }
1543 }
1544
1545 impl fidl::encoding::ResourceTypeMarker for ControllerCreateGuestRequest {
1546 type Borrowed<'a> = &'a mut Self;
1547 fn take_or_borrow<'a>(
1548 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1549 ) -> Self::Borrowed<'a> {
1550 value
1551 }
1552 }
1553
1554 unsafe impl fidl::encoding::TypeMarker for ControllerCreateGuestRequest {
1555 type Owned = Self;
1556
1557 #[inline(always)]
1558 fn inline_align(_context: fidl::encoding::Context) -> usize {
1559 8
1560 }
1561
1562 #[inline(always)]
1563 fn inline_size(_context: fidl::encoding::Context) -> usize {
1564 32
1565 }
1566 }
1567
1568 unsafe impl
1569 fidl::encoding::Encode<
1570 ControllerCreateGuestRequest,
1571 fidl::encoding::DefaultFuchsiaResourceDialect,
1572 > for &mut ControllerCreateGuestRequest
1573 {
1574 #[inline]
1575 unsafe fn encode(
1576 self,
1577 encoder: &mut fidl::encoding::Encoder<
1578 '_,
1579 fidl::encoding::DefaultFuchsiaResourceDialect,
1580 >,
1581 offset: usize,
1582 _depth: fidl::encoding::Depth,
1583 ) -> fidl::Result<()> {
1584 encoder.debug_check_bounds::<ControllerCreateGuestRequest>(offset);
1585 fidl::encoding::Encode::<ControllerCreateGuestRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1587 (
1588 <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1589 <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.network),
1590 <fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress> as fidl::encoding::ValueTypeMarker>::borrow(&self.mac),
1591 ),
1592 encoder, offset, _depth
1593 )
1594 }
1595 }
1596 unsafe impl<
1597 T0: fidl::encoding::Encode<
1598 fidl::encoding::BoundedString<32>,
1599 fidl::encoding::DefaultFuchsiaResourceDialect,
1600 >,
1601 T1: fidl::encoding::Encode<
1602 fidl::encoding::Endpoint<
1603 fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
1604 >,
1605 fidl::encoding::DefaultFuchsiaResourceDialect,
1606 >,
1607 T2: fidl::encoding::Encode<
1608 fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
1609 fidl::encoding::DefaultFuchsiaResourceDialect,
1610 >,
1611 >
1612 fidl::encoding::Encode<
1613 ControllerCreateGuestRequest,
1614 fidl::encoding::DefaultFuchsiaResourceDialect,
1615 > for (T0, T1, T2)
1616 {
1617 #[inline]
1618 unsafe fn encode(
1619 self,
1620 encoder: &mut fidl::encoding::Encoder<
1621 '_,
1622 fidl::encoding::DefaultFuchsiaResourceDialect,
1623 >,
1624 offset: usize,
1625 depth: fidl::encoding::Depth,
1626 ) -> fidl::Result<()> {
1627 encoder.debug_check_bounds::<ControllerCreateGuestRequest>(offset);
1628 unsafe {
1631 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1632 (ptr as *mut u64).write_unaligned(0);
1633 }
1634 self.0.encode(encoder, offset + 0, depth)?;
1636 self.1.encode(encoder, offset + 16, depth)?;
1637 self.2.encode(encoder, offset + 24, depth)?;
1638 Ok(())
1639 }
1640 }
1641
1642 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1643 for ControllerCreateGuestRequest
1644 {
1645 #[inline(always)]
1646 fn new_empty() -> Self {
1647 Self {
1648 name: fidl::new_empty!(
1649 fidl::encoding::BoundedString<32>,
1650 fidl::encoding::DefaultFuchsiaResourceDialect
1651 ),
1652 network: fidl::new_empty!(
1653 fidl::encoding::Endpoint<
1654 fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
1655 >,
1656 fidl::encoding::DefaultFuchsiaResourceDialect
1657 ),
1658 mac: fidl::new_empty!(
1659 fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
1660 fidl::encoding::DefaultFuchsiaResourceDialect
1661 ),
1662 }
1663 }
1664
1665 #[inline]
1666 unsafe fn decode(
1667 &mut self,
1668 decoder: &mut fidl::encoding::Decoder<
1669 '_,
1670 fidl::encoding::DefaultFuchsiaResourceDialect,
1671 >,
1672 offset: usize,
1673 _depth: fidl::encoding::Depth,
1674 ) -> fidl::Result<()> {
1675 decoder.debug_check_bounds::<Self>(offset);
1676 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1678 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1679 let mask = 0xffffffff00000000u64;
1680 let maskedval = padval & mask;
1681 if maskedval != 0 {
1682 return Err(fidl::Error::NonZeroPadding {
1683 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1684 });
1685 }
1686 fidl::decode!(
1687 fidl::encoding::BoundedString<32>,
1688 fidl::encoding::DefaultFuchsiaResourceDialect,
1689 &mut self.name,
1690 decoder,
1691 offset + 0,
1692 _depth
1693 )?;
1694 fidl::decode!(
1695 fidl::encoding::Endpoint<
1696 fidl::endpoints::ClientEnd<fidl_fuchsia_netemul_network::NetworkMarker>,
1697 >,
1698 fidl::encoding::DefaultFuchsiaResourceDialect,
1699 &mut self.network,
1700 decoder,
1701 offset + 16,
1702 _depth
1703 )?;
1704 fidl::decode!(
1705 fidl::encoding::Boxed<fidl_fuchsia_net::MacAddress>,
1706 fidl::encoding::DefaultFuchsiaResourceDialect,
1707 &mut self.mac,
1708 decoder,
1709 offset + 24,
1710 _depth
1711 )?;
1712 Ok(())
1713 }
1714 }
1715
1716 impl fidl::encoding::ResourceTypeMarker for ControllerCreateGuestResponse {
1717 type Borrowed<'a> = &'a mut Self;
1718 fn take_or_borrow<'a>(
1719 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1720 ) -> Self::Borrowed<'a> {
1721 value
1722 }
1723 }
1724
1725 unsafe impl fidl::encoding::TypeMarker for ControllerCreateGuestResponse {
1726 type Owned = Self;
1727
1728 #[inline(always)]
1729 fn inline_align(_context: fidl::encoding::Context) -> usize {
1730 4
1731 }
1732
1733 #[inline(always)]
1734 fn inline_size(_context: fidl::encoding::Context) -> usize {
1735 4
1736 }
1737 }
1738
1739 unsafe impl
1740 fidl::encoding::Encode<
1741 ControllerCreateGuestResponse,
1742 fidl::encoding::DefaultFuchsiaResourceDialect,
1743 > for &mut ControllerCreateGuestResponse
1744 {
1745 #[inline]
1746 unsafe fn encode(
1747 self,
1748 encoder: &mut fidl::encoding::Encoder<
1749 '_,
1750 fidl::encoding::DefaultFuchsiaResourceDialect,
1751 >,
1752 offset: usize,
1753 _depth: fidl::encoding::Depth,
1754 ) -> fidl::Result<()> {
1755 encoder.debug_check_bounds::<ControllerCreateGuestResponse>(offset);
1756 fidl::encoding::Encode::<ControllerCreateGuestResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1758 (
1759 <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.s),
1760 ),
1761 encoder, offset, _depth
1762 )
1763 }
1764 }
1765 unsafe impl<
1766 T0: fidl::encoding::Encode<
1767 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>>,
1768 fidl::encoding::DefaultFuchsiaResourceDialect,
1769 >,
1770 >
1771 fidl::encoding::Encode<
1772 ControllerCreateGuestResponse,
1773 fidl::encoding::DefaultFuchsiaResourceDialect,
1774 > for (T0,)
1775 {
1776 #[inline]
1777 unsafe fn encode(
1778 self,
1779 encoder: &mut fidl::encoding::Encoder<
1780 '_,
1781 fidl::encoding::DefaultFuchsiaResourceDialect,
1782 >,
1783 offset: usize,
1784 depth: fidl::encoding::Depth,
1785 ) -> fidl::Result<()> {
1786 encoder.debug_check_bounds::<ControllerCreateGuestResponse>(offset);
1787 self.0.encode(encoder, offset + 0, depth)?;
1791 Ok(())
1792 }
1793 }
1794
1795 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1796 for ControllerCreateGuestResponse
1797 {
1798 #[inline(always)]
1799 fn new_empty() -> Self {
1800 Self {
1801 s: fidl::new_empty!(
1802 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>>,
1803 fidl::encoding::DefaultFuchsiaResourceDialect
1804 ),
1805 }
1806 }
1807
1808 #[inline]
1809 unsafe fn decode(
1810 &mut self,
1811 decoder: &mut fidl::encoding::Decoder<
1812 '_,
1813 fidl::encoding::DefaultFuchsiaResourceDialect,
1814 >,
1815 offset: usize,
1816 _depth: fidl::encoding::Depth,
1817 ) -> fidl::Result<()> {
1818 decoder.debug_check_bounds::<Self>(offset);
1819 fidl::decode!(
1821 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<GuestMarker>>,
1822 fidl::encoding::DefaultFuchsiaResourceDialect,
1823 &mut self.s,
1824 decoder,
1825 offset + 0,
1826 _depth
1827 )?;
1828 Ok(())
1829 }
1830 }
1831}