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_INTERACTION_MAX_LENGTH: u32 = 1024;
14
15#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16#[repr(C)]
17pub struct CommandListenerOnStartedRequest {
18    pub status: i32,
19}
20
21impl fidl::Persistable for CommandListenerOnStartedRequest {}
22
23#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24#[repr(C)]
25pub struct CommandListenerOnTerminatedRequest {
26    pub status: i32,
27    pub return_code: i32,
28}
29
30impl fidl::Persistable for CommandListenerOnTerminatedRequest {}
31
32/// Represents a key/value pair to be injected into an environment where a command is executed.
33#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct EnvironmentVariable {
35    pub key: String,
36    pub value: String,
37}
38
39impl fidl::Persistable for EnvironmentVariable {}
40
41#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42#[repr(C)]
43pub struct InteractionGetFileResponse {
44    pub status: i32,
45}
46
47impl fidl::Persistable for InteractionGetFileResponse {}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50#[repr(C)]
51pub struct InteractionPutFileResponse {
52    pub status: i32,
53}
54
55impl fidl::Persistable for InteractionPutFileResponse {}
56
57pub mod command_listener_ordinals {
58    pub const ON_STARTED: u64 = 0x3a3693a7e54a5f09;
59    pub const ON_TERMINATED: u64 = 0x5a08413bdea2446a;
60}
61
62pub mod discovery_ordinals {
63    pub const GET_GUEST: u64 = 0x60538587bdd80a32;
64}
65
66pub mod interaction_ordinals {
67    pub const PUT_FILE: u64 = 0x223bc20da4a7cddd;
68    pub const GET_FILE: u64 = 0x7696bea472ca0f2d;
69    pub const EXECUTE_COMMAND: u64 = 0x612641220a1556d8;
70}
71
72mod internal {
73    use super::*;
74
75    impl fidl::encoding::ValueTypeMarker for CommandListenerOnStartedRequest {
76        type Borrowed<'a> = &'a Self;
77        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
78            value
79        }
80    }
81
82    unsafe impl fidl::encoding::TypeMarker for CommandListenerOnStartedRequest {
83        type Owned = Self;
84
85        #[inline(always)]
86        fn inline_align(_context: fidl::encoding::Context) -> usize {
87            4
88        }
89
90        #[inline(always)]
91        fn inline_size(_context: fidl::encoding::Context) -> usize {
92            4
93        }
94        #[inline(always)]
95        fn encode_is_copy() -> bool {
96            true
97        }
98
99        #[inline(always)]
100        fn decode_is_copy() -> bool {
101            true
102        }
103    }
104
105    unsafe impl<D: fidl::encoding::ResourceDialect>
106        fidl::encoding::Encode<CommandListenerOnStartedRequest, D>
107        for &CommandListenerOnStartedRequest
108    {
109        #[inline]
110        unsafe fn encode(
111            self,
112            encoder: &mut fidl::encoding::Encoder<'_, D>,
113            offset: usize,
114            _depth: fidl::encoding::Depth,
115        ) -> fidl::Result<()> {
116            encoder.debug_check_bounds::<CommandListenerOnStartedRequest>(offset);
117            unsafe {
118                // Copy the object into the buffer.
119                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
120                (buf_ptr as *mut CommandListenerOnStartedRequest)
121                    .write_unaligned((self as *const CommandListenerOnStartedRequest).read());
122                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
123                // done second because the memcpy will write garbage to these bytes.
124            }
125            Ok(())
126        }
127    }
128    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
129        fidl::encoding::Encode<CommandListenerOnStartedRequest, D> for (T0,)
130    {
131        #[inline]
132        unsafe fn encode(
133            self,
134            encoder: &mut fidl::encoding::Encoder<'_, D>,
135            offset: usize,
136            depth: fidl::encoding::Depth,
137        ) -> fidl::Result<()> {
138            encoder.debug_check_bounds::<CommandListenerOnStartedRequest>(offset);
139            // Zero out padding regions. There's no need to apply masks
140            // because the unmasked parts will be overwritten by fields.
141            // Write the fields.
142            self.0.encode(encoder, offset + 0, depth)?;
143            Ok(())
144        }
145    }
146
147    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
148        for CommandListenerOnStartedRequest
149    {
150        #[inline(always)]
151        fn new_empty() -> Self {
152            Self { status: fidl::new_empty!(i32, D) }
153        }
154
155        #[inline]
156        unsafe fn decode(
157            &mut self,
158            decoder: &mut fidl::encoding::Decoder<'_, D>,
159            offset: usize,
160            _depth: fidl::encoding::Depth,
161        ) -> fidl::Result<()> {
162            decoder.debug_check_bounds::<Self>(offset);
163            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
164            // Verify that padding bytes are zero.
165            // Copy from the buffer into the object.
166            unsafe {
167                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
168            }
169            Ok(())
170        }
171    }
172
173    impl fidl::encoding::ValueTypeMarker for CommandListenerOnTerminatedRequest {
174        type Borrowed<'a> = &'a Self;
175        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
176            value
177        }
178    }
179
180    unsafe impl fidl::encoding::TypeMarker for CommandListenerOnTerminatedRequest {
181        type Owned = Self;
182
183        #[inline(always)]
184        fn inline_align(_context: fidl::encoding::Context) -> usize {
185            4
186        }
187
188        #[inline(always)]
189        fn inline_size(_context: fidl::encoding::Context) -> usize {
190            8
191        }
192        #[inline(always)]
193        fn encode_is_copy() -> bool {
194            true
195        }
196
197        #[inline(always)]
198        fn decode_is_copy() -> bool {
199            true
200        }
201    }
202
203    unsafe impl<D: fidl::encoding::ResourceDialect>
204        fidl::encoding::Encode<CommandListenerOnTerminatedRequest, D>
205        for &CommandListenerOnTerminatedRequest
206    {
207        #[inline]
208        unsafe fn encode(
209            self,
210            encoder: &mut fidl::encoding::Encoder<'_, D>,
211            offset: usize,
212            _depth: fidl::encoding::Depth,
213        ) -> fidl::Result<()> {
214            encoder.debug_check_bounds::<CommandListenerOnTerminatedRequest>(offset);
215            unsafe {
216                // Copy the object into the buffer.
217                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
218                (buf_ptr as *mut CommandListenerOnTerminatedRequest)
219                    .write_unaligned((self as *const CommandListenerOnTerminatedRequest).read());
220                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
221                // done second because the memcpy will write garbage to these bytes.
222            }
223            Ok(())
224        }
225    }
226    unsafe impl<
227            D: fidl::encoding::ResourceDialect,
228            T0: fidl::encoding::Encode<i32, D>,
229            T1: fidl::encoding::Encode<i32, D>,
230        > fidl::encoding::Encode<CommandListenerOnTerminatedRequest, D> for (T0, T1)
231    {
232        #[inline]
233        unsafe fn encode(
234            self,
235            encoder: &mut fidl::encoding::Encoder<'_, D>,
236            offset: usize,
237            depth: fidl::encoding::Depth,
238        ) -> fidl::Result<()> {
239            encoder.debug_check_bounds::<CommandListenerOnTerminatedRequest>(offset);
240            // Zero out padding regions. There's no need to apply masks
241            // because the unmasked parts will be overwritten by fields.
242            // Write the fields.
243            self.0.encode(encoder, offset + 0, depth)?;
244            self.1.encode(encoder, offset + 4, depth)?;
245            Ok(())
246        }
247    }
248
249    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
250        for CommandListenerOnTerminatedRequest
251    {
252        #[inline(always)]
253        fn new_empty() -> Self {
254            Self { status: fidl::new_empty!(i32, D), return_code: fidl::new_empty!(i32, D) }
255        }
256
257        #[inline]
258        unsafe fn decode(
259            &mut self,
260            decoder: &mut fidl::encoding::Decoder<'_, D>,
261            offset: usize,
262            _depth: fidl::encoding::Depth,
263        ) -> fidl::Result<()> {
264            decoder.debug_check_bounds::<Self>(offset);
265            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
266            // Verify that padding bytes are zero.
267            // Copy from the buffer into the object.
268            unsafe {
269                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
270            }
271            Ok(())
272        }
273    }
274
275    impl fidl::encoding::ValueTypeMarker for EnvironmentVariable {
276        type Borrowed<'a> = &'a Self;
277        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
278            value
279        }
280    }
281
282    unsafe impl fidl::encoding::TypeMarker for EnvironmentVariable {
283        type Owned = Self;
284
285        #[inline(always)]
286        fn inline_align(_context: fidl::encoding::Context) -> usize {
287            8
288        }
289
290        #[inline(always)]
291        fn inline_size(_context: fidl::encoding::Context) -> usize {
292            32
293        }
294    }
295
296    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EnvironmentVariable, D>
297        for &EnvironmentVariable
298    {
299        #[inline]
300        unsafe fn encode(
301            self,
302            encoder: &mut fidl::encoding::Encoder<'_, D>,
303            offset: usize,
304            _depth: fidl::encoding::Depth,
305        ) -> fidl::Result<()> {
306            encoder.debug_check_bounds::<EnvironmentVariable>(offset);
307            // Delegate to tuple encoding.
308            fidl::encoding::Encode::<EnvironmentVariable, D>::encode(
309                (
310                    <fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.key),
311                    <fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.value),
312                ),
313                encoder, offset, _depth
314            )
315        }
316    }
317    unsafe impl<
318            D: fidl::encoding::ResourceDialect,
319            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
320            T1: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
321        > fidl::encoding::Encode<EnvironmentVariable, D> for (T0, T1)
322    {
323        #[inline]
324        unsafe fn encode(
325            self,
326            encoder: &mut fidl::encoding::Encoder<'_, D>,
327            offset: usize,
328            depth: fidl::encoding::Depth,
329        ) -> fidl::Result<()> {
330            encoder.debug_check_bounds::<EnvironmentVariable>(offset);
331            // Zero out padding regions. There's no need to apply masks
332            // because the unmasked parts will be overwritten by fields.
333            // Write the fields.
334            self.0.encode(encoder, offset + 0, depth)?;
335            self.1.encode(encoder, offset + 16, depth)?;
336            Ok(())
337        }
338    }
339
340    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EnvironmentVariable {
341        #[inline(always)]
342        fn new_empty() -> Self {
343            Self {
344                key: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D),
345                value: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D),
346            }
347        }
348
349        #[inline]
350        unsafe fn decode(
351            &mut self,
352            decoder: &mut fidl::encoding::Decoder<'_, D>,
353            offset: usize,
354            _depth: fidl::encoding::Depth,
355        ) -> fidl::Result<()> {
356            decoder.debug_check_bounds::<Self>(offset);
357            // Verify that padding bytes are zero.
358            fidl::decode!(
359                fidl::encoding::BoundedString<1024>,
360                D,
361                &mut self.key,
362                decoder,
363                offset + 0,
364                _depth
365            )?;
366            fidl::decode!(
367                fidl::encoding::BoundedString<1024>,
368                D,
369                &mut self.value,
370                decoder,
371                offset + 16,
372                _depth
373            )?;
374            Ok(())
375        }
376    }
377
378    impl fidl::encoding::ValueTypeMarker for InteractionGetFileResponse {
379        type Borrowed<'a> = &'a Self;
380        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
381            value
382        }
383    }
384
385    unsafe impl fidl::encoding::TypeMarker for InteractionGetFileResponse {
386        type Owned = Self;
387
388        #[inline(always)]
389        fn inline_align(_context: fidl::encoding::Context) -> usize {
390            4
391        }
392
393        #[inline(always)]
394        fn inline_size(_context: fidl::encoding::Context) -> usize {
395            4
396        }
397        #[inline(always)]
398        fn encode_is_copy() -> bool {
399            true
400        }
401
402        #[inline(always)]
403        fn decode_is_copy() -> bool {
404            true
405        }
406    }
407
408    unsafe impl<D: fidl::encoding::ResourceDialect>
409        fidl::encoding::Encode<InteractionGetFileResponse, D> for &InteractionGetFileResponse
410    {
411        #[inline]
412        unsafe fn encode(
413            self,
414            encoder: &mut fidl::encoding::Encoder<'_, D>,
415            offset: usize,
416            _depth: fidl::encoding::Depth,
417        ) -> fidl::Result<()> {
418            encoder.debug_check_bounds::<InteractionGetFileResponse>(offset);
419            unsafe {
420                // Copy the object into the buffer.
421                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
422                (buf_ptr as *mut InteractionGetFileResponse)
423                    .write_unaligned((self as *const InteractionGetFileResponse).read());
424                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
425                // done second because the memcpy will write garbage to these bytes.
426            }
427            Ok(())
428        }
429    }
430    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
431        fidl::encoding::Encode<InteractionGetFileResponse, D> for (T0,)
432    {
433        #[inline]
434        unsafe fn encode(
435            self,
436            encoder: &mut fidl::encoding::Encoder<'_, D>,
437            offset: usize,
438            depth: fidl::encoding::Depth,
439        ) -> fidl::Result<()> {
440            encoder.debug_check_bounds::<InteractionGetFileResponse>(offset);
441            // Zero out padding regions. There's no need to apply masks
442            // because the unmasked parts will be overwritten by fields.
443            // Write the fields.
444            self.0.encode(encoder, offset + 0, depth)?;
445            Ok(())
446        }
447    }
448
449    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
450        for InteractionGetFileResponse
451    {
452        #[inline(always)]
453        fn new_empty() -> Self {
454            Self { status: fidl::new_empty!(i32, D) }
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            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
466            // Verify that padding bytes are zero.
467            // Copy from the buffer into the object.
468            unsafe {
469                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
470            }
471            Ok(())
472        }
473    }
474
475    impl fidl::encoding::ValueTypeMarker for InteractionPutFileResponse {
476        type Borrowed<'a> = &'a Self;
477        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
478            value
479        }
480    }
481
482    unsafe impl fidl::encoding::TypeMarker for InteractionPutFileResponse {
483        type Owned = Self;
484
485        #[inline(always)]
486        fn inline_align(_context: fidl::encoding::Context) -> usize {
487            4
488        }
489
490        #[inline(always)]
491        fn inline_size(_context: fidl::encoding::Context) -> usize {
492            4
493        }
494        #[inline(always)]
495        fn encode_is_copy() -> bool {
496            true
497        }
498
499        #[inline(always)]
500        fn decode_is_copy() -> bool {
501            true
502        }
503    }
504
505    unsafe impl<D: fidl::encoding::ResourceDialect>
506        fidl::encoding::Encode<InteractionPutFileResponse, D> for &InteractionPutFileResponse
507    {
508        #[inline]
509        unsafe fn encode(
510            self,
511            encoder: &mut fidl::encoding::Encoder<'_, D>,
512            offset: usize,
513            _depth: fidl::encoding::Depth,
514        ) -> fidl::Result<()> {
515            encoder.debug_check_bounds::<InteractionPutFileResponse>(offset);
516            unsafe {
517                // Copy the object into the buffer.
518                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
519                (buf_ptr as *mut InteractionPutFileResponse)
520                    .write_unaligned((self as *const InteractionPutFileResponse).read());
521                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
522                // done second because the memcpy will write garbage to these bytes.
523            }
524            Ok(())
525        }
526    }
527    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
528        fidl::encoding::Encode<InteractionPutFileResponse, D> for (T0,)
529    {
530        #[inline]
531        unsafe fn encode(
532            self,
533            encoder: &mut fidl::encoding::Encoder<'_, D>,
534            offset: usize,
535            depth: fidl::encoding::Depth,
536        ) -> fidl::Result<()> {
537            encoder.debug_check_bounds::<InteractionPutFileResponse>(offset);
538            // Zero out padding regions. There's no need to apply masks
539            // because the unmasked parts will be overwritten by fields.
540            // Write the fields.
541            self.0.encode(encoder, offset + 0, depth)?;
542            Ok(())
543        }
544    }
545
546    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
547        for InteractionPutFileResponse
548    {
549        #[inline(always)]
550        fn new_empty() -> Self {
551            Self { status: fidl::new_empty!(i32, D) }
552        }
553
554        #[inline]
555        unsafe fn decode(
556            &mut self,
557            decoder: &mut fidl::encoding::Decoder<'_, D>,
558            offset: usize,
559            _depth: fidl::encoding::Depth,
560        ) -> fidl::Result<()> {
561            decoder.debug_check_bounds::<Self>(offset);
562            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
563            // Verify that padding bytes are zero.
564            // Copy from the buffer into the object.
565            unsafe {
566                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
567            }
568            Ok(())
569        }
570    }
571}