BSON_ITER_BINARY(3)
π BSON_ITER_BINARY(3) β like, the libbson girlies know β¨
okay so bestie, you're in the libbson corner of the universe and you need to pull the binary payload out of a BSON element? say less, this is literally the page for you π«Ά
πΈ 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β abson_iter_t. the iterator itself, the main character of this whole operation πsubtypeβ a location to stash abson_subtype_t, orNULLif you literally don't care. your call, no pressure πbinary_lenβ a location for the length ofbinary. so you know how much data you're dealing with β¨binaryβ a location for a pointer to the immutable buffer. that's where the data pointer gets dropped off π¦
π DESCRIPTION π
so this function bson_iter_binary() shall return the binary data of a BSON_TYPE_BINARY element. periodt. that's the whole job and it ate π₯
ngl bestie, big warning: it is a programming error to call this on a field that is not of type BSON_TYPE_BINARY. like, do not do that. it's giving chaos π
you can vibe-check the type first with the BSON_ITER_HOLDS_BINARY() macro or with bson_iter_type(). use them, they're right there, they're iconic π
also super important: the buffer that binary points to is only valid until the iterator's bson_t is modified or freed. like it is not yours forever, it's a borrowed fit, return it to the universe π§
π SEE ALSO π
bson_iter_binary_equal()bson_iter_binary_subtype()
β AUTHOR β
MongoDB, Inc β the legends themselves π«Ά
π COPYRIGHT π
2009-present, MongoDB, Inc. β all the rights reserved, no cap π
π and that's the whole page bestie! go forth and read those binary buffers responsibly, mwah π
this lil dream was brought to you by libbson version 2.5.6, dated Oct 09, 2026 β see you in the next release, slay πβ¨
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms