Skip to main content

TradeStatusAble

Trait TradeStatusAble 

Source
pub trait TradeStatusAble {
    // Required methods
    fn open(&self) -> Result<Trade, TradeError>;
    fn close(&self) -> Result<Trade, TradeError>;
    fn expired(&self) -> Result<Trade, TradeError>;
    fn exercised(&self) -> Result<Trade, TradeError>;
    fn assigned(&self) -> Result<Trade, TradeError>;
    fn status_other(&self) -> Result<Trade, TradeError>;
}
Expand description

A trait representing the status management of a trade.

This trait provides methods for transitioning a trade into various predefined statuses. Implementations of this trait should define how a trade moves between these statuses.

Each method returns a Trade instance representing the trade in its updated status.

Required Methods§

Source

fn open(&self) -> Result<Trade, TradeError>

  • open: Return a Trade instance representing the trade in its open status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the current state cannot transition to the Open status (for example, attempting to re-open a trade that has already been closed, exercised, or assigned).

Source

fn close(&self) -> Result<Trade, TradeError>

  • closed: Return a Trade instance representing the trade in its closed status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the trade is not currently in a state that allows transitioning to Closed (e.g. a trade that has not been opened yet).

Source

fn expired(&self) -> Result<Trade, TradeError>

  • expired: Return a Trade instance representing the trade in its expired status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the trade is not in a state that allows transitioning to Expired (e.g. already closed or exercised).

Source

fn exercised(&self) -> Result<Trade, TradeError>

  • exercised: Return a Trade instance representing the trade in its exercised status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the option cannot legally be exercised from the current trade state (e.g. the trade has already expired or been assigned).

Source

fn assigned(&self) -> Result<Trade, TradeError>

  • assigned: Return a Trade instance representing the trade in its assigned status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the trade cannot be moved into the Assigned state from its current status.

Source

fn status_other(&self) -> Result<Trade, TradeError>

  • status_other: Return a Trade instance representing undeclared status or a TradeError if the transition is invalid.
§Errors

Returns TradeError::InvalidTrade when the implementation rejects the transition to a non-canonical status (the semantics are left to the implementor).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§