Skip to main content

fidl_fuchsia_virtualization_guest_interaction__common/
fidl_fuchsia_virtualization_guest_interaction__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const DEFAULT_REALM: &str = "gis_default";
12
13pub const GUEST_EXECUTION_COMMAND_MAX_LENGTH: u32 = 8192;
14
15pub const GUEST_INTERACTION_MAX_LENGTH: u32 = 1024;
16
17pub const GUEST_NAME_MAX_LENGTH: u32 = 1024;
18
19/// The available guest types.
20#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21#[repr(u32)]
22pub enum GuestType {
23    /// A minimal Fuchsia system that boots to a Zircon virtcon.
24    Zircon = 0,
25    /// A Debian guest, exact version dependent on prebuilts.
26    Debian = 1,
27    /// A Linux guest that contains additional features for Vulkan and window manager
28    /// integration, based on the Termina VM from ChromeOS.
29    Termina = 2,
30}
31
32impl GuestType {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            0 => Some(Self::Zircon),
37            1 => Some(Self::Debian),
38            2 => Some(Self::Termina),
39            _ => None,
40        }
41    }
42
43    #[inline]
44    pub const fn into_primitive(self) -> u32 {
45        self as u32
46    }
47}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50#[repr(C)]
51pub struct CommandListenerOnStartedRequest {
52    pub status: i32,
53}
54
55impl fidl::Persistable for CommandListenerOnStartedRequest {}
56
57#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58#[repr(C)]
59pub struct CommandListenerOnTerminatedRequest {
60    pub status: i32,
61    pub return_code: i32,
62}
63
64impl fidl::Persistable for CommandListenerOnTerminatedRequest {}
65
66/// Represents a key/value pair to be injected into an environment where a command is executed.
67#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
68pub struct EnvironmentVariable {
69    pub key: String,
70    pub value: String,
71}
72
73impl fidl::Persistable for EnvironmentVariable {}
74
75#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
76#[repr(C)]
77pub struct InteractionGetFileResponse {
78    pub status: i32,
79}
80
81impl fidl::Persistable for InteractionGetFileResponse {}
82
83#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
84#[repr(C)]
85pub struct InteractionPutFileResponse {
86    pub status: i32,
87}
88
89impl fidl::Persistable for InteractionPutFileResponse {}
90
91pub mod command_listener_ordinals {
92    pub const ON_STARTED: u64 = 0x3a3693a7e54a5f09;
93    pub const ON_TERMINATED: u64 = 0x5a08413bdea2446a;
94}
95
96pub mod discovery_ordinals {
97    pub const GET_GUEST: u64 = 0x60538587bdd80a32;
98}
99
100pub mod interaction_ordinals {
101    pub const PUT_FILE: u64 = 0x223bc20da4a7cddd;
102    pub const GET_FILE: u64 = 0x7696bea472ca0f2d;
103    pub const EXECUTE_COMMAND: u64 = 0x612641220a1556d8;
104}
105
106pub mod interactive_guest_ordinals {
107    pub const PUT_FILE: u64 = 0x223bc20da4a7cddd;
108    pub const GET_FILE: u64 = 0x7696bea472ca0f2d;
109    pub const EXECUTE_COMMAND: u64 = 0x612641220a1556d8;
110    pub const START: u64 = 0x1e0e391a2e0b9ed0;
111    pub const SHUTDOWN: u64 = 0x17019f7511bae997;
112}
113
114mod internal {
115    use super::*;
116    unsafe impl fidl::encoding::TypeMarker for GuestType {
117        type Owned = Self;
118
119        #[inline(always)]
120        fn inline_align(_context: fidl::encoding::Context) -> usize {
121            std::mem::align_of::<u32>()
122        }
123
124        #[inline(always)]
125        fn inline_size(_context: fidl::encoding::Context) -> usize {
126            std::mem::size_of::<u32>()
127        }
128
129        #[inline(always)]
130        fn encode_is_copy() -> bool {
131            true
132        }
133
134        #[inline(always)]
135        fn decode_is_copy() -> bool {
136            false
137        }
138    }
139
140    impl fidl::encoding::ValueTypeMarker for GuestType {
141        type Borrowed<'a> = Self;
142        #[inline(always)]
143        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
144            *value
145        }
146    }
147
148    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GuestType {
149        #[inline]
150        unsafe fn encode(
151            self,
152            encoder: &mut fidl::encoding::Encoder<'_, D>,
153            offset: usize,
154            _depth: fidl::encoding::Depth,
155        ) -> fidl::Result<()> {
156            encoder.debug_check_bounds::<Self>(offset);
157            encoder.write_num(self.into_primitive(), offset);
158            Ok(())
159        }
160    }
161
162    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GuestType {
163        #[inline(always)]
164        fn new_empty() -> Self {
165            Self::Zircon
166        }
167
168        #[inline]
169        unsafe fn decode(
170            &mut self,
171            decoder: &mut fidl::encoding::Decoder<'_, D>,
172            offset: usize,
173            _depth: fidl::encoding::Depth,
174        ) -> fidl::Result<()> {
175            decoder.debug_check_bounds::<Self>(offset);
176            let prim = decoder.read_num::<u32>(offset);
177
178            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
179            Ok(())
180        }
181    }
182
183    impl fidl::encoding::ValueTypeMarker for CommandListenerOnStartedRequest {
184        type Borrowed<'a> = &'a Self;
185        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
186            value
187        }
188    }
189
190    unsafe impl fidl::encoding::TypeMarker for CommandListenerOnStartedRequest {
191        type Owned = Self;
192
193        #[inline(always)]
194        fn inline_align(_context: fidl::encoding::Context) -> usize {
195            4
196        }
197
198        #[inline(always)]
199        fn inline_size(_context: fidl::encoding::Context) -> usize {
200            4
201        }
202        #[inline(always)]
203        fn encode_is_copy() -> bool {
204            true
205        }
206
207        #[inline(always)]
208        fn decode_is_copy() -> bool {
209            true
210        }
211    }
212
213    unsafe impl<D: fidl::encoding::ResourceDialect>
214        fidl::encoding::Encode<CommandListenerOnStartedRequest, D>
215        for &CommandListenerOnStartedRequest
216    {
217        #[inline]
218        unsafe fn encode(
219            self,
220            encoder: &mut fidl::encoding::Encoder<'_, D>,
221            offset: usize,
222            _depth: fidl::encoding::Depth,
223        ) -> fidl::Result<()> {
224            encoder.debug_check_bounds::<CommandListenerOnStartedRequest>(offset);
225            unsafe {
226                // Copy the object into the buffer.
227                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
228                (buf_ptr as *mut CommandListenerOnStartedRequest)
229                    .write_unaligned((self as *const CommandListenerOnStartedRequest).read());
230                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
231                // done second because the memcpy will write garbage to these bytes.
232            }
233            Ok(())
234        }
235    }
236    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
237        fidl::encoding::Encode<CommandListenerOnStartedRequest, D> for (T0,)
238    {
239        #[inline]
240        unsafe fn encode(
241            self,
242            encoder: &mut fidl::encoding::Encoder<'_, D>,
243            offset: usize,
244            depth: fidl::encoding::Depth,
245        ) -> fidl::Result<()> {
246            encoder.debug_check_bounds::<CommandListenerOnStartedRequest>(offset);
247            // Zero out padding regions. There's no need to apply masks
248            // because the unmasked parts will be overwritten by fields.
249            // Write the fields.
250            self.0.encode(encoder, offset + 0, depth)?;
251            Ok(())
252        }
253    }
254
255    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
256        for CommandListenerOnStartedRequest
257    {
258        #[inline(always)]
259        fn new_empty() -> Self {
260            Self { status: fidl::new_empty!(i32, D) }
261        }
262
263        #[inline]
264        unsafe fn decode(
265            &mut self,
266            decoder: &mut fidl::encoding::Decoder<'_, D>,
267            offset: usize,
268            _depth: fidl::encoding::Depth,
269        ) -> fidl::Result<()> {
270            decoder.debug_check_bounds::<Self>(offset);
271            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
272            // Verify that padding bytes are zero.
273            // Copy from the buffer into the object.
274            unsafe {
275                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
276            }
277            Ok(())
278        }
279    }
280
281    impl fidl::encoding::ValueTypeMarker for CommandListenerOnTerminatedRequest {
282        type Borrowed<'a> = &'a Self;
283        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
284            value
285        }
286    }
287
288    unsafe impl fidl::encoding::TypeMarker for CommandListenerOnTerminatedRequest {
289        type Owned = Self;
290
291        #[inline(always)]
292        fn inline_align(_context: fidl::encoding::Context) -> usize {
293            4
294        }
295
296        #[inline(always)]
297        fn inline_size(_context: fidl::encoding::Context) -> usize {
298            8
299        }
300        #[inline(always)]
301        fn encode_is_copy() -> bool {
302            true
303        }
304
305        #[inline(always)]
306        fn decode_is_copy() -> bool {
307            true
308        }
309    }
310
311    unsafe impl<D: fidl::encoding::ResourceDialect>
312        fidl::encoding::Encode<CommandListenerOnTerminatedRequest, D>
313        for &CommandListenerOnTerminatedRequest
314    {
315        #[inline]
316        unsafe fn encode(
317            self,
318            encoder: &mut fidl::encoding::Encoder<'_, D>,
319            offset: usize,
320            _depth: fidl::encoding::Depth,
321        ) -> fidl::Result<()> {
322            encoder.debug_check_bounds::<CommandListenerOnTerminatedRequest>(offset);
323            unsafe {
324                // Copy the object into the buffer.
325                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
326                (buf_ptr as *mut CommandListenerOnTerminatedRequest)
327                    .write_unaligned((self as *const CommandListenerOnTerminatedRequest).read());
328                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
329                // done second because the memcpy will write garbage to these bytes.
330            }
331            Ok(())
332        }
333    }
334    unsafe impl<
335        D: fidl::encoding::ResourceDialect,
336        T0: fidl::encoding::Encode<i32, D>,
337        T1: fidl::encoding::Encode<i32, D>,
338    > fidl::encoding::Encode<CommandListenerOnTerminatedRequest, D> for (T0, T1)
339    {
340        #[inline]
341        unsafe fn encode(
342            self,
343            encoder: &mut fidl::encoding::Encoder<'_, D>,
344            offset: usize,
345            depth: fidl::encoding::Depth,
346        ) -> fidl::Result<()> {
347            encoder.debug_check_bounds::<CommandListenerOnTerminatedRequest>(offset);
348            // Zero out padding regions. There's no need to apply masks
349            // because the unmasked parts will be overwritten by fields.
350            // Write the fields.
351            self.0.encode(encoder, offset + 0, depth)?;
352            self.1.encode(encoder, offset + 4, depth)?;
353            Ok(())
354        }
355    }
356
357    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
358        for CommandListenerOnTerminatedRequest
359    {
360        #[inline(always)]
361        fn new_empty() -> Self {
362            Self { status: fidl::new_empty!(i32, D), return_code: fidl::new_empty!(i32, D) }
363        }
364
365        #[inline]
366        unsafe fn decode(
367            &mut self,
368            decoder: &mut fidl::encoding::Decoder<'_, D>,
369            offset: usize,
370            _depth: fidl::encoding::Depth,
371        ) -> fidl::Result<()> {
372            decoder.debug_check_bounds::<Self>(offset);
373            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
374            // Verify that padding bytes are zero.
375            // Copy from the buffer into the object.
376            unsafe {
377                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
378            }
379            Ok(())
380        }
381    }
382
383    impl fidl::encoding::ValueTypeMarker for EnvironmentVariable {
384        type Borrowed<'a> = &'a Self;
385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
386            value
387        }
388    }
389
390    unsafe impl fidl::encoding::TypeMarker for EnvironmentVariable {
391        type Owned = Self;
392
393        #[inline(always)]
394        fn inline_align(_context: fidl::encoding::Context) -> usize {
395            8
396        }
397
398        #[inline(always)]
399        fn inline_size(_context: fidl::encoding::Context) -> usize {
400            32
401        }
402    }
403
404    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EnvironmentVariable, D>
405        for &EnvironmentVariable
406    {
407        #[inline]
408        unsafe fn encode(
409            self,
410            encoder: &mut fidl::encoding::Encoder<'_, D>,
411            offset: usize,
412            _depth: fidl::encoding::Depth,
413        ) -> fidl::Result<()> {
414            encoder.debug_check_bounds::<EnvironmentVariable>(offset);
415            // Delegate to tuple encoding.
416            fidl::encoding::Encode::<EnvironmentVariable, D>::encode(
417                (
418                    <fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.key),
419                    <fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
420                ),
421                encoder, offset, _depth
422            )
423        }
424    }
425    unsafe impl<
426        D: fidl::encoding::ResourceDialect,
427        T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
428        T1: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
429    > fidl::encoding::Encode<EnvironmentVariable, D> for (T0, T1)
430    {
431        #[inline]
432        unsafe fn encode(
433            self,
434            encoder: &mut fidl::encoding::Encoder<'_, D>,
435            offset: usize,
436            depth: fidl::encoding::Depth,
437        ) -> fidl::Result<()> {
438            encoder.debug_check_bounds::<EnvironmentVariable>(offset);
439            // Zero out padding regions. There's no need to apply masks
440            // because the unmasked parts will be overwritten by fields.
441            // Write the fields.
442            self.0.encode(encoder, offset + 0, depth)?;
443            self.1.encode(encoder, offset + 16, depth)?;
444            Ok(())
445        }
446    }
447
448    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EnvironmentVariable {
449        #[inline(always)]
450        fn new_empty() -> Self {
451            Self {
452                key: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D),
453                value: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D),
454            }
455        }
456
457        #[inline]
458        unsafe fn decode(
459            &mut self,
460            decoder: &mut fidl::encoding::Decoder<'_, D>,
461            offset: usize,
462            _depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            decoder.debug_check_bounds::<Self>(offset);
465            // Verify that padding bytes are zero.
466            fidl::decode!(
467                fidl::encoding::BoundedString<1024>,
468                D,
469                &mut self.key,
470                decoder,
471                offset + 0,
472                _depth
473            )?;
474            fidl::decode!(
475                fidl::encoding::BoundedString<1024>,
476                D,
477                &mut self.value,
478                decoder,
479                offset + 16,
480                _depth
481            )?;
482            Ok(())
483        }
484    }
485
486    impl fidl::encoding::ValueTypeMarker for InteractionGetFileResponse {
487        type Borrowed<'a> = &'a Self;
488        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
489            value
490        }
491    }
492
493    unsafe impl fidl::encoding::TypeMarker for InteractionGetFileResponse {
494        type Owned = Self;
495
496        #[inline(always)]
497        fn inline_align(_context: fidl::encoding::Context) -> usize {
498            4
499        }
500
501        #[inline(always)]
502        fn inline_size(_context: fidl::encoding::Context) -> usize {
503            4
504        }
505        #[inline(always)]
506        fn encode_is_copy() -> bool {
507            true
508        }
509
510        #[inline(always)]
511        fn decode_is_copy() -> bool {
512            true
513        }
514    }
515
516    unsafe impl<D: fidl::encoding::ResourceDialect>
517        fidl::encoding::Encode<InteractionGetFileResponse, D> for &InteractionGetFileResponse
518    {
519        #[inline]
520        unsafe fn encode(
521            self,
522            encoder: &mut fidl::encoding::Encoder<'_, D>,
523            offset: usize,
524            _depth: fidl::encoding::Depth,
525        ) -> fidl::Result<()> {
526            encoder.debug_check_bounds::<InteractionGetFileResponse>(offset);
527            unsafe {
528                // Copy the object into the buffer.
529                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
530                (buf_ptr as *mut InteractionGetFileResponse)
531                    .write_unaligned((self as *const InteractionGetFileResponse).read());
532                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
533                // done second because the memcpy will write garbage to these bytes.
534            }
535            Ok(())
536        }
537    }
538    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
539        fidl::encoding::Encode<InteractionGetFileResponse, D> for (T0,)
540    {
541        #[inline]
542        unsafe fn encode(
543            self,
544            encoder: &mut fidl::encoding::Encoder<'_, D>,
545            offset: usize,
546            depth: fidl::encoding::Depth,
547        ) -> fidl::Result<()> {
548            encoder.debug_check_bounds::<InteractionGetFileResponse>(offset);
549            // Zero out padding regions. There's no need to apply masks
550            // because the unmasked parts will be overwritten by fields.
551            // Write the fields.
552            self.0.encode(encoder, offset + 0, depth)?;
553            Ok(())
554        }
555    }
556
557    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
558        for InteractionGetFileResponse
559    {
560        #[inline(always)]
561        fn new_empty() -> Self {
562            Self { status: fidl::new_empty!(i32, D) }
563        }
564
565        #[inline]
566        unsafe fn decode(
567            &mut self,
568            decoder: &mut fidl::encoding::Decoder<'_, D>,
569            offset: usize,
570            _depth: fidl::encoding::Depth,
571        ) -> fidl::Result<()> {
572            decoder.debug_check_bounds::<Self>(offset);
573            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
574            // Verify that padding bytes are zero.
575            // Copy from the buffer into the object.
576            unsafe {
577                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
578            }
579            Ok(())
580        }
581    }
582
583    impl fidl::encoding::ValueTypeMarker for InteractionPutFileResponse {
584        type Borrowed<'a> = &'a Self;
585        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
586            value
587        }
588    }
589
590    unsafe impl fidl::encoding::TypeMarker for InteractionPutFileResponse {
591        type Owned = Self;
592
593        #[inline(always)]
594        fn inline_align(_context: fidl::encoding::Context) -> usize {
595            4
596        }
597
598        #[inline(always)]
599        fn inline_size(_context: fidl::encoding::Context) -> usize {
600            4
601        }
602        #[inline(always)]
603        fn encode_is_copy() -> bool {
604            true
605        }
606
607        #[inline(always)]
608        fn decode_is_copy() -> bool {
609            true
610        }
611    }
612
613    unsafe impl<D: fidl::encoding::ResourceDialect>
614        fidl::encoding::Encode<InteractionPutFileResponse, D> for &InteractionPutFileResponse
615    {
616        #[inline]
617        unsafe fn encode(
618            self,
619            encoder: &mut fidl::encoding::Encoder<'_, D>,
620            offset: usize,
621            _depth: fidl::encoding::Depth,
622        ) -> fidl::Result<()> {
623            encoder.debug_check_bounds::<InteractionPutFileResponse>(offset);
624            unsafe {
625                // Copy the object into the buffer.
626                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
627                (buf_ptr as *mut InteractionPutFileResponse)
628                    .write_unaligned((self as *const InteractionPutFileResponse).read());
629                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
630                // done second because the memcpy will write garbage to these bytes.
631            }
632            Ok(())
633        }
634    }
635    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
636        fidl::encoding::Encode<InteractionPutFileResponse, D> for (T0,)
637    {
638        #[inline]
639        unsafe fn encode(
640            self,
641            encoder: &mut fidl::encoding::Encoder<'_, D>,
642            offset: usize,
643            depth: fidl::encoding::Depth,
644        ) -> fidl::Result<()> {
645            encoder.debug_check_bounds::<InteractionPutFileResponse>(offset);
646            // Zero out padding regions. There's no need to apply masks
647            // because the unmasked parts will be overwritten by fields.
648            // Write the fields.
649            self.0.encode(encoder, offset + 0, depth)?;
650            Ok(())
651        }
652    }
653
654    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
655        for InteractionPutFileResponse
656    {
657        #[inline(always)]
658        fn new_empty() -> Self {
659            Self { status: fidl::new_empty!(i32, D) }
660        }
661
662        #[inline]
663        unsafe fn decode(
664            &mut self,
665            decoder: &mut fidl::encoding::Decoder<'_, D>,
666            offset: usize,
667            _depth: fidl::encoding::Depth,
668        ) -> fidl::Result<()> {
669            decoder.debug_check_bounds::<Self>(offset);
670            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
671            // Verify that padding bytes are zero.
672            // Copy from the buffer into the object.
673            unsafe {
674                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
675            }
676            Ok(())
677        }
678    }
679}