betex 0.35.0

Betfair / Prediction Market Exchange
Documentation
use super::reject::RejectReason;
use crate::{book::protocol::command::Side, types::*};
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TradeSummary {
    pub maker_order_id: OrderId,
    pub maker_side: Side,
    pub taker_order_id: OrderId,
    pub taker_side: Side,
    pub price: FillPrice,
    pub quantity: FillQuantity,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[allow(clippy::large_enum_variant)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Response {
    Ok {
        order_id: Option<OrderId>,
        trades: SmallVec<[TradeSummary; 4]>,
        liability_delta: Money,
        tx_start_seq: Option<u64>,
        tx_len: u16,
    },
    Rejected {
        reason: RejectReason,
        tx_start_seq: Option<u64>,
        tx_len: u16,
    },
    Fatal {
        tx_start_seq: Option<u64>,
        tx_len: u16,
    },
}

impl Response {
    pub fn fatal() -> Self {
        Self::Fatal {
            tx_start_seq: None,
            tx_len: 0,
        }
    }
}