---
name: "rq_encode"
section: "3"
platform: "linux"
package: "liblcrq0.0"
version: "0.2.3-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rq_encode"
---

# rq\_encode(3)

encode data with RaptorQ

## NAME

rq\_encode - encode data with RaptorQ

## SYNOPSIS

```
#include <lcrq.h>
```

**int rq\_encode(rq\_t \****rq***, void \****data***, const size\_t** *len***);**

Compile and link with *-llcrq*.

## DESCRIPTION

This function is used to prepare data for the generation of encoding (original or repair) symbols.

Calls to API functions that generate symbols, such as **[rq\_symbol(3)](/rq_symbol/3.md),** **rq\_symbol\_random(3)** and must be preceded with a call to **rq\_encode()**

**rq\_encode** must be called with a pointer to valid rq\_t context, *rq* and a pointer to *data* to be encoded of length *len* bytes.

The object pointed to by *data* will be used to generate RaptorQ intermediate symbols as per RFC6330. These are referenced by the rq context, and will be free()d when **[rq\_free(3)](/rq_free/3.md)** is called, along with the context itself.

## RETURN VALUE

On success, 0 is returned. If encoding fails, the function returns -1.

## SEE ALSO

[**rq\_init**(3)](/rq_init/3.md), [**rq\_free**(3)](/rq_free/3.md), [**rq\_decode**(3)](/rq_decode/3.md), [**rq\_symbol**(3)](/rq_symbol/3.md), [**lcrq**(7)](/lcrq/7.md)
