use std::str::FromStr;
use strum::EnumIter;
pub use strum::IntoEnumIterator;
pub mod host_exports {
pub const INIT: &str = "__init_buffers";
pub const SEND: &str = "__send";
pub const LOG: &str = "__console_log";
pub const OP_LIST: &str = "__op_list";
}
#[derive(Debug, Copy, Clone, EnumIter)]
#[allow(missing_docs)]
pub enum HostExports {
Init,
Send,
Log,
OpList,
}
impl FromStr for HostExports {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let result = match s {
host_exports::INIT => Self::Init,
host_exports::SEND => Self::Send,
host_exports::LOG => Self::Log,
host_exports::OP_LIST => Self::OpList,
_ => return Err(()),
};
Ok(result)
}
}
impl AsRef<str> for HostExports {
fn as_ref(&self) -> &str {
match self {
Self::Init => host_exports::INIT,
Self::Send => host_exports::SEND,
Self::Log => host_exports::LOG,
Self::OpList => host_exports::OP_LIST,
}
}
}
impl std::fmt::Display for HostExports {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())
}
}
pub mod guest_exports {
pub const INIT: &str = "__wasmrs_init";
pub const SEND: &str = "__wasmrs_send";
pub const OP_LIST_REQUEST: &str = "__wasmrs_op_list_request";
pub const TINYGO_START: &str = "_start";
pub const REQUIRED_STARTS: [&str; 2] = [TINYGO_START, INIT];
}
#[derive(Debug, Copy, Clone, EnumIter)]
#[allow(missing_docs)]
pub enum GuestExports {
Init,
Start,
OpListRequest,
Send,
}
impl FromStr for GuestExports {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let result = match s {
guest_exports::INIT => Self::Init,
guest_exports::TINYGO_START => Self::Start,
guest_exports::OP_LIST_REQUEST => Self::OpListRequest,
guest_exports::SEND => Self::Send,
_ => return Err(()),
};
Ok(result)
}
}
impl AsRef<str> for GuestExports {
fn as_ref(&self) -> &str {
match self {
GuestExports::Init => guest_exports::INIT,
GuestExports::Start => guest_exports::TINYGO_START,
GuestExports::Send => guest_exports::SEND,
GuestExports::OpListRequest => guest_exports::OP_LIST_REQUEST,
}
}
}
impl std::fmt::Display for GuestExports {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())
}
}