NNG_MSG_TRIM(3)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

✨ NNG_MSG_TRIM πŸ’–

okay bestie so this is a page from the NNG Reference Manual, and it's all about nng_msg_trim β€” the function family that yeets bytes off the front of a message. no cap. πŸŽ€


πŸ’… NAME

nng_msg_trim β€” remove data from start of message body 🧚


πŸ¦‹ SYNOPSIS

#include <nng/nng.h>

int nng_msg_trim(nng_msg *msg, size_t size);
int nng_msg_trim_u16(nng_msg *msg, uint16_t *val16);
int nng_msg_trim_u32(nng_msg *msg, uint32_t *val32);
int nng_msg_trim_u64(nng_msg *msg, uint64_t *val64);

🌸 DESCRIPTION

okay so picture this: you've got a message, and its body has stuff at the start that you don't want anymore. the nng_msg_trim() family of functions removes data from the start of the body of message msg. it's giving "scissors but for buffers". βœ‚οΈβœ¨

here's the breakdown, bestie:

  • the first function, nng_msg_trim(), removes size bytes. that's it. that's the whole job. πŸ‘‘
  • the remaining functions remove 2, 4, or 8 bytes respectively, and β€” plot twist β€” they store those bytes in the value (such as val32) after converting them from network-byte order (big-endian) to native byte order. so you're not just trimming, you're also decoding. main character energy fr fr. 🌈

πŸ’– RETURN VALUES

these functions return 0 on success, and non-zero otherwise. simple as. 🫢


🚨 ERRORS

  • NNG_EINVAL β€” the message body is too short to remove the requested data. like?? you can't trim what isn't there bestie 😭 the vibe check failed, the body simply does not have enough bytes.

πŸ‘€ SEE ALSO


and that's the whole page, babe β€” literally every detail, none skipped, no crumbs left behind πŸ’œ

this lil masterpiece comes to you courtesy of the NNG Reference Manual, dated 2026-06-30. that's the source, that's the version, that's the date. periodt. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from