AsyncDbnStore::decode_record_ref

Decode a single record of an unknown type.

Returns

A RecordRef—a wrapper around a record of a dynamic type—or Ok(None) if the stream has been exhausted.

This function will return an error if there's an error reading from the input stream.

API method
pub async fn decode_record_ref(
    &mut self,
) -> dbn::Result<Option<RecordRef>>;
Example usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use databento::{
    HistoricalClient,
    dbn::{OhlcvMsg, SType, Schema},
    historical::timeseries::GetRangeParams,
};
use time::macros::datetime;

let mut client =
    HistoricalClient::builder().key("$YOUR_API_KEY")?.build()?;
let mut decoder = client
    .timeseries()
    .get_range(
        &GetRangeParams::builder()
            .dataset("OPRA.PILLAR")
            .stype_in(SType::Parent)
            .date_time_range(
                datetime!(2023-08-07 00:00 UTC)
                    ..datetime!(2023-08-08 00:00 UTC),
            )
            .symbols("SPXW.OPT")
            .schema(Schema::Ohlcv1H)
            .build(),
    )
    .await?;
let bar = decoder.decode_record::<OhlcvMsg>().await?.unwrap();
println!("{bar:#?}");
Example response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
OhlcvMsg {
    hd: RecordHeader {
        length: 14,
        rtype: Ohlcv1H,
        publisher_id: OpraPillarXcbo,
        instrument_id: 587251818,
        ts_event: 1691413200000000000,
    },
    open: 85.060000000,
    high: 85.060000000,
    low: 85.060000000,
    close: 85.060000000,
    volume: 1,
}