---
name: "bson_iter_binary"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_iter_binary"
---

# bson\_iter\_binary(3)

## SYNOPSIS

```
#define BSON_ITER_HOLDS_BINARY(iter) \
   (bson_iter_type ((iter)) == BSON_TYPE_BINARY)
void
bson_iter_binary (const bson_iter_t *iter,
                  bson_subtype_t *subtype,
                  uint32_t *binary_len,
                  const uint8_t **binary);
```

## PARAMETERS

- •

  **iter**: A *bson\_iter\_t*.

- •

  **subtype**: A location for a *bson\_subtype\_t* or NULL.

- •

  **binary\_len**: A location for the length of **binary**.

- •

  **binary**: A location for a pointer to the immutable buffer.

## DESCRIPTION

This function shall return the binary data of a BSON\_TYPE\_BINARY element. It is a programming error to call this function on a field that is not of type BSON\_TYPE\_BINARY. You can check this with the BSON\_ITER\_HOLDS\_BINARY() macro or *bson\_iter\_type()*.

The buffer that **binary** points to is only valid until the iterator's *bson\_t* is modified or freed.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
