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§
Sourcefn open(&self) -> Result<Trade, TradeError>
fn open(&self) -> Result<Trade, TradeError>
open: Return aTradeinstance 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).
Sourcefn close(&self) -> Result<Trade, TradeError>
fn close(&self) -> Result<Trade, TradeError>
closed: Return aTradeinstance 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).
Sourcefn expired(&self) -> Result<Trade, TradeError>
fn expired(&self) -> Result<Trade, TradeError>
expired: Return aTradeinstance 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).
Sourcefn exercised(&self) -> Result<Trade, TradeError>
fn exercised(&self) -> Result<Trade, TradeError>
exercised: Return aTradeinstance 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).
Sourcefn assigned(&self) -> Result<Trade, TradeError>
fn assigned(&self) -> Result<Trade, TradeError>
assigned: Return aTradeinstance 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.
Sourcefn status_other(&self) -> Result<Trade, TradeError>
fn status_other(&self) -> Result<Trade, TradeError>
status_other: Return aTradeinstance 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".