use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
pub enum Variant {
#[default]
Fn,
FinalFn,
EntryPoint,
Finalize,
}
impl Variant {
pub fn is_entry(self) -> bool {
matches!(self, Variant::EntryPoint)
}
pub fn is_finalize(self) -> bool {
matches!(self, Variant::Finalize)
}
pub fn is_onchain(self) -> bool {
matches!(self, Variant::Finalize | Variant::FinalFn)
}
}
impl fmt::Display for Variant {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::FinalFn => write!(f, "final fn"),
Self::Fn => write!(f, "fn"),
Self::EntryPoint => write!(f, "entry"),
Self::Finalize => write!(f, "finalize"),
}
}
}