class

Netstring

Inherits Reference < Object

The primary namespace for netstring.cr.

Constants

NETSTRING_MAX = 999999999_u32

The default maximum netstring size, taken from the reference implementation.

VERSION = "0.1.0"

The current version of netstring.cr.

Class methods

parse(input : String, max : UInt32 = NETSTRING_MAX)

Returns a new Netstring based on input.

max is a user-specifiable maximum size for input, which can be set either above or below the default NETSTRING_MAX.

Raises a ParseError on any parser failure.

ns = Netstring.parse "3:foo,"
ns.size # => 3
ns.data # => Bytes[102, 111, 111]
ns.to_s # => "foo"
Source
parse(input : IO, max : UInt32 = NETSTRING_MAX)

Like the other parse, but takes an IO instead. See parse.

Source

Instance methods

data

Returns the body of the netstring, as a slice.

Source
size

Returns the size of the parsed netstring.

Source
to_s(io)

Returns a string containing the encoded contents of the netstring.

NOTE: This will not fix or deduce the correct encoding for you. It assumes UTF-8.

Source

Nested types