# Primary index

The Aerospike Rust client provides the ability to query all records in a specified namespace and set.

## Querying records

This example counts the number of records in the query result:

```rust
use aerospike::{Bins, Client, ClientPolicy, Error, QueryPolicy, Statement};

use aerospike::query::PartitionFilter;

use futures::stream::StreamExt;

#[tokio::main]

async fn main() -> Result<(), Error> {

    let hosts = std::env::var("AEROSPIKE_HOSTS")

        .unwrap_or_else(|_| "localhost:3000".to_string());

    let client = Client::new(&ClientPolicy::default(), &hosts).await?;

    let policy = QueryPolicy::default();

    let stmt = Statement::new("test", "demo", Bins::None);

    let rs = client.query(&policy, PartitionFilter::all(), stmt).await?;

    let mut stream = rs.into_stream();

    let mut count: usize = 0;

    while let Some(result) = stream.next().await {

        match result {

            Ok(_record) => count += 1,

            Err(err) => println!("Error during scan: {}", err),

        }

    }

    println!("Records: {}", count);

    client.close().await?;

    Ok(())

}
```

> 📖 **API Reference**: [`Client::new`](https://docs.rs/aerospike/latest/aerospike/struct.Client.html#method.new) | [`Client::scan`](https://docs.rs/aerospike/latest/aerospike/struct.Client.html#method.scan)

> 📖 **API Reference**: [`Client::new()`](https://docs.rs/aerospike/latest/aerospike/struct.Client.html#method.new) | [`Client::query()`](https://docs.rs/aerospike/latest/aerospike/struct.Client.html#method.query) | [`Statement::new()`](https://docs.rs/aerospike/latest/aerospike/struct.Statement.html#method.new) | [`PartitionFilter::all()`](https://docs.rs/aerospike/latest/aerospike/struct.PartitionFilter.html#method.all) | [`Recordset::into_stream()`](https://docs.rs/aerospike/latest/aerospike/struct.Recordset.html#method.into_stream)

The query executes asynchronously. If an error occurs while executing the query, parallel query tasks to other nodes are terminated and the error propagates back through the record stream.