use fvm_shared2::error::ExitCode as ExitCodeV2;
use fvm_shared3::error::ExitCode as ExitCodeV3;
use fvm_shared4::error::ExitCode as ExitCodeV4;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Eq, Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
pub struct ExitCode(#[schemars(with = "u32")] ExitCodeV3);
impl ExitCode {
pub const FIRST_USER_EXIT_CODE: u32 = ExitCodeV3::FIRST_USER_EXIT_CODE;
pub fn value(&self) -> u32 {
self.0.value()
}
pub fn is_success(&self) -> bool {
self.0.is_success()
}
}
impl From<u32> for ExitCode {
fn from(value: u32) -> Self {
Self(ExitCodeV3::new(value))
}
}
impl From<ExitCodeV4> for ExitCode {
fn from(value: ExitCodeV4) -> Self {
value.value().into()
}
}
impl From<ExitCodeV3> for ExitCode {
fn from(value: ExitCodeV3) -> Self {
Self(value)
}
}
impl From<ExitCodeV2> for ExitCode {
fn from(value: ExitCodeV2) -> Self {
value.value().into()
}
}
impl From<ExitCode> for ExitCodeV2 {
fn from(value: ExitCode) -> Self {
Self::new(value.0.value())
}
}
impl From<ExitCode> for ExitCodeV3 {
fn from(value: ExitCode) -> Self {
value.0
}
}
impl From<ExitCode> for ExitCodeV4 {
fn from(value: ExitCode) -> Self {
Self::new(value.0.value())
}
}