pub struct MarketHistory {
pub item_id: String,
/* private fields */
}Expand description
Recent sale history for a single item.
Fields§
§item_id: StringImplementations§
Source§impl MarketHistory
impl MarketHistory
pub fn new(item_id: impl Into<String>) -> Self
Sourcepub fn record_sale(&mut self, time: f32, price_copper: u64)
pub fn record_sale(&mut self, time: f32, price_copper: u64)
Record a sale at a given time and price (copper).
Sourcepub fn latest_price(&self) -> Option<u64>
pub fn latest_price(&self) -> Option<u64>
Most recent price, or None if no history.
Sourcepub fn average_price(&self) -> f32
pub fn average_price(&self) -> f32
Average price over all recorded sales.
Sourcepub fn recent_average(&self, n: usize) -> f32
pub fn recent_average(&self, n: usize) -> f32
Average price over the last n sales.
Sourcepub fn price_at(&self, index: usize) -> Option<(f32, u64)>
pub fn price_at(&self, index: usize) -> Option<(f32, u64)>
Price at a specific index (0 = oldest).
Sourcepub fn all_prices(&self) -> &[(f32, u64)]
pub fn all_prices(&self) -> &[(f32, u64)]
All recorded price points as a slice.
Trait Implementations§
Source§impl Clone for MarketHistory
impl Clone for MarketHistory
Source§fn clone(&self) -> MarketHistory
fn clone(&self) -> MarketHistory
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MarketHistory
impl RefUnwindSafe for MarketHistory
impl Send for MarketHistory
impl Sync for MarketHistory
impl Unpin for MarketHistory
impl UnsafeUnpin for MarketHistory
impl UnwindSafe for MarketHistory
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.