Struct dbn::symbol_map::TsSymbolMap

source ·
pub struct TsSymbolMap(/* private fields */);
Expand description

A timeseries symbol map. Generally useful for working with historical data and is commonly built from a Metadata object via Self::from_metadata().

Implementations§

source§

impl TsSymbolMap

source

pub fn new() -> Self

Creates a new timeseries symbol map.

source

pub fn is_empty(&self) -> bool

Returns true if there are no mappings.

source

pub fn len(&self) -> usize

Returns the number of symbol mappings in the map.

source

pub fn from_metadata(metadata: &Metadata) -> Result<Self>

Creates a new timeseries symbol map from the metadata.

§Errors

This function returns an error if neither stype_in or stype_out are SType::InstrumentId. It will also return an error if it can’t parse a symbol into u32 instrument ID.

source

pub fn insert( &mut self, instrument_id: u32, start_date: Date, end_date: Date, symbol: Arc<String> ) -> Result<()>

Inserts a new mapping into the symbol map.

If the map already had a mapping, the mapping is updated.

§Errors

This function returns an error if start_date comes after end_date.

source

pub fn get(&self, date: Date, instrument_id: u32) -> Option<&String>

Returns the symbol mapping for the given date and instrument ID. Returns None if no mapping exists.

source

pub fn inner(&self) -> &HashMap<(Date, u32), Arc<String>>

Returns a reference to the inner map.

source

pub fn inner_mut(&mut self) -> &mut HashMap<(Date, u32), Arc<String>>

Returns a mutable reference to the inner map.

Trait Implementations§

source§

impl Clone for TsSymbolMap

source§

fn clone(&self) -> TsSymbolMap

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TsSymbolMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TsSymbolMap

source§

fn default() -> TsSymbolMap

Returns the “default value” for a type. Read more
source§

impl Index<&(Date, u32)> for TsSymbolMap

§

type Output = String

The returned type after indexing.
source§

fn index(&self, index: &(Date, u32)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<R: HasRType> Index<&R> for TsSymbolMap

§

type Output = String

The returned type after indexing.
source§

fn index(&self, index: &R) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq for TsSymbolMap

source§

fn eq(&self, other: &TsSymbolMap) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SymbolIndex for TsSymbolMap

source§

fn get_for_rec<R: Record>(&self, record: &R) -> Option<&String>

Returns the associated symbol mapping for record. Returns None if no mapping exists.
source§

fn get_for_rec_ref(&self, rec_ref: RecordRef<'_>) -> Option<&String>

👎Deprecated since 0.13.0: The trait bound for get_for_rec was loosened to accept RecordRefs, making this function redundant
Returns the associated symbol mapping for rec_ref. Returns None if no mapping exists.
source§

impl TryFrom<&Metadata> for TsSymbolMap

§

type Error = Error

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

fn try_from(metadata: &Metadata) -> Result<Self, Error>

Performs the conversion.
source§

impl Eq for TsSymbolMap

source§

impl StructuralPartialEq for TsSymbolMap

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<T> Ungil for T
where T: Send,