NNG_MSG_TRIM(3)
β¨ 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(), removessizebytes. 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
nng_msg_alloc(3)nng_msg_append(3)nng_msg_body(3)nng_msg_chop(3)nng_msg_free(3)nng_msg_insert(3)nng_msg_len(3)nng_msg_realloc(3)nng_strerror(3)nng_msg(5)nng(7)
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
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms