tvl-depot/users/Profpatsch/netstring
Profpatsch 061a91ff8f refactor(users/Profpatsch/netstring): use toplevel aliases as impls
Apparently I had forgotten that these already exist on the toplevel.
At one point I should unify the two namespaces, but for now at least
acknowledge that they are the same functions.

Change-Id: Ie7d14de0b65f6c750d97630798c65f777b3eda8c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7673
Reviewed-by: Profpatsch <mail@profpatsch.de>
Autosubmit: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
2022-12-29 15:30:38 +00:00
..
tests style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
default.nix refactor(users/Profpatsch/netstring): use toplevel aliases as impls 2022-12-29 15:30:38 +00:00
README.md feat(users/Profpatsch/netencode): rename spec -> README 2021-01-23 15:37:26 +00:00

Netstring

Netstrings are a djb invention. They are intended as a serialization format. Instead of inline control characters like \n or \0 to signal the end of a string, they use a run-length encoding given as the number of bytes, encoded in ASCII, at the beginning of the string.

hello -> 5:hello,
foo! -> 4:foo!,
こんにちは -> 15:こんにちは,

They can be used to encode e.g. lists by simply concatenating and reading them in one-by-one.

If you need a more complex encoding, you could start encoding e.g. tuples as netstrings-in-netstrings, or you could use netencode instead, which is what-if-json-but-netstrings, and takes the idea of netstrings to their logical conclusion.

Resources:

Spec: http://cr.yp.to/proto/netstrings.txt Wiki: https://en.wikipedia.org/wiki/Netstring