Files
brk/crates/brk_computer/src/states/block.rs
T

37 lines
785 B
Rust

use std::ops::{Add, AddAssign, SubAssign};
use brk_structs::{Dollars, Timestamp};
use serde::Serialize;
use super::SupplyState;
#[derive(Debug, Clone, Serialize)]
pub struct BlockState {
#[serde(flatten)]
pub supply: SupplyState,
#[serde(skip)]
pub price: Option<Dollars>,
#[serde(skip)]
pub timestamp: Timestamp,
}
impl Add<BlockState> for BlockState {
type Output = Self;
fn add(mut self, rhs: BlockState) -> Self::Output {
self.supply += &rhs.supply;
self
}
}
impl AddAssign<&BlockState> for BlockState {
fn add_assign(&mut self, rhs: &Self) {
self.supply += &rhs.supply;
}
}
impl SubAssign<&BlockState> for BlockState {
fn sub_assign(&mut self, rhs: &Self) {
self.supply -= &rhs.supply;
}
}