Available languages: [Python](https://databento.com/docs/api-live/client/next-record.python.md) · [C++](https://databento.com/docs/api-live/client/next-record.cpp.md) · [Rust](https://databento.com/docs/api-live/client/next-record.rust.md) · [Raw](https://databento.com/docs/api-live/client/next-record.raw.md)

Source: https://databento.com/docs/api-live/client/next-record


### LiveClient::next_record

Returns the next record or `None` if the gateway has closed the connection.
This method should only be called after [starting](https://databento.com/docs/api-live/client/start.md) the session.

#### API method

```rust
pub async fn next_record(
    &mut self,
) -> databento::Result<Option<RecordRef>>;
```

#### Returns

Returns a [RecordRef](https://databento.com/docs/api-live/helpers/record-ref.md), 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](https://databento.com/docs/schemas/whats-a-schema.md).

#### Example usage

```rust
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

```plaintext
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,
}
```
