{"modulePath":"github.com/google/gapid","version":"v1.6.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package binary\n\n## Functions\n\n```go\nfunc ConsumeBytes(r Reader, bytes uint64) uint64\n```\nConsumeBytes reads and throws away a number of bytes from r, returning the number of bytes it consumed.\n\n```go\nfunc ReadInt(r Reader, bits int32) int64\n```\nReadInt reads a signed integer of either 8, 16, 32 or 64 bits from r, returning the result as a int64.\n\n```go\nfunc ReadUint(r Reader, bits int32) uint64\n```\nReadUint reads an unsigned integer of either 8, 16, 32 or 64 bits from r, returning the result as a uint64.\n\n```go\nfunc Write(w Writer, v interface{})\n```\nWrite writes v to the writer w. v must be an byte, integer, float, boolean, string, slice or array.\n\n```go\nfunc WriteBytes(w Writer, v uint8, count int32)\n```\nWriteBytes writes the given v for count times to writer w.\n\n```go\nfunc WriteInt(w Writer, bits int32, v int64)\n```\nWriteInt writes the signed integer v of either 8, 16, 32 or 64 bits to w.\n\n```go\nfunc WriteUint(w Writer, bits int32, v uint64)\n```\nWriteUint writes the unsigned integer v of either 8, 16, 32 or 64 bits to w.\n\n## Types\n\n```go\ntype BitStream struct {\n\tData     []byte // The byte slice containing the bits\n\tReadPos  uint32 // The current read offset from the start of the Data slice (in bits)\n\tWritePos uint32 // The current write offset from the start of the Data slice (in bits)\n}\n```\nBitStream provides methods for reading and writing bits to a slice of bytes. Bits are packed in a least-significant-bit to most-significant-bit order.\n\n```go\nfunc (s *BitStream) CanRead(count uint32) bool\n```\nCanRead returns true if there's enough data to call Read(count).\n\n```go\nfunc (s *BitStream) Read(count uint32) uint64\n```\nRead reads the specified number of bits from the BitStream, increamenting the ReadPos by the specified number of bits and returning the bits packed into a uint64. The bits are packed into the uint64 from LSB to MSB.\n\n```go\nfunc (s *BitStream) ReadBit() uint64\n```\nReadBit reads a single bit from the BitStream, incrementing ReadPos by one.\n\n```go\nfunc (s *BitStream) Write(bits uint64, count uint32)\n```\nWrite writes the specified number of bits from the packed uint64, increamenting the WritePos by the specified number of bits. The bits are read from the uint64 from LSB to MSB.\n\n```go\nfunc (s *BitStream) WriteBit(bit uint64)\n```\nWriteBit writes a single bit to the BitStream, incrementing WritePos by one.\n\n```go\ntype Reader interface {\n\tio.Reader\n\t// Data reads the data bytes in their entirety.\n\tData([]byte)\n\t// Bool decodes and returns a boolean value from the Reader.\n\tBool() bool\n\t// Int8 decodes and returns a signed, 8 bit integer value from the Reader.\n\tInt8() int8\n\t// Uint8 decodes and returns an unsigned, 8 bit integer value from the Reader.\n\tUint8() uint8\n\t// Int16 decodes and returns a signed, 16 bit integer value from the Reader.\n\tInt16() int16\n\t// Uint16 decodes and returns an unsigned, 16 bit integer value from the Reader.\n\tUint16() uint16\n\t// Int32 decodes and returns a signed, 32 bit integer value from the Reader.\n\tInt32() int32\n\t// Uint32 decodes and returns an unsigned, 32 bit integer value from the Reader.\n\tUint32() uint32\n\t// Float16 decodes and returns a 16 bit floating-point value from the Reader.\n\tFloat16() f16.Number\n\t// Float32 decodes and returns a 32 bit floating-point value from the Reader.\n\tFloat32() float32\n\t// Int64 decodes and returns a signed, 64 bit integer value from the Reader.\n\tInt64() int64\n\t// Uint64 decodes and returns an unsigned, 64 bit integer value from the Reader.\n\tUint64() uint64\n\t// Float64 decodes and returns a 64 bit floating-point value from the Reader.\n\tFloat64() float64\n\t// String decodes and returns a string from the Reader.\n\tString() string\n\t// Decode a collection count from the stream.\n\tCount() uint32\n\t// If there is an error reading any input, all further reading returns the\n\t// zero value of the type read. Error() returns the error which stopped\n\t// reading from the stream. If reading has not stopped it returns nil.\n\tError() error\n\t// Set the error state and stop reading from the stream.\n\tSetError(error)\n}\n```\nReader provides methods for decoding values.\n\n```go\ntype Writer interface {\n\t// Data writes the data bytes in their entirety.\n\tData([]byte)\n\t// Bool encodes a boolean value to the Writer.\n\tBool(bool)\n\t// Int8 encodes a signed, 8 bit integer value to the Writer.\n\tInt8(int8)\n\t// Uint8 encodes an unsigned, 8 bit integer value to the Writer.\n\tUint8(uint8)\n\t// Int16 encodes a signed, 16 bit integer value to the Writer.\n\tInt16(int16)\n\t// Uint16 encodes an unsigned, 16 bit integer value to the Writer.\n\tUint16(uint16)\n\t// Int32 encodes a signed, 32 bit integer value to the Writer.\n\tInt32(int32)\n\t// Uint32 encodes an usigned, 32 bit integer value to the Writer.\n\tUint32(uint32)\n\t// Float16 encodes a 16 bit floating-point value to the Writer.\n\tFloat16(f16.Number)\n\t// Float32 encodes a 32 bit floating-point value to the Writer.\n\tFloat32(float32)\n\t// Int64 encodes a signed, 64 bit integer value to the Writer.\n\tInt64(int64)\n\t// Uint64 encodes an unsigned, 64 bit integer value to the Encoders's io.Writer.\n\tUint64(uint64)\n\t// Float64 encodes a 64 bit floating-point value to the Writer.\n\tFloat64(float64)\n\t// String encodes a string to the Writer.\n\tString(string)\n\t// If there is an error writing any output, all further writing becomes\n\t// a no-op. Error() returns the error which stopped writing to the stream.\n\t// If writing has not stopped it returns nil.\n\tError() error\n\t// Set the error state and stop writing to the stream.\n\tSetError(error)\n}\n```\nWriter provides methods for encoding values.\n\n","path":"github.com/google/gapid/core/data/binary","name":"binary","synopsis":"","isRedistributable":true}
