Netstrings v0.2.0 Netstrings

netstring encoding and decoding

An implementation of djb’s netstrings.

Please note that the decoder violates spec by accepting leading zeroes in the len part. However, the encoder will never generate such leading zeros.

Summary

Functions

decode netstrings

encode a netstring

Functions

decode(ns)

Specs

decode(String.t) ::
  {:ok, [String.t], String.t} |
  {:error, String.t}

decode netstrings

The decoder will stop as soon as it encounters an improper or incomplete netstring. Upon success, decoded strings will appear in the second element of the tuple as a list. Any remaining (undecoded) part of the string will appear as the third element.

There are no gaurantees that the remainder is the start of a proper netstring. Appending more recieved data to the remainder may or may not allow it to be decoded.

encode(str)

Specs

encode(String.t) :: {:ok | :error, String.t}

encode a netstring