OrderBookBuilder

Struct OrderBookBuilder 

Source
pub struct OrderBookBuilder { /* private fields */ }
Expand description

A builder for constructing an OrderBook with custom options.

Use this struct to configure optional features such as journaling before creating an OrderBook instance.

Implementations§

Source§

impl OrderBookBuilder

Source

pub fn new(symbol: impl Into<String>) -> Self

Creates a new builder instance for the given symbol.

§Parameters
  • symbol: The market symbol (e.g., "BTCUSD")
Source

pub fn with_options(self, options: OrderBookOptions) -> Self

Sets all options in bulk via an OrderBookOptions struct.

This method can be used for advanced configuration.

Source

pub fn with_snapshot(self, snapshot: Snapshot) -> Self

Attaches a snapshot to this builder, so that the constructed OrderBook will be restored to the state captured in the snapshot rather than starting empty.

§Parameters
  • snapshot: A previously captured Snapshot representing the full state of an order book at a given point in time.
§Returns

The builder itself, allowing method chaining.

Source

pub fn with_replay_logs(self, logs: Vec<JournalLog>) -> Self

Sets a sequence of journal logs to be replayed after snapshot restoration.

This allows the order book to reconstruct its state by first restoring a snapshot (if provided) and then applying all operations contained in the logs.

§Parameters
  • logs: A vector of JournalLog entries to replay. Logs should ideally be in chronological order (op_id ascending), but replay_logs will sort them internally.
§Returns

Returns self to allow chaining with other builder methods.

Source

pub fn with_journaling(self, enabled: bool) -> Self

Enables or disables journaling.

§Parameters
  • enabled: true to enable journaling
Source

pub fn build(self) -> OrderBook

Builds and returns a fully configured OrderBook instance.

§Returns

An OrderBook with the configured options.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.