use super::*;
pub trait HasRecursiveMemoryEffects {}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MemoryEffect {
Read,
Write,
Allocate,
Free,
}
impl AsRef<str> for MemoryEffect {
fn as_ref(&self) -> &str {
match self {
Self::Read => "read",
Self::Write => "write",
Self::Allocate => "allocate",
Self::Free => "free",
}
}
}
impl core::fmt::Display for MemoryEffect {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_ref())
}
}
impl core::str::FromStr for MemoryEffect {
type Err = alloc::string::String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use alloc::string::ToString;
match s {
"read" => Ok(Self::Read),
"write" => Ok(Self::Write),
"allocate" => Ok(Self::Allocate),
"free" => Ok(Self::Free),
s => Err(s.to_string()),
}
}
}
impl PartialEq<MemoryEffect> for &MemoryEffect {
#[inline]
fn eq(&self, other: &MemoryEffect) -> bool {
(**self).eq(other)
}
}
impl Effect for MemoryEffect {}
pub trait MemoryEffectOpInterface = EffectOpInterface<MemoryEffect>;