fidl_fuchsia_testing_harness__common/
fidl_fuchsia_testing_harness__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
11/// The maximum number of characters allowed in a FIDL protocol name.
12/// This is set to the maximum length of filesystem node name because
13/// we generally use the filesystem for protocol discovery.
14pub const MAX_PROTOCOL_LEN: u64 = fidl_fuchsia_io__common::MAX_NAME_LENGTH as u64;
15
16/// Fuchsia test harness operation error type.
17///
18/// A harness is responsible for maintaining the state for a particular test run.
19/// This type is returned when an operation fails.
20#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21pub enum OperationError {
22    /// The requested operation is invalid.
23    ///
24    /// This is returned when a test case asked the harness to do
25    /// something incompatible with the harness' current state. This
26    /// error signifies a bug in the test code itself.
27    ///
28    /// Returning this value MUST fail the corresponding test.
29    ///
30    /// Example: Test asked for the size of a file before it was created.
31    Invalid,
32    /// The requested operation failed.
33    ///
34    /// This is returned when the test harness failed to complete
35    /// an operation, even though the current state should have permitted
36    /// the operation to work. This error signifies a bug in a
37    /// dependency of the harness.
38    ///
39    /// Returning this value MUST fail the corresponding test.
40    ///
41    /// Example: Test asked for the size of a file after it was
42    /// created, but the query failed.
43    Failed,
44    /// The requested operation is not supported by this harness.
45    ///
46    /// This is returned when the test harness does not support the
47    /// requested operation. This is not necessarily a fatal error, it
48    /// is used to signify that the harness has knowledge of what was
49    /// requested, but it does not implement the behavior.
50    ///
51    /// Returning this value MAY fail the corresponding test, but
52    /// it does not need to. This return value is useful to determine
53    /// compatibility with different feature sets or versions.
54    ///
55    /// Example: Test asked for the size of a file, but the ability
56    /// to check file sizes was removed in the previous component
57    /// version.
58    Unsupported,
59    #[doc(hidden)]
60    __SourceBreaking { unknown_ordinal: u32 },
61}
62
63/// Pattern that matches an unknown `OperationError` member.
64#[macro_export]
65macro_rules! OperationErrorUnknown {
66    () => {
67        _
68    };
69}
70
71impl OperationError {
72    #[inline]
73    pub fn from_primitive(prim: u32) -> Option<Self> {
74        match prim {
75            0 => Some(Self::Invalid),
76            1 => Some(Self::Failed),
77            2 => Some(Self::Unsupported),
78            _ => None,
79        }
80    }
81
82    #[inline]
83    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
84        match prim {
85            0 => Self::Invalid,
86            1 => Self::Failed,
87            2 => Self::Unsupported,
88            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
89        }
90    }
91
92    #[inline]
93    pub fn unknown() -> Self {
94        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
95    }
96
97    #[inline]
98    pub const fn into_primitive(self) -> u32 {
99        match self {
100            Self::Invalid => 0,
101            Self::Failed => 1,
102            Self::Unsupported => 2,
103            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
104        }
105    }
106
107    #[inline]
108    pub fn is_unknown(&self) -> bool {
109        match self {
110            Self::__SourceBreaking { unknown_ordinal: _ } => true,
111            _ => false,
112        }
113    }
114}
115
116pub mod realm_proxy__ordinals {
117    pub const CONNECT_TO_NAMED_PROTOCOL: u64 = 0x159b4ba0b614ecc4;
118    pub const OPEN_SERVICE: u64 = 0x7e4f670a6ec5986a;
119    pub const CONNECT_TO_SERVICE_INSTANCE: u64 = 0x39111e790d55bbf;
120}
121
122mod internal {
123    use super::*;
124    unsafe impl fidl::encoding::TypeMarker for OperationError {
125        type Owned = Self;
126
127        #[inline(always)]
128        fn inline_align(_context: fidl::encoding::Context) -> usize {
129            std::mem::align_of::<u32>()
130        }
131
132        #[inline(always)]
133        fn inline_size(_context: fidl::encoding::Context) -> usize {
134            std::mem::size_of::<u32>()
135        }
136
137        #[inline(always)]
138        fn encode_is_copy() -> bool {
139            false
140        }
141
142        #[inline(always)]
143        fn decode_is_copy() -> bool {
144            false
145        }
146    }
147
148    impl fidl::encoding::ValueTypeMarker for OperationError {
149        type Borrowed<'a> = Self;
150        #[inline(always)]
151        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
152            *value
153        }
154    }
155
156    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for OperationError {
157        #[inline]
158        unsafe fn encode(
159            self,
160            encoder: &mut fidl::encoding::Encoder<'_, D>,
161            offset: usize,
162            _depth: fidl::encoding::Depth,
163        ) -> fidl::Result<()> {
164            encoder.debug_check_bounds::<Self>(offset);
165            encoder.write_num(self.into_primitive(), offset);
166            Ok(())
167        }
168    }
169
170    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OperationError {
171        #[inline(always)]
172        fn new_empty() -> Self {
173            Self::unknown()
174        }
175
176        #[inline]
177        unsafe fn decode(
178            &mut self,
179            decoder: &mut fidl::encoding::Decoder<'_, D>,
180            offset: usize,
181            _depth: fidl::encoding::Depth,
182        ) -> fidl::Result<()> {
183            decoder.debug_check_bounds::<Self>(offset);
184            let prim = decoder.read_num::<u32>(offset);
185
186            *self = Self::from_primitive_allow_unknown(prim);
187            Ok(())
188        }
189    }
190}