bs_capacityassert(3)

πŸ’– bs_capacityassert β€” the manual page, but make it make sense πŸ’–

okay bestie, sit down, we're learning bs_capacityassert(3) from the Library Functions Manual and honestly? it's giving "small function, big feelings". πŸŽ€


✨ NAME ✨

bs_capacityassert β€” assert that there are at least n bytes left in the stream 🫢


✨ SYNTAX ✨

#include <libowfat/parse.h>

int bs_capacityassert(struct bytestream* &bs,
                size_t capacity);

✨ DESCRIPTION ✨

so basically πŸ’… bs_capacityassert checks whether there are at least this many bytes left in the bytestream. this many = capacity.

  • if there aren't enough β†’ it sets the bytestream to the error state and returns 0
  • if there are β†’ it returns 1 ✨
⚠️ okay this part is important, don't skip it. this compares against the limits of the bytestream, not the actual length. these two things are often the same, but bytestreams can be tied to a buffer*, and in that case the actual length of the stream isn't known beforehand. so even if bs_capacityassert returns successful, the following actual reads could still run into an error. no cap. 😭

bs_capacitycheck does the same thing but it does not set the bytestream to the error state if there isn't enough space. so like, same energy, different consequences. 🌸

use bs_capacityleft to find out how many bytes are left in the bytestream. πŸ‘‘

bs_nomoredataassert is the inverse assertion. πŸ”„

use bs_err to find out whether the bytestream is in the error state. 🩺


✨ SEE ALSO ✨

  • bs_init_membuf(3)
  • bs_init_iobuf(3)
  • bs_init_iobuf_size(3)
  • bs_init_membuf(3)
  • bs_capacitycheck(3)
  • bs_capacityleft(3)
  • bs_err(3)
  • bs_nomoredataassert(3)

and that's the whole page, bestie!! πŸ¦‹ this was bs_capacityassert(3) from the Library Functions Manual β€” go forth and assert your capacity, you ate πŸ’…βœ¨