#[non_exhaustive]pub struct Tick {
pub price: f64,
pub volume: f64,
pub timestamp: i64,
}Expand description
A single trade tick.
§Construction and the limits of its guarantee
The struct is #[non_exhaustive], so code outside this crate cannot build
one from a field literal and must go through new, which
validates. A tick has no unchecked constructor.
The fields stay public because reading them is by far the common operation and an accessor on each would buy nothing. That does mean a validated value can still be written into an invalid state afterwards, and nothing detects it: the code that consumes this type relies on the constructor’s guarantee rather than re-checking. A mutation is an assertion that the invariants still hold.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.price: f64Trade price.
volume: f64Trade size.
timestamp: i64Trade timestamp (caller-defined epoch / resolution).
Implementations§
Source§impl Tick
impl Tick
Sourcepub fn new(price: f64, volume: f64, timestamp: i64) -> Result<Self>
pub fn new(price: f64, volume: f64, timestamp: i64) -> Result<Self>
Construct a new tick, validating finiteness and non-negativity of volume.
§Errors
Returns Error::NonFiniteInput if price or volume is NaN or infinite,
or Error::InvalidTick for volume < 0. (Audit finding R14 — previously
returned Error::InvalidCandle, which is semantically wrong for a tick.)
Trait Implementations§
impl Copy for Tick
impl StructuralPartialEq for Tick
Auto Trait Implementations§
impl Freeze for Tick
impl RefUnwindSafe for Tick
impl Send for Tick
impl Sync for Tick
impl Unpin for Tick
impl UnsafeUnpin for Tick
impl UnwindSafe for Tick
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more