Interface IRecord<TSelf>
- Namespace
- DatabentoDotNet.Dbn
- Assembly
- DatabentoDotNet.Dbn.dll
Associates a record struct with the record types (RType) it can decode and with its exact size on the wire.
public interface IRecord<TSelf> where TSelf : unmanaged, IRecord<TSelf>
Type Parameters
TSelfThe implementing record struct.
Remarks
This is the port of the Rust crate's HasRType trait, and it has the same shape as
databento-cpp's per-struct static bool HasRType(RType). C# 11 static abstract
interface members resolve the check at the call site with no allocation, no boxing, and no
reflection, which keeps the downcast path AOT- and trim-safe.
An rtype alone does not identify a record. Five rtypes —
InstrumentDef, SymbolMapping,
Error, System and Statistics —
decode to a different struct depending on the record's length, because those layouts changed
across DBN versions. The match rule is therefore
T.HasRType(rtype) && wireLength == T.WireSize, with exact equality: a
>= comparison would let a 520-byte v3 InstrumentDefMsg match the 360-byte v1
struct and silently decode as the wrong version. No two versions of the same rtype share a
size, so exact equality disambiguates every family.
Properties
IndexTs
The record's index timestamp: the one to sort by, and the one to key a symbol map with. Nanoseconds since the UNIX epoch.
ulong IndexTs { get; }
Property Value
Remarks
This is usually ts_recv, not TsEvent. Fourteen of
the twenty-one record structs carry a ts_recv and index on it; the rest have no
ts_recv at all and fall back to the header's ts_event. Port of upstream's
Record::raw_index_ts (record/traits.rs:52-54), whose default body is
ts_event and which the #[dbn(index_ts)] field attribute overrides per struct
(record.rs, compat.rs).
The distinction is not cosmetic: ts_event and ts_recv can fall on opposite
sides of UTC midnight, so resolving a symbol by the wrong one silently returns the
previous day's symbol, or nothing, with no error anywhere.
This is a raw timestamp and can be UndefTimestamp. Convert it with ToUtcDate(ulong) or TryToUtcDate(ulong, out LocalDate), which check the sentinel.
WireSize
The struct's exact size on the wire, in bytes, excluding any trailing ts_out.
public static abstract int WireSize { get; }
Property Value
Methods
HasRType(RType)
Reports whether TSelf is the layout for records carrying
rtype.
public static abstract bool HasRType(RType rtype)
Parameters
rtypeRTypeThe record type read from a record header.
Returns
- bool
true if
rtypeis one of the record types this struct decodes. This is necessary but not sufficient to identify the record — see the remarks on IRecord<TSelf>.