Documentation ¶
Overview ¶
Package container gives you a []byte slice on steroids, allowing for quick data appending, prepending and fetching as well as transparent error transportation.
Index ¶
- type Container
- func (c *Container) Append(data []byte)
- func (c *Container) AppendAsBlock(data []byte)
- func (c *Container) AppendNumber(n uint64)
- func (c *Container) CheckError()
- func (c *Container) CompileData() []byte
- func (c *Container) ErrString() string
- func (c *Container) Error() error
- func (c *Container) Get(n int) ([]byte, error)
- func (c *Container) GetMax(n int) []byte
- func (c *Container) GetNextBlock() ([]byte, error)
- func (c *Container) GetNextN16() (uint16, error)
- func (c *Container) GetNextN32() (uint32, error)
- func (c *Container) GetNextN64() (uint64, error)
- func (c *Container) GetNextN8() (uint8, error)
- func (c *Container) HasError() bool
- func (c *Container) Length() (length int)
- func (c *Container) Prepend(data []byte)
- func (c *Container) PrependLength()
- func (c *Container) Replace(data []byte)
- func (c *Container) SetError(err error)
- func (c *Container) WriteToSlice(slice []byte) (n int, containerEmptied bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is []byte sclie on steroids, allowing for quick data appending, prepending and fetching as well as transparent error transportation. (Error transportation requires use of varints for data)
func New ¶
New creates a new container with an optional initial []byte slice. Data will NOT be copied.
func NewContainer ¶
NewContainer is DEPRECATED, please use New(), it's the same thing.
func (*Container) AppendAsBlock ¶
AppendAsBlock appends the length of the data and the data itself. Data will NOT be copied.
func (*Container) AppendNumber ¶
AppendNumber appends a number (varint encoded).
func (*Container) CheckError ¶
func (c *Container) CheckError()
CheckError checks if there is an error in the data. If so, it will parse the error and delete the data.
func (*Container) CompileData ¶
CompileData concatenates all bytes held by the container and returns it as one single []byte slice. Data will NOT be copied and is NOT consumed.
func (*Container) GetMax ¶
GetMax returns as much as possible, but the given amount of bytes at maximum. Data MAY be copied and IS consumed.
func (*Container) GetNextBlock ¶
GetNextBlock returns the next block of data defined by a varint (note: data will MAY be copied and IS consumed).
func (*Container) GetNextN16 ¶
GetNextN16 parses and returns a varint of type uint16.
func (*Container) GetNextN32 ¶
GetNextN32 parses and returns a varint of type uint32.
func (*Container) GetNextN64 ¶
GetNextN64 parses and returns a varint of type uint64.
func (*Container) PrependLength ¶
func (c *Container) PrependLength()
PrependLength prepends the current full length of all bytes in the container.