LiveClient::next_record

Returns the next record or None if the gateway has closed the connection. This method should only be called after starting the session.

Returns

Returns a RecordRef, a reference to a record of any rtype or None if the connection was closed.

A full list of fields is available in list of fields by schema.

API method
pub async fn next_record(
    &mut self,
) -> databento::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
27
28
use databento::{
    LiveClient,
    dbn::{Dataset::IfeuImpact, SType, Schema, TradeMsg},
    live::Subscription,
};

let mut client = LiveClient::builder()
    .key("$YOUR_API_KEY")?
    .dataset(IfeuImpact)
    .build()
    .await?;
client
    .subscribe(
        Subscription::builder()
            .schema(Schema::Trades)
            .stype_in(SType::Parent)
            .symbols("BRN.FUT")
            .build(),
    )
    .await?;
client.start().await?;

while let Some(record) = client.next_record().await? {
    if let Some(trade) = record.get::<TradeMsg>() {
        println!("{trade:#?}");
        break;
    }
}
Example response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
TradeMsg {
    hd: RecordHeader {
        length: 12,
        rtype: Mbp0,
        publisher_id: IfeuImpactIfeu,
        instrument_id: 6018439,
        ts_event: 1773438135206728003,
    },
    price: 103.870000000,
    size: 1,
    action: 'T',
    side: 'A',
    flags: 0,
    depth: 0,
    ts_recv: 1773438135207649945,
    ts_in_delta: 330945,
    sequence: 151684861,
}