Documentation
¶
Overview ¶
D. J. Bernstein's netstrings for Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Garbled = errors.New("The netstring was not correctly formatted and could not be read")
var Incomplete = errors.New("The netstring is incomplete")
Functions ¶
func MarshalFrom ¶
Convenience function, create a netstring representation of a []byte
Types ¶
type Netstring ¶
type Netstring struct {
// contains filtered or unexported fields
}
func ForReading ¶
func ForReading() *Netstring
Construct an empty netstring, for input. n.IsComplete() will return false.
func From ¶
Construct a netstring wrapping a byte slice, for output. n.IsComplete() will return true.
func (*Netstring) Bytes ¶
Returns the bytes in the netstring if it is complete, otherwise returns Incomplete as an error.
func (*Netstring) IsComplete ¶
Returns true if the number of bytes advertized in the netstring's length have been read into its buffer. Operations that require the netstring's contents will not be available until it is complete.
func (*Netstring) Length ¶
Returns the advertized length of the netstring. If n.IsComplete() then this is the length of the data in the buffer, too. If this value is negative, in means that no length has been read yet.
func (*Netstring) ReadFrom ¶
Read a netstring from input. Returns any errors from input except io.EOF. Returns Garbled if the input was not a valid netstring. Returns Incomplete if the input was shorter than a full netstring. To resume reading where you left off, call Readfrom(input) again. Calling Readfrom(input) on a complete netstring does nothing.