#[non_exhaustive]pub enum OrderBookError {
Show 20 variants
PriceLevelError(PriceLevelError),
OrderNotFound(String),
InvalidPriceLevel(u128),
PriceCrossing {
price: u128,
side: Side,
opposite_price: u128,
},
InsufficientLiquidity {
side: Side,
requested: u64,
available: u64,
},
InsufficientLiquidityNotional {
side: Side,
requested: u128,
spent: u128,
},
InvalidOperation {
message: String,
},
KillSwitchActive,
SerializationError {
message: String,
},
DeserializationError {
message: String,
},
ChecksumMismatch {
expected: String,
actual: String,
},
InvalidTickSize {
price: u128,
tick_size: u128,
},
InvalidLotSize {
quantity: u64,
lot_size: u64,
},
OrderSizeOutOfRange {
quantity: u64,
min: Option<u64>,
max: Option<u64>,
},
DuplicateOrderId {
order_id: Id,
},
MissingUserId {
order_id: Id,
},
SelfTradePrevented {
mode: STPMode,
taker_order_id: Id,
user_id: Hash32,
},
RiskMaxOpenOrders {
account: Hash32,
current: u64,
limit: u64,
},
RiskMaxNotional {
account: Hash32,
current: u128,
attempted: u128,
limit: u128,
},
RiskPriceBand {
submitted: u128,
reference: u128,
deviation_bps: u32,
limit_bps: u32,
},
}Expand description
Errors that can occur within the OrderBook
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PriceLevelError(PriceLevelError)
Error from underlying price level operations
OrderNotFound(String)
Order not found in the book
InvalidPriceLevel(u128)
Invalid price level
PriceCrossing
Price crossing (bid >= ask)
Fields
InsufficientLiquidity
Insufficient liquidity for market order
Fields
InsufficientLiquidityNotional
Insufficient liquidity for a quote-notional market order. Returned by
the *_by_amount paths when the book cannot fund a single whole lot
against the requested notional. Distinct from
OrderBookError::InsufficientLiquidity so callers can pattern-match
on quote-vs-base semantics.
Fields
InvalidOperation
Operation not permitted for specified order type
KillSwitchActive
New flow (submit / modify / replace) is rejected because the kill switch is engaged. Cancel and mass-cancel paths still operate so operators can drain the book in an orderly way.
SerializationError
Error while serializing snapshot data
DeserializationError
Error while deserializing snapshot data
ChecksumMismatch
Snapshot integrity check failed
InvalidTickSize
Order price is not a multiple of the configured tick size
InvalidLotSize
Order quantity is not a multiple of the configured lot size
OrderSizeOutOfRange
Order quantity is outside the allowed min/max range
Fields
DuplicateOrderId
Order rejected because its order_id duplicates an order that is
already resting on the book. Admitting it would overwrite the
existing order’s location and orphan it (the prior order could no
longer be cancelled or modified by id), so the engine rejects the
duplicate instead of silently replacing the live order. Maps to the
stable wire code RejectReason::DuplicateOrderId.
This guards against sequential reuse of a live order’s id. It is not atomic against two concurrent submissions of the same fresh id on the lock-free admission path — serializing order ids is the ingress / sequencing layer’s responsibility.
MissingUserId
Order rejected because user_id is Hash32::zero() while
Self-Trade Prevention is enabled. All orders must carry a non-zero
user_id when STP mode is active.
SelfTradePrevented
Self-trade prevention triggered: the incoming order would have matched against a resting order from the same user.
Fields
RiskMaxOpenOrders
Per-account open-order limit breached.
Returned by limit-order admission when the requesting account
already has current resting orders and the configured ceiling
is limit. current >= limit always holds when this variant
is constructed.
Fields
RiskMaxNotional
Per-account notional limit would be breached by this admission.
current + attempted > limit always holds when this variant
is constructed. attempted is computed as
submitted_quantity * submitted_price.
Fields
RiskPriceBand
Submitted price exceeds the configured price band against the reference price.
deviation_bps > limit_bps always holds when this variant is
constructed.
Trait Implementations§
Source§impl Clone for OrderBookError
impl Clone for OrderBookError
Source§impl Debug for OrderBookError
impl Debug for OrderBookError
Source§impl Display for OrderBookError
impl Display for OrderBookError
Source§impl Error for OrderBookError
impl Error for OrderBookError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<&OrderBookError> for RejectReason
Map a typed OrderBookError to its wire-side reject code.
impl From<&OrderBookError> for RejectReason
Map a typed OrderBookError to its wire-side reject code.
Errors that do not represent a public reject (e.g.
SerializationError, ChecksumMismatch, NatsPublishError,
internal-state errors) map to [RejectReason::Other(0)] — they are
not expected to surface on outbound reject events.
The match below is intentionally exhaustive (no _ => catch-all);
any new variant added to OrderBookError must extend this mapping
at compile time. This is enforced because the impl lives inside
the crate, where exhaustive matches over a #[non_exhaustive] enum
are still permitted.
Source§fn from(err: &OrderBookError) -> Self
fn from(err: &OrderBookError) -> Self
Source§impl From<PriceLevelError> for OrderBookError
impl From<PriceLevelError> for OrderBookError
Source§fn from(err: PriceLevelError) -> Self
fn from(err: PriceLevelError) -> Self
Source§impl From<SerializationError> for OrderBookError
impl From<SerializationError> for OrderBookError
Source§fn from(err: SerializationError) -> Self
fn from(err: SerializationError) -> Self
Folds a typed SerializationError
into OrderBookError::SerializationError, preserving the underlying
serde / bincode message via the error’s Display. Enables
?-propagation of an EventSerializer failure on paths returning
OrderBookError.
Auto Trait Implementations§
impl Freeze for OrderBookError
impl RefUnwindSafe for OrderBookError
impl Send for OrderBookError
impl Sync for OrderBookError
impl Unpin for OrderBookError
impl UnsafeUnpin for OrderBookError
impl UnwindSafe for OrderBookError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more