axvm_types/error.rs
1// Copyright 2026 The Axvisor Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Architecture backend error contract shared with AxVM.
16
17/// Result returned by architecture virtualization backends.
18pub type VmBackendResult<T = ()> = Result<T, VmBackendError>;
19
20/// Failures reported by an architecture virtualization backend.
21#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
22pub enum VmBackendError {
23 /// The backend rejected a caller-provided value.
24 #[error("invalid virtualization backend input")]
25 InvalidInput,
26 /// The backend received malformed or inconsistent architecture data.
27 #[error("invalid virtualization backend data")]
28 InvalidData,
29 /// The backend state does not permit the requested operation.
30 #[error("invalid virtualization backend state")]
31 InvalidState,
32 /// The backend does not implement the requested operation.
33 #[error("unsupported virtualization backend operation")]
34 Unsupported,
35 /// The backend could not allocate the required memory.
36 #[error("virtualization backend memory allocation failed")]
37 OutOfMemory,
38 /// A backend resource is already owned or in use.
39 #[error("virtualization backend resource is busy")]
40 ResourceBusy,
41}