class Netstring
- Netstring
- Reference
- Object
Overview
The primary namespace for netstring.cr
.
Defined in:
netstring.crConstant Summary
-
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 Method Summary
-
.parse(input : String, max : UInt32 = NETSTRING_MAX)
Returns a new
Netstring
based on input. -
.parse(input : IO, max : UInt32 = NETSTRING_MAX)
Like the other
.parse
, but takes anIO
instead.
Instance Method Summary
-
#data : Slice(UInt8)
Returns the body of the netstring, as a slice.
-
#size
Returns the size of the parsed netstring.
-
#to_s(io)
Returns a string containing the encoded contents of the netstring.
Class Method Detail
def self.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"
def self.parse(input : IO, max : UInt32 = NETSTRING_MAX)
#
Instance Method Detail
def 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.