stream

package module
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 6 Imported by: 17

README

Go Report Card GoDoc

Stream

  • stream is a simple and fast binary stream reader and writer for golang.

Usage

  • This is ping example
package main

import (
	"bytes"
	"fmt"
	"net"
	"time"

	"github.com/zijiren233/stream"
)

type ICMP struct {
	Type        uint8
	Code        uint8
	Checksum    uint16
	Identifier  uint16
	SequenceNum uint16
	Data        []byte
}

type IPHeader struct {
	Version   uint8   // 4 bits
	HeaderLen uint8   // 4 bits
	TOS       uint8   // 8 bits
	TotalLen  uint16  // 16 bits
	ID        uint16  // 16 bits
	Flag      uint8   // 3 bits
	Offset    uint16  // 13 bits
	TTL       uint8   // 8 bits
	Protocol  uint8   // 8 bits
	Checksum  uint16  // 16 bits
	Src       [4]byte // 32 bits
	Dst       [4]byte // 32 bits
}

var (
	size = 0
)

func main() {
	c, err := net.DialTimeout("ip:icmp", "www.baidu.com", time.Second*3)
	if err != nil {
		panic(err)
	}
	defer c.Close()

	icmp := ICMP{
		Type:        8,
		Code:        0,
		Checksum:    0,
		Identifier:  1,
		SequenceNum: 1,
		Data:        make([]byte, size),
	}

	buf := bytes.NewBuffer(make([]byte, 0, 8+size))
	w := stream.NewWriter(buf, stream.BigEndian)
	if err := w.Write(&icmp).Error(); err != nil {
		panic(err)
	}
	stream.BigEndian.WriteU16(buf.Bytes()[2:4], checkSun(buf.Bytes()))
	_, err = c.Write(buf.Bytes())
	if err != nil {
		panic(err)
	}
	resp := make([]byte, 1024)
	n, err := c.Read(resp)
	if err != nil {
		panic(err)
	}
	ipHeader := IPHeader{}
	r := stream.NewReader(bytes.NewReader(resp[:n]), stream.BigEndian)
	if err := r.
		Bits(4, &ipHeader.Version).
		Bits(4, &ipHeader.HeaderLen).
		U8(&ipHeader.TOS).
		U16(&ipHeader.TotalLen).
		U16(&ipHeader.ID).
		Bits(3, &ipHeader.Flag).
		Bits(13, &ipHeader.Offset).
		U8(&ipHeader.TTL).
		U8(&ipHeader.Protocol).
		U16(&ipHeader.Checksum).
		Bytes(ipHeader.Src[:]).
		Bytes(ipHeader.Dst[:]).
		Error(); err != nil {
		panic(err)
	}

	fmt.Printf("ipHeader: %+v\n", ipHeader)
}

func checkSun(data []byte) uint16 {
	var (
		sum uint32
	)
	if len(data)%2 != 0 {
		data = data[:len(data)-1]
		sum += uint32(data[len(data)-1])
	}
	r := stream.NewReader(bytes.NewReader(data), stream.BigEndian)
	var v uint16
	for {
		if err := r.U16(&v).Error(); err != nil {
			break
		}
		sum += uint32(v)
	}

	for sum>>16 > 0 {
		sum = (sum >> 16) + (sum & 0xff00)
	}

	return uint16(^sum)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitToU8 added in v0.4.0

func BitToU8(b byte, start int8, end int8) uint8

BitToU8(0b1001_0110, 0, 3) == 0b0000_0100

func BitsCut added in v0.5.0

func BitsCut(data []byte, start, end int, o Order) ([]byte, error)

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

func BytesToString(b []byte) string

The change of bytes will cause the change of string synchronously

func CopyBits added in v0.5.0

func CopyBits(src, dst []byte, offset int) error

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

func StringToBytes(s string) []byte

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 NewBitReader(r io.Reader) *BitReader

func (*BitReader) Read added in v0.5.0

func (r *BitReader) Read(p []byte) (int, error)

Read reads len(p) bytes from the stream.

func (*BitReader) ReadBit added in v0.5.0

func (r *BitReader) ReadBit() (byte, error)

ReadBit reads a single bit from the stream.

func (*BitReader) ReadBits added in v0.5.0

func (r *BitReader) ReadBits(p []byte, start, end int) error

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.

func (*BitReader) ReadByte added in v0.5.0

func (r *BitReader) ReadByte() (byte, error)

ReadByte reads a single byte from the stream.

func (*BitReader) SkipBits added in v0.5.1

func (r *BitReader) SkipBits(n int64) (int64, error)

func (*BitReader) SkipBytes added in v0.5.1

func (r *BitReader) SkipBytes(n int64) (int64, error)

type BitWriter added in v0.5.2

type BitWriter struct {
	// contains filtered or unexported fields
}

func NewBitWriter added in v0.5.2

func NewBitWriter(w io.Writer) *BitWriter

func (*BitWriter) Write added in v0.5.2

func (w *BitWriter) Write(p []byte) (int, error)

func (*BitWriter) WriteBit added in v0.5.2

func (w *BitWriter) WriteBit(b byte) error

func (*BitWriter) WriteBits added in v0.5.2

func (w *BitWriter) WriteBits(b []byte, start, end int) error

func (*BitWriter) WriteByte added in v0.5.2

func (w *BitWriter) WriteByte(b byte) error

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

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)
}
var (
	BigEndian    Order = (*bigEndian)(nil)
	LittleEndian Order = (*littleEndian)(nil)
)

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 NewReader

func NewReader(r io.Reader, o Order) *Reader

func (*Reader) Bits added in v0.5.0

func (r *Reader) Bits(n int, s any) *Reader

func (*Reader) Bool added in v0.2.1

func (r *Reader) Bool(t *bool) *Reader

func (*Reader) Byte

func (r *Reader) Byte(t *byte) *Reader

func (*Reader) Bytes

func (r *Reader) Bytes(t []byte) *Reader

func (*Reader) Error

func (r *Reader) Error() error

func (*Reader) F32 added in v0.5.0

func (r *Reader) F32(t *float32) *Reader

func (*Reader) F64 added in v0.5.0

func (r *Reader) F64(t *float64) *Reader

func (*Reader) I16 added in v0.5.0

func (r *Reader) I16(t *int16) *Reader

func (*Reader) I24 added in v0.5.0

func (r *Reader) I24(t *int32) *Reader

func (*Reader) I32 added in v0.5.0

func (r *Reader) I32(t *int32) *Reader

func (*Reader) I40 added in v0.5.0

func (r *Reader) I40(t *int64) *Reader

func (*Reader) I48 added in v0.5.0

func (r *Reader) I48(t *int64) *Reader

func (*Reader) I56 added in v0.5.0

func (r *Reader) I56(t *int64) *Reader

func (*Reader) I64 added in v0.5.0

func (r *Reader) I64(t *int64) *Reader

func (*Reader) I8

func (r *Reader) I8(t *int8) *Reader

func (*Reader) N

func (r *Reader) N() int

N returns the number of bytes read at last read. Instead of the total.

func (*Reader) Read added in v0.5.0

func (r *Reader) Read(data any) *Reader

func (*Reader) ReadBool added in v0.3.3

func (r *Reader) ReadBool() (t bool, err error)

func (*Reader) ReadByte added in v0.3.3

func (r *Reader) ReadByte() (t byte, err error)

func (*Reader) ReadBytes added in v0.3.4

func (r *Reader) ReadBytes(n int) (t []byte, err error)

func (*Reader) ReadF32 added in v0.5.0

func (r *Reader) ReadF32() (t float32, err error)

func (*Reader) ReadF64 added in v0.5.0

func (r *Reader) ReadF64() (t float64, err error)

func (*Reader) ReadI16 added in v0.5.0

func (r *Reader) ReadI16() (t int16, err error)

func (*Reader) ReadI24 added in v0.5.0

func (r *Reader) ReadI24() (t int32, err error)

func (*Reader) ReadI32 added in v0.5.0

func (r *Reader) ReadI32() (t int32, err error)

func (*Reader) ReadI40 added in v0.5.0

func (r *Reader) ReadI40() (t int64, err error)

func (*Reader) ReadI48 added in v0.5.0

func (r *Reader) ReadI48() (t int64, err error)

func (*Reader) ReadI56 added in v0.5.0

func (r *Reader) ReadI56() (t int64, err error)

func (*Reader) ReadI64 added in v0.5.0

func (r *Reader) ReadI64() (t int64, err error)

func (*Reader) ReadI8 added in v0.3.2

func (r *Reader) ReadI8() (t int8, err error)

func (*Reader) ReadString added in v0.3.4

func (r *Reader) ReadString(n int) (t string, err error)

func (*Reader) ReadU16 added in v0.5.0

func (r *Reader) ReadU16() (t uint16, err error)

func (*Reader) ReadU24 added in v0.5.0

func (r *Reader) ReadU24() (t uint32, err error)

func (*Reader) ReadU32 added in v0.5.0

func (r *Reader) ReadU32() (t uint32, err error)

func (*Reader) ReadU40 added in v0.5.0

func (r *Reader) ReadU40() (t uint64, err error)

func (*Reader) ReadU48 added in v0.5.0

func (r *Reader) ReadU48() (t uint64, err error)

func (*Reader) ReadU56 added in v0.5.0

func (r *Reader) ReadU56() (t uint64, err error)

func (*Reader) ReadU64 added in v0.5.0

func (r *Reader) ReadU64() (t uint64, err error)

func (*Reader) ReadU8 added in v0.3.2

func (r *Reader) ReadU8() (t uint8, err error)

func (*Reader) Reset

func (r *Reader) Reset()

func (*Reader) SkipBits added in v0.5.1

func (r *Reader) SkipBits(n int64) *Reader

r.N() and r.Total() dont work with r.SkipBits() and r.SkipBytes()

func (*Reader) SkipBytes added in v0.4.0

func (r *Reader) SkipBytes(n int64) *Reader

r.N() and r.Total() dont work with r.SkipBits() and r.SkipBytes()

func (*Reader) String added in v0.3.4

func (r *Reader) String(t *string, n int) *Reader

func (*Reader) Total added in v0.2.0

func (r *Reader) Total() int

func (*Reader) U16 added in v0.5.0

func (r *Reader) U16(t *uint16) *Reader

func (*Reader) U24 added in v0.5.0

func (r *Reader) U24(t *uint32) *Reader

func (*Reader) U32 added in v0.5.0

func (r *Reader) U32(t *uint32) *Reader

func (*Reader) U40 added in v0.5.0

func (r *Reader) U40(t *uint64) *Reader

func (*Reader) U48 added in v0.5.0

func (r *Reader) U48(t *uint64) *Reader

func (*Reader) U56 added in v0.5.0

func (r *Reader) U56(t *uint64) *Reader

func (*Reader) U64 added in v0.5.0

func (r *Reader) U64(t *uint64) *Reader

func (*Reader) U8

func (r *Reader) U8(t *uint8) *Reader

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

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.Writer, o Order) *Writer

func (*Writer) Bool added in v0.2.1

func (w *Writer) Bool(s bool) *Writer

func (*Writer) Byte

func (w *Writer) Byte(s byte) *Writer

func (*Writer) Bytes

func (w *Writer) Bytes(s []byte) *Writer

func (*Writer) Error

func (w *Writer) Error() error

func (*Writer) F32 added in v0.5.0

func (w *Writer) F32(s float32) *Writer

func (*Writer) F64 added in v0.5.0

func (w *Writer) F64(s float64) *Writer

func (*Writer) I16 added in v0.5.0

func (w *Writer) I16(s int16) *Writer

func (*Writer) I24 added in v0.5.0

func (w *Writer) I24(s int32) *Writer

func (*Writer) I32 added in v0.5.0

func (w *Writer) I32(s int32) *Writer

func (*Writer) I40 added in v0.5.0

func (w *Writer) I40(s int64) *Writer

func (*Writer) I48 added in v0.5.0

func (w *Writer) I48(s int64) *Writer

func (*Writer) I56 added in v0.5.0

func (w *Writer) I56(s int64) *Writer

func (*Writer) I64 added in v0.5.0

func (w *Writer) I64(s int64) *Writer

func (*Writer) I8

func (w *Writer) I8(s int8) *Writer

func (*Writer) N

func (w *Writer) N() int

N returns the number of bytes write at last write. Instead of the total.

func (*Writer) ReadFrom added in v0.5.2

func (w *Writer) ReadFrom(r io.Reader) *Writer

func (*Writer) Reset

func (w *Writer) Reset() *Writer

func (*Writer) String added in v0.3.4

func (w *Writer) String(s string) *Writer

func (*Writer) Total added in v0.2.0

func (w *Writer) Total() int

func (*Writer) U16 added in v0.5.0

func (w *Writer) U16(s uint16) *Writer

func (*Writer) U24 added in v0.5.0

func (w *Writer) U24(s uint32) *Writer

func (*Writer) U32 added in v0.5.0

func (w *Writer) U32(s uint32) *Writer

func (*Writer) U40 added in v0.5.0

func (w *Writer) U40(s uint64) *Writer

func (*Writer) U48 added in v0.5.0

func (w *Writer) U48(s uint64) *Writer

func (*Writer) U56 added in v0.5.0

func (w *Writer) U56(s uint64) *Writer

func (*Writer) U64 added in v0.5.0

func (w *Writer) U64(s uint64) *Writer

func (*Writer) U8

func (w *Writer) U8(s uint8) *Writer

func (*Writer) Write added in v0.5.0

func (w *Writer) Write(data any) *Writer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL