use crate::Currency;
use serde::Serialize;
#[derive(Default, Debug, Clone, Serialize)]
pub struct Book {
pub taker_gets: Currency,
pub taker_pays: Currency,
#[serde(skip_serializing_if = "Option::is_none")]
pub taker: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub snapshot: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub both: Option<bool>,
}
impl Book {
pub fn new(taker_gets: Currency, taker_pays: Currency) -> Self {
Self {
taker_gets,
taker_pays,
taker: None,
snapshot: None,
both: None,
}
}
pub fn snapshot(self, snapshot: bool) -> Self {
Self {
snapshot: Some(snapshot),
..self
}
}
pub fn taker(self, taker: impl Into<String>) -> Self {
Self {
taker: Some(taker.into()),
..self
}
}
pub fn both(self, both: bool) -> Self {
Self {
both: Some(both),
..self
}
}
}