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: u8The DBN schema version number. Newly-encoded DBN files will use
crate::DBN_VERSION.
dataset: StringThe 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: u64The 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: STypeThe output symbology type to map to.
ts_out: booltrue if this store contains live data with send timestamps appended to each
record.
symbol_cstr_len: usizeThe 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
impl Metadata
Sourcepub fn builder() -> MetadataBuilder<Unset, Unset, Unset, Unset, Unset>
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.
Sourcepub fn start(&self) -> OffsetDateTime
pub fn start(&self) -> OffsetDateTime
Parses the raw query start into a datetime.
Sourcepub fn end(&self) -> Option<OffsetDateTime>
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.
Sourcepub fn symbol_map_for_date(&self, date: Date) -> Result<PitSymbolMap>
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.
Sourcepub fn symbol_map(&self) -> Result<TsSymbolMap>
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.
Sourcepub fn upgrade(&mut self, upgrade_policy: VersionUpgradePolicy)
pub fn upgrade(&mut self, upgrade_policy: VersionUpgradePolicy)
Upgrades the metadata according to upgrade_policy if necessary.
Sourcepub fn merge(self, other: impl IntoIterator<Item = Metadata>) -> Result<Self>
pub fn merge(self, other: impl IntoIterator<Item = Metadata>) -> Result<Self>
Attempts to merge another metadata into this one. This is useful for merging DBN streams.
If merging data from multiple schemas, the resulting metadata will have a schema
of None.
§Errors
Merging metadata where any of the following fields don’t match will result in an error:
version: upgrade the metadata of the lower version before mergingdatasetstype_instype_outts_outsymbol_cstr_len: upgrade the metadata of the lower version before merging
This function will also return an error if there are conflicting symbology mappings.
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for Metadata
impl<'py> IntoPyObject<'py> for Metadata
Source§type Output = Bound<'py, <Metadata as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Metadata as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClassImpl for Metadata
impl PyClassImpl for Metadata
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§type ThreadChecker = SendablePyClass<Metadata>
type ThreadChecker = SendablePyClass<Metadata>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<Metadata> for PyClassImplCollector<Metadata>
Available on crate feature python only.
impl PyClassNewTextSignature<Metadata> for PyClassImplCollector<Metadata>
python only.fn new_text_signature(self) -> Option<&'static str>
Source§impl PyMethods<Metadata> for PyClassImplCollector<Metadata>
Available on crate feature python only.
impl PyMethods<Metadata> for PyClassImplCollector<Metadata>
python only.fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Metadata
impl PyTypeInfo for Metadata
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
Source§impl TryFrom<&Metadata> for TsSymbolMap
impl TryFrom<&Metadata> for TsSymbolMap
impl DerefToPyAny for Metadata
impl Eq for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
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> FromPyObject<'_> for T
impl<T> FromPyObject<'_> for T
Source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.