Documentation ¶
Overview ¶
Package format provides readers and writers for various binary formats used by Spy Cards Online.
Index ¶
- Variables
- func Catch(err *error)
- func Decode32(src string) ([]byte, error)
- func Encode32(src []byte) string
- func Encode32Space(src []byte) string
- func Throw(err error)
- type FileID
- type Reader
- func (r *Reader) Byte() byte
- func (r *Reader) Bytes(count int) []byte
- func (r *Reader) Init(b []byte)
- func (r *Reader) Len() int
- func (r *Reader) Peek(n int) []byte
- func (r *Reader) Read(v interface{})
- func (r *Reader) SVarInt() int64
- func (r *Reader) String() string
- func (r *Reader) String1() string
- func (r *Reader) SubReader() *Reader
- func (r *Reader) UVarInt() uint64
- type Writer
Constants ¶
This section is empty.
Variables ¶
var Crockford32 = base32.NewEncoding("0123456789ABCDEFGHJKMNPQRSTVWXYZ").WithPadding(base32.NoPadding)
Crockford32 is an implementation of Crockford Base 32. See https://www.crockford.com/base32.html
Functions ¶
func Catch ¶
func Catch(err *error)
Catch is a deferred function that recovers an error passed to Throw in *err.
func Decode32 ¶
Decode32 decodes a Crockford Base 32 string, applying the recommended transformations to fix typos.
func Encode32Space ¶
Encode32Space encodes a slice of bytes as a Crockford Base 32 string with a space after every 4 characters.
Types ¶
type FileID ¶
FileID is the decoded form of a file identifier for Spy Cards Online.FileID
It contains the first 8 bytes of the SHA-256 hash of the file, along with an opaque integer identifier.
func (FileID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (FileID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*FileID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*FileID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decodes data from a binary format.
There should be a deferred call to Catch when Reader is in use.
func (*Reader) Peek ¶
Peek returns the next n bytes in the buffer without consuming them.
Peek panics if n is greater than Len.
func (*Reader) Read ¶
func (r *Reader) Read(v interface{})
Read decodes a fixed-size data structure from the Reader.
func (*Reader) String1 ¶
String1 decodes a length-prefixed string from the Reader.
The maximum length of a string in this legacy format is 255 characters.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer encodes data into a binary format.
There should be a deferred call to Catch when Writer is in use.
func (*Writer) Data ¶
Data returns the buffer held by the Writer.
The buffer is not copied, so modifications to the buffer may result in modifications to the writer.
func (*Writer) String1 ¶
String1 appends a length-prefixed string to the Writer.
The maximum length of a string in this legacy format is 255 characters.
func (*Writer) SubWriter ¶
SubWriter returns a Writer that can be used to append a length-prefixed section of data.
done must be called before any methods are called on w.