#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Tif {
Alo,
Gtc,
Ioc,
Other(u8),
}
impl Tif {
#[must_use]
pub const fn code(self) -> u8 {
match self {
Tif::Alo => 1,
Tif::Gtc => 2,
Tif::Ioc => 3,
Tif::Other(code) => code,
}
}
#[must_use]
pub const fn from_code(code: u8) -> Tif {
match code {
1 => Tif::Alo,
2 => Tif::Gtc,
3 => Tif::Ioc,
other => Tif::Other(other),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FinalizeVariant {
Create,
FirstStorageSlot,
CustomStorageSlot,
Other(u8),
}
impl FinalizeVariant {
#[must_use]
pub const fn code(self) -> u8 {
match self {
FinalizeVariant::Create => 1,
FinalizeVariant::FirstStorageSlot => 2,
FinalizeVariant::CustomStorageSlot => 3,
FinalizeVariant::Other(code) => code,
}
}
#[must_use]
pub const fn from_code(code: u8) -> FinalizeVariant {
match code {
1 => FinalizeVariant::Create,
2 => FinalizeVariant::FirstStorageSlot,
3 => FinalizeVariant::CustomStorageSlot,
other => FinalizeVariant::Other(other),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BorrowLendOp {
Supply,
Withdraw,
Borrow,
Repay,
Other(u8),
}
impl BorrowLendOp {
#[must_use]
pub const fn code(self) -> u8 {
match self {
BorrowLendOp::Supply => 0,
BorrowLendOp::Withdraw => 1,
BorrowLendOp::Borrow => 2,
BorrowLendOp::Repay => 3,
BorrowLendOp::Other(code) => code,
}
}
#[must_use]
pub const fn from_code(code: u8) -> BorrowLendOp {
match code {
0 => BorrowLendOp::Supply,
1 => BorrowLendOp::Withdraw,
2 => BorrowLendOp::Borrow,
3 => BorrowLendOp::Repay,
other => BorrowLendOp::Other(other),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Abstraction {
Disabled,
UnifiedAccount,
PortfolioMargin,
Other(u8),
}
impl Abstraction {
#[must_use]
pub const fn code(self) -> u8 {
match self {
Abstraction::Disabled => 1,
Abstraction::UnifiedAccount => 2,
Abstraction::PortfolioMargin => 3,
Abstraction::Other(code) => code,
}
}
#[must_use]
pub const fn from_code(code: u8) -> Abstraction {
match code {
1 => Abstraction::Disabled,
2 => Abstraction::UnifiedAccount,
3 => Abstraction::PortfolioMargin,
other => Abstraction::Other(other),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OutcomeOp {
SplitOutcome,
MergeOutcome,
MergeQuestion,
NegateOutcome,
Other(u8),
}
impl OutcomeOp {
#[must_use]
pub const fn code(self) -> u8 {
match self {
OutcomeOp::SplitOutcome => 0,
OutcomeOp::MergeOutcome => 1,
OutcomeOp::MergeQuestion => 2,
OutcomeOp::NegateOutcome => 3,
OutcomeOp::Other(code) => code,
}
}
#[must_use]
pub const fn from_code(code: u8) -> OutcomeOp {
match code {
0 => OutcomeOp::SplitOutcome,
1 => OutcomeOp::MergeOutcome,
2 => OutcomeOp::MergeQuestion,
3 => OutcomeOp::NegateOutcome,
other => OutcomeOp::Other(other),
}
}
}
#[cfg(test)]
#[path = "tests/options.rs"]
mod tests;