1use std::str::FromStr;
7
8use allocative::Allocative;
9use async_graphql::scalar;
10use derive_more::Display;
11use linera_witty::{WitLoad, WitStore, WitType};
12use serde::{Deserialize, Serialize};
13use thiserror::Error;
14
15#[derive(
16 Clone,
17 Copy,
18 Default,
19 Display,
20 Hash,
21 PartialEq,
22 Eq,
23 PartialOrd,
24 Ord,
25 Serialize,
26 Deserialize,
27 WitType,
28 WitStore,
29 WitLoad,
30 Debug,
31 Allocative,
32)]
33#[cfg_attr(with_testing, derive(test_strategy::Arbitrary))]
34pub enum VmRuntime {
36 #[default]
38 Wasm,
39 Evm,
41}
42
43impl FromStr for VmRuntime {
44 type Err = InvalidVmRuntime;
45
46 fn from_str(string: &str) -> Result<Self, Self::Err> {
47 match string {
48 "wasm" => Ok(VmRuntime::Wasm),
49 "evm" => Ok(VmRuntime::Evm),
50 unknown => Err(InvalidVmRuntime(unknown.to_owned())),
51 }
52 }
53}
54
55scalar!(VmRuntime);
56
57#[derive(Clone, Debug, Error)]
59#[error("{0:?} is not a valid virtual machine runtime")]
60pub struct InvalidVmRuntime(String);
61
62#[derive(Clone, Debug, Deserialize, Serialize)]
64pub enum EvmQuery {
65 Query(Vec<u8>),
67 Mutation(Vec<u8>),
69}