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