Documentation ¶
Index ¶
- Constants
- Variables
- func BufDesc(inBuf []byte) string
- func SmartDecodeFromBase32(srcBase32 []byte, tryDst []byte) ([]byte, error)
- func SmartMarshal(item Marshalable, tryDst []byte) []byte
- func SmartMarshalToBase32(item Marshalable, tryDst []byte) []byte
- func Zero(buf []byte)
- type Buf
- type Bytes
- type Marshalable
- type Unmarshalable
Constants ¶
const GeohashBase32Alphabet = "0123456789bcdefghjkmnpqrstuvwxyz"
GeohashBase32Alphabet is the alphabet used for Base32Encoding
Variables ¶
var ( // Base32Encoding is used to encode/decode binary buffer to/from base 32 Base32Encoding = base32.NewEncoding(GeohashBase32Alphabet).WithPadding(base32.NoPadding) // GenesisMemberID is the genesis member ID GenesisMemberID = uint32(1) )
var (
// Parsing/Encoding
ErrSyntax = &encodingErr{"invalid hex string"}
)
Errors
Functions ¶
func BufDesc ¶
BufDesc returns a base32 encoding of a binary string, limiting it to a short number of character for debugging and logging.
func SmartDecodeFromBase32 ¶
SmartDecodeFromBase32 decodes the base32 (ASCII) string into the given scrap buffer, returning the scrap buffer set to proper size.
If tryDst is not large enough, a new buffer is allocated and returned in its place.
func SmartMarshal ¶
func SmartMarshal(item Marshalable, tryDst []byte) []byte
SmartMarshal marshals the given item to the given buffer. If there is not enough space a new one is allocated. The purpose of this is to reuse a scrap buffer.
func SmartMarshalToBase32 ¶
func SmartMarshalToBase32(item Marshalable, tryDst []byte) []byte
SmartMarshalToBase32 marshals the given item and then encodes it into a base32 (ASCII) byte string.
If tryDst is not large enough, a new buffer is allocated and returned in its place.
Types ¶
type Buf ¶
type Buf struct { Unmarshalable Bytes []byte }
Buf is a flexible buffer designed for reuse.
type Bytes ¶
type Bytes []byte
Bytes marshal/unmarshal as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (Bytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Bytes) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Bytes) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Marshalable ¶
type Marshalable interface { Marshal() ([]byte, error) MarshalToSizedBuffer([]byte) (int, error) Size() int }
Marshalable generalizes efficient serialization
type Unmarshalable ¶
Unmarshalable used to generalize deserialization