Netstrings v2.0.6 Netstrings View Source

netstring encoding and decoding

An implementation of djb’s netstrings.

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

Link to this section Summary

Functions

Decode netstrings

Decode netstrings, raise exception on error

Encode a netstring

Encode a netstring, raise exception on error

Converts an io device into a Netstrings.Stream

Link to this section Functions

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 guarantees that the remainder is the start of a proper netstring. Appending more received data to the remainder may or may not allow it to be decoded.

Link to this function decode!(str) View Source
decode!(String.t) :: {[String.t], String.t} | no_return

Decode netstrings, raise exception on error

Note that the strings must be correct and complete, having any remainder will raise an exception.

Encode a netstring

Link to this function encode!(str) View Source
encode!(String.t) :: String.t | no_return

Encode a netstring, raise exception on error

Link to this function stream(device) View Source
stream(atom | pid) :: Enumerable.t

Converts an io device into a Netstrings.Stream

Behaves similarly to an IO.Stream with the values marshaled into and out of netstring format. The device should be opened in raw format for predictability.

Note that netstrings approaching or above 64kib may not be properly handled.