1use std::fmt;
4
5use triomphe::Arc;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum Arch {
9 Wasm32,
11 Wasm64,
12 Other,
13}
14
15#[derive(Debug, PartialEq, Eq, Hash, Clone)]
16pub struct TargetData {
17 pub data_layout: Box<str>,
18 pub arch: Arch,
19}
20
21#[derive(Clone, PartialEq, Eq, Hash)]
22pub struct TargetLoadError(Arc<str>);
23
24impl fmt::Debug for TargetLoadError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 fmt::Debug::fmt(&self.0, f)
27 }
28}
29
30impl fmt::Display for TargetLoadError {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 fmt::Display::fmt(&self.0, f)
33 }
34}
35
36impl std::error::Error for TargetLoadError {}
37
38impl From<String> for TargetLoadError {
39 fn from(value: String) -> Self {
40 Self(value.into())
41 }
42}
43
44impl From<&str> for TargetLoadError {
45 fn from(value: &str) -> Self {
46 Self(value.into())
47 }
48}
49
50pub type TargetLoadResult = Result<TargetData, TargetLoadError>;