use std::sync::Arc;
mod convert;
#[cfg(feature = "serde")]
mod der;
mod display;
#[cfg(feature = "serde")]
mod ser;
pub enum WasiValue {
Boolean(bool),
Unsigned8(u8),
Unsigned16(u16),
Unsigned32(u32),
Unsigned64(u64),
Integer8(i8),
Integer16(i16),
Integer32(i32),
Integer64(i64),
Float32(f32),
Float64(f64),
Unicode(char),
UTF8(Arc<str>),
Buffer(Arc<[u8]>),
Object(Arc<WasiObject>),
}
#[derive(Debug)]
pub struct WasiObject {
pub kind: WasiObjectKind,
pub terms: Vec<WasiValue>,
}
#[derive(Clone, Debug)]
pub enum WasiObjectKind {
Record { typing: Arc<str> },
Flags {
typing: Arc<str>
},
List,
Variant {
typing: Arc<str>,
},
Tuple,
}
#[derive(Debug)]
pub struct WasiPair {
pub key: Arc<str>,
pub value: WasiValue,
}
impl From<WasiObject> for WasiValue {
fn from(value: WasiObject) -> Self {
Self::Object(Arc::new(value))
}
}
impl WasiObject {
pub fn none() -> Self {
Self { kind: WasiObjectKind::Variant { typing: Arc::from("none") }, terms: vec![] }
}
pub fn unit() -> Self {
Self { kind: WasiObjectKind::Tuple {}, terms: vec![] }
}
pub fn variant<N, I>(name: N, values: I) -> Self
where
N: Into<Arc<str>>,
I: IntoIterator<Item = WasiValue>,
{
Self { kind: WasiObjectKind::Variant { typing: name.into() }, terms: values.into_iter().collect() }
}
}