> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# encode_records

> encode_records — Kinetica Rust API

[gpudb\_api](https://docs.kinetica.com/content/api/rust/index.md)::<wbr />[avro](https://docs.kinetica.com/content/api/rust/avro/index.md)
[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/avro.rs#L192-L205)&#x20;

<pre>`pub fn encode_records<T: Serialize + Sync>(    schema: &Schema,    records: &[T],) -> Result<Vec<Vec<u8>>, KineticaError>`</pre>

Encodes records to Avro binary format.Automatically chooses between sequential and parallel encoding based on record count. Uses `serde_avro_fast` for optimal performance.

## Type Parameters

<ul>
  <li>`T` - The record type. Must implement `serde::Serialize`.</li>
</ul>

## Arguments

<ul>
  <li>`schema` - The serde\_avro\_fast schema to use for encoding</li>
  <li>`records` - Slice of records to encode</li>
</ul>

## Returns

A vector of binary-encoded Avro records.

## Example

```rust theme={null}
use gpudb_api::avro::{encode_records, parse_fast_schema};

let schema = parse_fast_schema(schema_str)?;
let encoded = encode_records(&schema, &records)?;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.