Documentation ¶
Index ¶
- func BitToU8(b byte, start int8, end int8) uint8
- func BitsCut(data []byte, start, end int, o Order) ([]byte, error)
- func BytesToString(b []byte) string
- func CopyBits(src, dst []byte, offset int) error
- func StringToBytes(s string) []byte
- type BitReader
- func (r *BitReader) Read(p []byte) (int, error)
- func (r *BitReader) ReadBit() (byte, error)
- func (r *BitReader) ReadBits(p []byte, start, end int) error
- func (r *BitReader) ReadByte() (byte, error)
- func (r *BitReader) SkipBits(n int64) (int64, error)
- func (r *BitReader) SkipBytes(n int64) (int64, error)
- type BitWriter
- type ErrLongLength
- type ErrShortLength
- type FormatUnsupportedTypeError
- type Order
- type ReadSeeker
- func (r *ReadSeeker) Bool(t *bool) *ReadSeeker
- func (r *ReadSeeker) Byte(t *byte) *ReadSeeker
- func (r *ReadSeeker) Bytes(t []byte) *ReadSeeker
- func (r *ReadSeeker) F32(t *float32) *ReadSeeker
- func (r *ReadSeeker) F64(t *float64) *ReadSeeker
- func (r *ReadSeeker) I16(t *int16) *ReadSeeker
- func (r *ReadSeeker) I24(t *int32) *ReadSeeker
- func (r *ReadSeeker) I32(t *int32) *ReadSeeker
- func (r *ReadSeeker) I40(t *int64) *ReadSeeker
- func (r *ReadSeeker) I48(t *int64) *ReadSeeker
- func (r *ReadSeeker) I56(t *int64) *ReadSeeker
- func (r *ReadSeeker) I64(t *int64) *ReadSeeker
- func (r *ReadSeeker) I8(t *int8) *ReadSeeker
- func (r *ReadSeeker) Read(data any) *ReadSeeker
- func (r *ReadSeeker) Seek(offset int64, whence int) *ReadSeeker
- func (r *ReadSeeker) SkipBytes(n int64) *ReadSeeker
- func (r *ReadSeeker) String(t *string, n int) *ReadSeeker
- func (r *ReadSeeker) U16(t *uint16) *ReadSeeker
- func (r *ReadSeeker) U24(t *uint32) *ReadSeeker
- func (r *ReadSeeker) U32(t *uint32) *ReadSeeker
- func (r *ReadSeeker) U40(t *uint64) *ReadSeeker
- func (r *ReadSeeker) U48(t *uint64) *ReadSeeker
- func (r *ReadSeeker) U56(t *uint64) *ReadSeeker
- func (r *ReadSeeker) U64(t *uint64) *ReadSeeker
- func (r *ReadSeeker) U8(t *uint8) *ReadSeeker
- type Reader
- func (r *Reader) Bits(n int, s any) *Reader
- func (r *Reader) Bool(t *bool) *Reader
- func (r *Reader) Byte(t *byte) *Reader
- func (r *Reader) Bytes(t []byte) *Reader
- func (r *Reader) Error() error
- func (r *Reader) F32(t *float32) *Reader
- func (r *Reader) F64(t *float64) *Reader
- func (r *Reader) I16(t *int16) *Reader
- func (r *Reader) I24(t *int32) *Reader
- func (r *Reader) I32(t *int32) *Reader
- func (r *Reader) I40(t *int64) *Reader
- func (r *Reader) I48(t *int64) *Reader
- func (r *Reader) I56(t *int64) *Reader
- func (r *Reader) I64(t *int64) *Reader
- func (r *Reader) I8(t *int8) *Reader
- func (r *Reader) N() int
- func (r *Reader) Read(data any) *Reader
- func (r *Reader) ReadBool() (t bool, err error)
- func (r *Reader) ReadByte() (t byte, err error)
- func (r *Reader) ReadBytes(n int) (t []byte, err error)
- func (r *Reader) ReadF32() (t float32, err error)
- func (r *Reader) ReadF64() (t float64, err error)
- func (r *Reader) ReadI16() (t int16, err error)
- func (r *Reader) ReadI24() (t int32, err error)
- func (r *Reader) ReadI32() (t int32, err error)
- func (r *Reader) ReadI40() (t int64, err error)
- func (r *Reader) ReadI48() (t int64, err error)
- func (r *Reader) ReadI56() (t int64, err error)
- func (r *Reader) ReadI64() (t int64, err error)
- func (r *Reader) ReadI8() (t int8, err error)
- func (r *Reader) ReadString(n int) (t string, err error)
- func (r *Reader) ReadU16() (t uint16, err error)
- func (r *Reader) ReadU24() (t uint32, err error)
- func (r *Reader) ReadU32() (t uint32, err error)
- func (r *Reader) ReadU40() (t uint64, err error)
- func (r *Reader) ReadU48() (t uint64, err error)
- func (r *Reader) ReadU56() (t uint64, err error)
- func (r *Reader) ReadU64() (t uint64, err error)
- func (r *Reader) ReadU8() (t uint8, err error)
- func (r *Reader) Reset()
- func (r *Reader) SkipBits(n int64) *Reader
- func (r *Reader) SkipBytes(n int64) *Reader
- func (r *Reader) String(t *string, n int) *Reader
- func (r *Reader) Total() int
- func (r *Reader) U16(t *uint16) *Reader
- func (r *Reader) U24(t *uint32) *Reader
- func (r *Reader) U32(t *uint32) *Reader
- func (r *Reader) U40(t *uint64) *Reader
- func (r *Reader) U48(t *uint64) *Reader
- func (r *Reader) U56(t *uint64) *Reader
- func (r *Reader) U64(t *uint64) *Reader
- func (r *Reader) U8(t *uint8) *Reader
- type WriteSeeker
- func (w *WriteSeeker) Bool(t bool) *WriteSeeker
- func (w *WriteSeeker) Byte(t byte) *WriteSeeker
- func (w *WriteSeeker) Bytes(t []byte) *WriteSeeker
- func (w *WriteSeeker) F32(t float32) *WriteSeeker
- func (w *WriteSeeker) F64(t float64) *WriteSeeker
- func (w *WriteSeeker) I16(t int16) *WriteSeeker
- func (w *WriteSeeker) I24(t int32) *WriteSeeker
- func (w *WriteSeeker) I32(t int32) *WriteSeeker
- func (w *WriteSeeker) I40(t int64) *WriteSeeker
- func (w *WriteSeeker) I48(t int64) *WriteSeeker
- func (w *WriteSeeker) I56(t int64) *WriteSeeker
- func (w *WriteSeeker) I64(t int64) *WriteSeeker
- func (w *WriteSeeker) I8(t int8) *WriteSeeker
- func (w *WriteSeeker) Seek(offset int64, whence int) *WriteSeeker
- func (w *WriteSeeker) String(t string) *WriteSeeker
- func (w *WriteSeeker) U16(t uint16) *WriteSeeker
- func (w *WriteSeeker) U24(t uint32) *WriteSeeker
- func (w *WriteSeeker) U32(t uint32) *WriteSeeker
- func (w *WriteSeeker) U40(t uint64) *WriteSeeker
- func (w *WriteSeeker) U48(t uint64) *WriteSeeker
- func (w *WriteSeeker) U56(t uint64) *WriteSeeker
- func (w *WriteSeeker) U64(t uint64) *WriteSeeker
- func (w *WriteSeeker) U8(t uint8) *WriteSeeker
- func (w *WriteSeeker) Write(data any) *WriteSeeker
- type Writer
- func (w *Writer) Bool(s bool) *Writer
- func (w *Writer) Byte(s byte) *Writer
- func (w *Writer) Bytes(s []byte) *Writer
- func (w *Writer) Error() error
- func (w *Writer) F32(s float32) *Writer
- func (w *Writer) F64(s float64) *Writer
- func (w *Writer) I16(s int16) *Writer
- func (w *Writer) I24(s int32) *Writer
- func (w *Writer) I32(s int32) *Writer
- func (w *Writer) I40(s int64) *Writer
- func (w *Writer) I48(s int64) *Writer
- func (w *Writer) I56(s int64) *Writer
- func (w *Writer) I64(s int64) *Writer
- func (w *Writer) I8(s int8) *Writer
- func (w *Writer) N() int
- func (w *Writer) ReadFrom(r io.Reader) *Writer
- func (w *Writer) Reset() *Writer
- func (w *Writer) String(s string) *Writer
- func (w *Writer) Total() int
- func (w *Writer) U16(s uint16) *Writer
- func (w *Writer) U24(s uint32) *Writer
- func (w *Writer) U32(s uint32) *Writer
- func (w *Writer) U40(s uint64) *Writer
- func (w *Writer) U48(s uint64) *Writer
- func (w *Writer) U56(s uint64) *Writer
- func (w *Writer) U64(s uint64) *Writer
- func (w *Writer) U8(s uint8) *Writer
- func (w *Writer) Write(data any) *Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitsCut ¶ added in v0.5.0
BitsCut([]byte{0b0110_1101}, 1, 4, BigEndian) -> []byte{0b0000_0110} BitsCut([]byte{0b0110_1101, 0b1001_0010}, 1, 9, BigEndian) -> []byte{0b1101_1011} BitsCut([]byte{0b0110_1101, 0b1001_0010, 0b1011_0111}, 2, 14, BigEndian) -> []byte{0b1011_0110, 0b0000_0100} BitsCut([]byte{0b0110_1101, 0b1001_0010, 0b1011_0111}, 2, 18, BigEndian) -> []byte{0b1011_0110, 0b0100_1010} BitsCut([]byte{0b0110_1101, 0b1001_0010, 0b1011_0111}, 7, 9, BigEndian) -> []byte{0b0000_0011} BitsCut([]byte{0b0110_1101, 0b1001_0010, 0b1011_0111}, 7, 15, BigEndian) -> []byte{0b1100_1001} BitsCut([]byte{0b0110_1101, 0b1001_0010, 0b1011_0111}, 7, 20, LittleEndian) -> []byte{0b0000_1011, 0b1100_1001}
func BytesToString ¶ added in v0.3.4
The change of bytes will cause the change of string synchronously
func CopyBits ¶ added in v0.5.0
CopyBits copies bits from src to dst, starting at offset. offset is the bit index of dst. len(dst)*8 must be greater than or equal to len(src)*8 + offset.
src := []byte{0b10110101, 0b10100011} dst := []byte{0b00001111, 0b11110000, 0b10100101} CopyBits(src, dst, 2) // dst == []byte{0b00101101, 0b01101000, 0b11100101}
func StringToBytes ¶ added in v0.3.4
If string is readonly, modifying bytes will cause panic
Types ¶
type BitReader ¶ added in v0.5.0
type BitReader struct {
// contains filtered or unexported fields
}
func NewBitReader ¶ added in v0.5.0
func (*BitReader) ReadBits ¶ added in v0.5.0
ReadBits reads bits from the stream. The bits are written to p, starting at bit start and ending at bit end. including start, excluding end.
type BitWriter ¶ added in v0.5.2
type BitWriter struct {
// contains filtered or unexported fields
}
func NewBitWriter ¶ added in v0.5.2
type ErrLongLength ¶ added in v0.5.0
type ErrLongLength uint
func (ErrLongLength) Error ¶ added in v0.5.0
func (e ErrLongLength) Error() string
type ErrShortLength ¶ added in v0.5.0
type ErrShortLength uint8
func (ErrShortLength) Error ¶ added in v0.5.0
func (e ErrShortLength) Error() string
type FormatUnsupportedTypeError ¶ added in v0.5.0
type FormatUnsupportedTypeError string
func (FormatUnsupportedTypeError) Error ¶ added in v0.5.0
func (e FormatUnsupportedTypeError) Error() string
type Order ¶ added in v0.5.0
type Order interface { ReadI8(s byte) int8 // A maximum of 2 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI16(s []byte) int16 // A maximum of 3 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI24(s []byte) int32 // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI32(s []byte) int32 // A maximum of 5 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI40(s []byte) int64 // A maximum of 6 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI48(s []byte) int64 // A maximum of 7 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI56(s []byte) int64 // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadI64(s []byte) int64 ReadU8(s byte) uint8 // A maximum of 2 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU16(s []byte) uint16 // A maximum of 3 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU24(s []byte) uint32 // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU32(s []byte) uint32 // A maximum of 5 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU40(s []byte) uint64 // A maximum of 6 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU48(s []byte) uint64 // A maximum of 7 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU56(s []byte) uint64 // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadU64(s []byte) uint64 // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadF32(s []byte) float32 // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost ReadF64(s []byte) float64 ReadBool(s byte) bool WriteI8(buf *byte, v int8) // A maximum of 2 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI16(buf []byte, v int16) // A maximum of 3 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI24(buf []byte, v int32) // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI32(buf []byte, v int32) // A maximum of 5 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI40(buf []byte, v int64) // A maximum of 6 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI48(buf []byte, v int64) // A maximum of 7 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI56(buf []byte, v int64) // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteI64(buf []byte, v int64) WriteU8(buf *byte, v uint8) // A maximum of 2 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU16(buf []byte, v uint16) // A maximum of 3 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU24(buf []byte, v uint32) // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU32(buf []byte, v uint32) // A maximum of 5 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU40(buf []byte, v uint64) // A maximum of 6 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU48(buf []byte, v uint64) // A maximum of 7 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU56(buf []byte, v uint64) // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteU64(buf []byte, v uint64) // A maximum of 4 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteF32(buf []byte, v float32) // A maximum of 8 bytes is required. If the size of the incoming slice is not enough, the precision may be lost WriteF64(buf []byte, v float64) WriteBool(buf *byte, v bool) }
type ReadSeeker ¶ added in v0.3.0
type ReadSeeker struct { *Reader // contains filtered or unexported fields }
func NewReadSeeker ¶ added in v0.3.0
func NewReadSeeker(rs io.ReadSeeker, o Order) *ReadSeeker
func (*ReadSeeker) Bool ¶ added in v0.3.1
func (r *ReadSeeker) Bool(t *bool) *ReadSeeker
func (*ReadSeeker) Byte ¶ added in v0.3.1
func (r *ReadSeeker) Byte(t *byte) *ReadSeeker
func (*ReadSeeker) Bytes ¶ added in v0.3.1
func (r *ReadSeeker) Bytes(t []byte) *ReadSeeker
func (*ReadSeeker) F32 ¶ added in v0.5.0
func (r *ReadSeeker) F32(t *float32) *ReadSeeker
func (*ReadSeeker) F64 ¶ added in v0.5.0
func (r *ReadSeeker) F64(t *float64) *ReadSeeker
func (*ReadSeeker) I16 ¶ added in v0.5.0
func (r *ReadSeeker) I16(t *int16) *ReadSeeker
func (*ReadSeeker) I24 ¶ added in v0.5.0
func (r *ReadSeeker) I24(t *int32) *ReadSeeker
func (*ReadSeeker) I32 ¶ added in v0.5.0
func (r *ReadSeeker) I32(t *int32) *ReadSeeker
func (*ReadSeeker) I40 ¶ added in v0.5.0
func (r *ReadSeeker) I40(t *int64) *ReadSeeker
func (*ReadSeeker) I48 ¶ added in v0.5.0
func (r *ReadSeeker) I48(t *int64) *ReadSeeker
func (*ReadSeeker) I56 ¶ added in v0.5.0
func (r *ReadSeeker) I56(t *int64) *ReadSeeker
func (*ReadSeeker) I64 ¶ added in v0.5.0
func (r *ReadSeeker) I64(t *int64) *ReadSeeker
func (*ReadSeeker) I8 ¶ added in v0.3.1
func (r *ReadSeeker) I8(t *int8) *ReadSeeker
func (*ReadSeeker) Read ¶ added in v0.5.0
func (r *ReadSeeker) Read(data any) *ReadSeeker
func (*ReadSeeker) Seek ¶ added in v0.3.0
func (r *ReadSeeker) Seek(offset int64, whence int) *ReadSeeker
func (*ReadSeeker) SkipBytes ¶ added in v0.4.0
func (r *ReadSeeker) SkipBytes(n int64) *ReadSeeker
func (*ReadSeeker) String ¶ added in v0.3.4
func (r *ReadSeeker) String(t *string, n int) *ReadSeeker
func (*ReadSeeker) U16 ¶ added in v0.5.0
func (r *ReadSeeker) U16(t *uint16) *ReadSeeker
func (*ReadSeeker) U24 ¶ added in v0.5.0
func (r *ReadSeeker) U24(t *uint32) *ReadSeeker
func (*ReadSeeker) U32 ¶ added in v0.5.0
func (r *ReadSeeker) U32(t *uint32) *ReadSeeker
func (*ReadSeeker) U40 ¶ added in v0.5.0
func (r *ReadSeeker) U40(t *uint64) *ReadSeeker
func (*ReadSeeker) U48 ¶ added in v0.5.0
func (r *ReadSeeker) U48(t *uint64) *ReadSeeker
func (*ReadSeeker) U56 ¶ added in v0.5.0
func (r *ReadSeeker) U56(t *uint64) *ReadSeeker
func (*ReadSeeker) U64 ¶ added in v0.5.0
func (r *ReadSeeker) U64(t *uint64) *ReadSeeker
func (*ReadSeeker) U8 ¶ added in v0.3.1
func (r *ReadSeeker) U8(t *uint8) *ReadSeeker
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) ReadString ¶ added in v0.3.4
func (*Reader) SkipBits ¶ added in v0.5.1
r.N() and r.Total() dont work with r.SkipBits() and r.SkipBytes()
type WriteSeeker ¶ added in v0.3.0
type WriteSeeker struct { *Writer // contains filtered or unexported fields }
func NewWriteSeeker ¶ added in v0.3.0
func NewWriteSeeker(ws io.WriteSeeker, o Order) *WriteSeeker
func (*WriteSeeker) Bool ¶ added in v0.3.1
func (w *WriteSeeker) Bool(t bool) *WriteSeeker
func (*WriteSeeker) Byte ¶ added in v0.3.1
func (w *WriteSeeker) Byte(t byte) *WriteSeeker
func (*WriteSeeker) Bytes ¶ added in v0.3.1
func (w *WriteSeeker) Bytes(t []byte) *WriteSeeker
func (*WriteSeeker) F32 ¶ added in v0.5.0
func (w *WriteSeeker) F32(t float32) *WriteSeeker
func (*WriteSeeker) F64 ¶ added in v0.5.0
func (w *WriteSeeker) F64(t float64) *WriteSeeker
func (*WriteSeeker) I16 ¶ added in v0.5.0
func (w *WriteSeeker) I16(t int16) *WriteSeeker
func (*WriteSeeker) I24 ¶ added in v0.5.0
func (w *WriteSeeker) I24(t int32) *WriteSeeker
func (*WriteSeeker) I32 ¶ added in v0.5.0
func (w *WriteSeeker) I32(t int32) *WriteSeeker
func (*WriteSeeker) I40 ¶ added in v0.5.0
func (w *WriteSeeker) I40(t int64) *WriteSeeker
func (*WriteSeeker) I48 ¶ added in v0.5.0
func (w *WriteSeeker) I48(t int64) *WriteSeeker
func (*WriteSeeker) I56 ¶ added in v0.5.0
func (w *WriteSeeker) I56(t int64) *WriteSeeker
func (*WriteSeeker) I64 ¶ added in v0.5.0
func (w *WriteSeeker) I64(t int64) *WriteSeeker
func (*WriteSeeker) I8 ¶ added in v0.3.1
func (w *WriteSeeker) I8(t int8) *WriteSeeker
func (*WriteSeeker) Seek ¶ added in v0.3.0
func (w *WriteSeeker) Seek(offset int64, whence int) *WriteSeeker
func (*WriteSeeker) String ¶ added in v0.3.4
func (w *WriteSeeker) String(t string) *WriteSeeker
func (*WriteSeeker) U16 ¶ added in v0.5.0
func (w *WriteSeeker) U16(t uint16) *WriteSeeker
func (*WriteSeeker) U24 ¶ added in v0.5.0
func (w *WriteSeeker) U24(t uint32) *WriteSeeker
func (*WriteSeeker) U32 ¶ added in v0.5.0
func (w *WriteSeeker) U32(t uint32) *WriteSeeker
func (*WriteSeeker) U40 ¶ added in v0.5.0
func (w *WriteSeeker) U40(t uint64) *WriteSeeker
func (*WriteSeeker) U48 ¶ added in v0.5.0
func (w *WriteSeeker) U48(t uint64) *WriteSeeker
func (*WriteSeeker) U56 ¶ added in v0.5.0
func (w *WriteSeeker) U56(t uint64) *WriteSeeker
func (*WriteSeeker) U64 ¶ added in v0.5.0
func (w *WriteSeeker) U64(t uint64) *WriteSeeker
func (*WriteSeeker) U8 ¶ added in v0.3.1
func (w *WriteSeeker) U8(t uint8) *WriteSeeker
func (*WriteSeeker) Write ¶ added in v0.5.0
func (w *WriteSeeker) Write(data any) *WriteSeeker