wasmer_deploy_schema/schema/
workload.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5use super::{CapabilityMapV1, StringWebcIdent};
6
7#[doc(inline)]
8pub use wcgi_host::CgiDialect;
9
10/// Spawn a new workload on demand.
11#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, schemars::JsonSchema)]
12pub struct WorkloadV2 {
13    pub source: StringWebcIdent,
14    #[serde(default)]
15    pub capabilities: CapabilityMapV1,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
19pub enum RunnerKind {
20    Wasi,
21    Wcgi,
22}
23
24impl RunnerKind {
25    pub fn ipv6_only(&self) -> bool {
26        match self {
27            Self::Wcgi => true,
28            _ => false,
29        }
30    }
31}
32
33impl fmt::Display for RunnerKind {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        match self {
36            Self::Wasi => write!(f, "wasi"),
37            Self::Wcgi => write!(f, "wcgi"),
38        }
39    }
40}