BSON_READER_NEW_FROM_FD(3)

πŸ’… BSON_READER_NEW_FROM_FD(3) πŸ’…

okay so bestie, we're in the libbson section of the manual, and today's main character is bson_reader_new_from_fd() β€” literally the glow-up that turns a raw file descriptor into a whole entire reader ✨


🌸 SYNOPSIS 🌸

bson_reader_t *
bson_reader_new_from_fd (int fd, bool close_on_destroy);

πŸŽ€ PARAMETERS πŸŽ€

  • fd β€” a valid file-descriptor. like, an actual one. it has to be valid, no cap 🫢
  • close_on_destroy β€” a bool that decides whether close() gets called on fd when the reader is destroyed. yes-or-no energy πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so the bson_reader_new_from_fd() function shall create a brand-new bson_reader_t that will read from the file-descriptor you handed it. that's it, that's the vibe πŸŽ€

⚠️ fd MUST be in blocking mode. like, non-negotiable, bestie. blocking mode or nothing 😭

if close_fd is true, then fd will be closed when the bson_reader_t is destroyed with bson_reader_destroy(). so like, the reader takes care of cleanup for you β€” iconic behavior honestly πŸ‘‘


✨ RETURNS ✨

a newly allocated bson_reader_t that should be freed with bson_reader_destroy(). don't just leave it lying around, that's not the move πŸ™ˆ


πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc β€” the icons behind all of this 🫢


2009-present, MongoDB, Inc. protecting the intellectual property, as they should ⭐


and that's the whole page, bestie! this specific copy of the manual is version 2.5.6, dated Oct 09, 2026, served fresh from the libbson collection β€” go forth and read those file-descriptors responsibly πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from