Struct dbn::metadata::Metadata

source ·
pub struct Metadata {
Show 14 fields pub version: u8, pub dataset: String, pub schema: Option<Schema>, pub start: u64, pub end: Option<NonZeroU64>, pub limit: Option<NonZeroU64>, pub stype_in: Option<SType>, pub stype_out: SType, pub ts_out: bool, pub symbol_cstr_len: usize, pub symbols: Vec<String>, pub partial: Vec<String>, pub not_found: Vec<String>, pub mappings: Vec<SymbolMapping>,
}
Expand description

Information about the data contained in a DBN file or stream. DBN requires the Metadata to be included at the start of the encoded data.

Fields§

§version: u8

The DBN schema version number. Newly-encoded DBN files will use crate::DBN_VERSION.

§dataset: String

The dataset code.

§schema: Option<Schema>

The data record schema. Specifies which record types are in the DBN stream. None indicates the DBN stream may contain more than one record type.

§start: u64

The UNIX nanosecond timestamp of the query start, or the first record if the file was split.

§end: Option<NonZeroU64>

The UNIX nanosecond timestamp of the query end, or the last record if the file was split.

§limit: Option<NonZeroU64>

The optional maximum number of records for the query.

§stype_in: Option<SType>

The input symbology type to map from. None indicates a mix, such as in the case of live data.

§stype_out: SType

The output symbology type to map to.

§ts_out: bool

true if this store contains live data with send timestamps appended to each record.

§symbol_cstr_len: usize

The length in bytes of fixed-length symbol strings, including a null terminator byte.

§symbols: Vec<String>

The original query input symbols from the request.

§partial: Vec<String>

Symbols that did not resolve for at least one day in the query time range.

§not_found: Vec<String>

Symbols that did not resolve for any day in the query time range.

§mappings: Vec<SymbolMapping>

Symbol mappings containing a raw symbol and its mapping intervals.

Implementations§

source§

impl Metadata

source

pub fn builder() -> MetadataBuilder<Unset, Unset, Unset, Unset, Unset>

Creates a builder for building Metadata. Call .dataset(...), .schema(...), .start(...) .stype_in(...), and .stype_out(...) on the builder to set the required fields. Finally call .build() to create the Metadata instance.

source

pub fn start(&self) -> OffsetDateTime

Parses the raw query start into a datetime.

source

pub fn end(&self) -> Option<OffsetDateTime>

Parses the raw query end time or the timestamp of the last record into a datetime. Returns None if the end time was not specified.

source

pub fn symbol_map_for_date(&self, date: Date) -> Result<PitSymbolMap>

Creates a symbology mapping from instrument ID to text symbol for the given date.

This method is useful when working with a historical request over a single day or in other situations where you’re sure the mappings don’t change during the time range of the request. Otherwise, Self::symbol_map() is recommmended.

§Errors

This function returns an error if stype_out is not SType::InstrumentId or it can’t parse a symbol into a u32 instrument ID. It will also return an error if date is outside the query range.

source

pub fn symbol_map(&self) -> Result<TsSymbolMap>

Creates a symbology mapping from instrument ID and date to text symbol.

If you’re working with a single date or otherwise don’t expect the mappings to change, Self::symbol_map_for_date() is recommended.

§Errors

This function returns an error if stype_out is not SType::InstrumentId or it can’t parse a symbol into a u32 instrument ID.

source

pub fn upgrade(&mut self, upgrade_policy: VersionUpgradePolicy)

Upgrades the metadata according to upgrade_policy if necessary.

Trait Implementations§

source§

impl AsRef<[u8]> for Metadata

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Metadata

source§

fn clone(&self) -> Metadata

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 Metadata

source§

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

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

impl IntoPy<Py<PyAny>> for Metadata

source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
source§

impl PartialEq for Metadata

source§

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

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

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

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

impl PyClass for Metadata

§

type Frozen = False

Whether the pyclass is frozen. Read more
source§

impl PyClassImpl for Metadata

source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<Metadata>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

Available on non-crate feature gil-refs only.
The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
source§

fn items_iter() -> PyClassItemsIter

source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

source§

fn dict_offset() -> Option<isize>

source§

fn weaklist_offset() -> Option<isize>

source§

impl PyClassNewTextSignature<Metadata> for PyClassImplCollector<Metadata>

Available on crate feature python only.
source§

fn new_text_signature(self) -> Option<&'static str>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a Metadata

§

type Holder = Option<PyRef<'py, Metadata>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut Metadata

§

type Holder = Option<PyRefMut<'py, Metadata>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

source§

impl PyMethods<Metadata> for PyClassImplCollector<Metadata>

Available on crate feature python only.
source§

fn py_methods(self) -> &'static PyClassItems

source§

impl PyTypeInfo for Metadata

source§

const NAME: &'static str = "Metadata"

Class name.
source§

const MODULE: Option<&'static str> = _

Module name, if any.
source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
source§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
source§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
source§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
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 DerefToPyAny for Metadata

source§

impl Eq for Metadata

source§

impl StructuralPartialEq for Metadata

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

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

source§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
source§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

source§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
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> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
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,