BSON_READER_NEW_FROM_HANDLE(3)

πŸ’… BSON_READER_NEW_FROM_HANDLE β€” like, the libbson girlies are gonna eat this one up

okay so bestie, welcome to bson_reader_new_from_handle(3) from libbson, the manual page you didn't know you needed until right now. this is the one where you get to plug your own stream into the reader. main character energy, fr fr. πŸŽ€


✨ SYNOPSIS ✨

bson_reader_t *
bson_reader_new_from_handle (void *handle,
                             bson_reader_read_func_t rf,
                             bson_reader_destroy_func_t df);

literally just three little args and you get a whole reader back. the way that this signature is so clean?? obsessed. 🌸


🫢 PARAMETERS 🫢

  • handle β€” a user-provided pointer, or NULL if you're feeling mysterious. your call, queen. (yes, NULL is allowed, it says so right there πŸ‘‘)
  • rf β€” a bson_reader_read_func_t. this is the read function, the vibe of the operation.
  • df β€” a bson_reader_destroy_func_t. this is the cleanup function, holding it down at the end. 🧹

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: this function lets you have a pluggable data stream for the reader. pluggable!! like you can swap the source out and the reader is just fine with it. it's giving "open relationship with your file descriptors." πŸ’€

what can you read from, you ask? sockets, files, memory, or other arbitrary sources. yes, arbitrary. go off, honestly. 🌈

basically if you've got data coming from somewhere and you've got a read func and a destroy func, this is the constructor for you. no cap. πŸ”₯

ngl this is highkey the move when your stream doesn't fit the built-in file/memory helpers β€” you bring the functions, libbson brings the reader. πŸ’œ

⭐ RETURNS ⭐

a newly allocated bson_reader_t if successful; otherwise NULL. 😭

so like, check it. if you get NULL, something went sideways, and you should probably not keep dereferencing things. ask me how I know. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons themselves. πŸ’…


2009-present, MongoDB, Inc. β€” yes, they've been at this since 2009 and the copyright still says present, iconic behaviour honestly.


and that's the whole page, bestie!! πŸ₯³ no notes, 10/10, would read again.

signing off from libbson 2.5.6, dated Oct 09, 2026, page BSON_READER_NEW_FROM_HANDLE(3) β€” go build something slay today πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from