matchcore 0.4.0

A high-performance order book and price-time matching engine implemented as a single-threaded, deterministic, in-memory state machine
Documentation
//! Command specifications for the matchcore library
//!
//! The `Command` type is the top-level command for all kinds of commands and orders,
//! and is the only input accepted by the order book.

mod amend;
mod cancel;
mod error;
mod submit;
mod validation;

pub use amend::*;
pub use cancel::*;
pub use error::*;
pub use submit::*;

use crate::{SequenceNumber, Timestamp};

/// Represents a top-level command for all kinds of commands and orders
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Command {
    /// The common metadata for all command kinds
    pub meta: CommandMeta,
    /// The kind of command
    pub kind: CommandKind,
}

/// Represents the common metadata for all command kinds
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CommandMeta {
    /// The sequence number of the command
    pub sequence_number: SequenceNumber,
    /// The timestamp of the command
    pub timestamp: Timestamp,
}

/// Represents the kind of command
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CommandKind {
    /// A command to submit a new order
    Submit(SubmitCmd),
    /// A command to amend an existing order
    Amend(AmendCmd),
    /// A command to cancel an existing order
    Cancel(CancelCmd),
}