Documentation ¶
Index ¶
- type InputStream
- func (r *InputStream) Offset() int64
- func (r *InputStream) Read(p []byte) (n int, err error)
- func (r *InputStream) ReadBinary(v encoding.BinaryUnmarshaler) error
- func (r *InputStream) ReadBool() (bool, error)
- func (r *InputStream) ReadBytes() (out []byte, err error)
- func (r *InputStream) ReadFloat32() (out float32, err error)
- func (r *InputStream) ReadFloat64() (out float64, err error)
- func (r *InputStream) ReadInt() (int, error)
- func (r *InputStream) ReadInt16() (int16, error)
- func (r *InputStream) ReadInt32() (int32, error)
- func (r *InputStream) ReadInt64() (int64, error)
- func (r *InputStream) ReadInt8() (int8, error)
- func (r *InputStream) ReadRange(fn func(i int, r *InputStream) error) error
- func (r *InputStream) ReadSelf(v io.ReaderFrom) error
- func (r *InputStream) ReadString() (out string, err error)
- func (r *InputStream) ReadText(v encoding.TextUnmarshaler) error
- func (r *InputStream) ReadUint() (uint, error)
- func (r *InputStream) ReadUint16() (out uint16, err error)
- func (r *InputStream) ReadUint32() (out uint32, err error)
- func (r *InputStream) ReadUint64() (out uint64, err error)
- func (r *InputStream) ReadUint8() (uint8, error)
- func (r *InputStream) ReadUvarint() (uint64, error)
- func (r *InputStream) ReadVarint() (int64, error)
- func (r *InputStream) Seek(offset int64, whence int) (int64, error)
- type OutputStream
- func (w *OutputStream) Close() error
- func (w *OutputStream) Flush() error
- func (w *OutputStream) Offset() int64
- func (w *OutputStream) Reset(out io.Writer)
- func (w *OutputStream) Write(p []byte) (int, error)
- func (w *OutputStream) WriteBinary(v encoding.BinaryMarshaler) error
- func (w *OutputStream) WriteBool(v bool) error
- func (w *OutputStream) WriteBytes(v []byte) error
- func (w *OutputStream) WriteFloat32(v float32) error
- func (w *OutputStream) WriteFloat64(v float64) error
- func (w *OutputStream) WriteInt(v int) error
- func (w *OutputStream) WriteInt16(v int16) error
- func (w *OutputStream) WriteInt32(v int32) error
- func (w *OutputStream) WriteInt64(v int64) error
- func (w *OutputStream) WriteInt8(v int8) error
- func (w *OutputStream) WriteRange(length int, fn func(i int, w *OutputStream) error) error
- func (w *OutputStream) WriteSelf(v io.WriterTo) error
- func (w *OutputStream) WriteString(v string) error
- func (w *OutputStream) WriteText(v encoding.TextMarshaler) error
- func (w *OutputStream) WriteUint(v uint) error
- func (w *OutputStream) WriteUint16(v uint16) error
- func (w *OutputStream) WriteUint32(v uint32) error
- func (w *OutputStream) WriteUint64(v uint64) error
- func (w *OutputStream) WriteUint8(v uint8) error
- func (w *OutputStream) WriteUvarint(x uint64) error
- func (w *OutputStream) WriteVarint(v int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InputStream ¶
type InputStream struct {
// contains filtered or unexported fields
}
InputStream 流的读取器
func NewInputStream ¶
func NewInputStream(src io.Reader) *InputStream
NewInputStream creates a input stream.
func (*InputStream) Offset ¶
func (r *InputStream) Offset() int64
Offset returns the number of bytes read through this reader.
func (*InputStream) Read ¶
func (r *InputStream) Read(p []byte) (n int, err error)
Read implements io.Reader interface
func (*InputStream) ReadBinary ¶
func (r *InputStream) ReadBinary(v encoding.BinaryUnmarshaler) error
ReadBinary 从流中读取bytes,并按实现encoding.BinaryUnmarshaler接口的函数的方式 进行unmarshaler
func (*InputStream) ReadBytes ¶
func (r *InputStream) ReadBytes() (out []byte, err error)
ReadBytes 读取可变长度的byte string
func (*InputStream) ReadFloat32 ¶
func (r *InputStream) ReadFloat32() (out float32, err error)
ReadFloat32 reads a float32
func (*InputStream) ReadFloat64 ¶
func (r *InputStream) ReadFloat64() (out float64, err error)
ReadFloat64 reads a float64
func (*InputStream) ReadInt16 ¶
func (r *InputStream) ReadInt16() (int16, error)
ReadInt16 reads an int16
func (*InputStream) ReadInt32 ¶
func (r *InputStream) ReadInt32() (int32, error)
ReadInt32 reads an int32
func (*InputStream) ReadInt64 ¶
func (r *InputStream) ReadInt64() (int64, error)
ReadInt64 reads an int64
func (*InputStream) ReadInt8 ¶
func (r *InputStream) ReadInt8() (int8, error)
ReadInt8 reads an int8
func (*InputStream) ReadRange ¶
func (r *InputStream) ReadRange(fn func(i int, r *InputStream) error) error
ReadRange 通过回调函数从stream里读取指定长度的数组
func (*InputStream) ReadSelf ¶
func (r *InputStream) ReadSelf(v io.ReaderFrom) error
ReadSelf 通过io.ReaderFrom由reader本身读取
func (*InputStream) ReadString ¶
func (r *InputStream) ReadString() (out string, err error)
ReadString 通过可变长度的读取string
func (*InputStream) ReadText ¶
func (r *InputStream) ReadText(v encoding.TextUnmarshaler) error
ReadText 同上,只是unmarshaler方法换成实现encoding.TextUnmarshaler接口的
func (*InputStream) ReadUint ¶
func (r *InputStream) ReadUint() (uint, error)
ReadUint 由于现代计算机都是64位的,这里假设int即是int64
func (*InputStream) ReadUint16 ¶
func (r *InputStream) ReadUint16() (out uint16, err error)
ReadUint16 reads an uint16
func (*InputStream) ReadUint32 ¶
func (r *InputStream) ReadUint32() (out uint32, err error)
ReadUint32 reads an uint32
func (*InputStream) ReadUint64 ¶
func (r *InputStream) ReadUint64() (out uint64, err error)
ReadUint64 reads an uint64
func (*InputStream) ReadUint8 ¶
func (r *InputStream) ReadUint8() (uint8, error)
ReadUint8 reads an uint8
func (*InputStream) ReadUvarint ¶
func (r *InputStream) ReadUvarint() (uint64, error)
ReadUvarint reads a variable-length Uint64 from the buffer.
func (*InputStream) ReadVarint ¶
func (r *InputStream) ReadVarint() (int64, error)
type OutputStream ¶
type OutputStream struct {
// contains filtered or unexported fields
}
OutputStream 流的写入器
func NewOutputStream ¶
func NewOutputStream(out io.Writer) *OutputStream
NewOutputStream creates a output stream .
func (*OutputStream) Close ¶
func (w *OutputStream) Close() error
Close closes the writer's underlying stream and return its error. If the underlying io.Writer is not an io.Closer, it's a no-op.
func (*OutputStream) Flush ¶
func (w *OutputStream) Flush() error
Flush flushes the writer to the underlying stream and returns its error. If the underlying io.Writer does not have a Flush() error method, it's a no-op.
func (*OutputStream) Offset ¶
func (w *OutputStream) Offset() int64
Offset returns the number of bytes written through this writer.
func (*OutputStream) Reset ¶
func (w *OutputStream) Reset(out io.Writer)
Reset resets the writer and makes it ready to be reused.
func (*OutputStream) Write ¶
func (w *OutputStream) Write(p []byte) (int, error)
Write implements io.Writer interface
func (*OutputStream) WriteBinary ¶
func (w *OutputStream) WriteBinary(v encoding.BinaryMarshaler) error
WriteBinary marshals the type to its binary representation and writes it downstream, prefixed with its size as a variable-size integer.
func (*OutputStream) WriteBool ¶
func (w *OutputStream) WriteBool(v bool) error
WriteBool writes a single boolean value into the buffer
func (*OutputStream) WriteBytes ¶
func (w *OutputStream) WriteBytes(v []byte) error
WriteBytes writes a byte slice prefixed with a variable-size integer.
func (*OutputStream) WriteFloat32 ¶
func (w *OutputStream) WriteFloat32(v float32) error
WriteFloat32 a 32-bit floating point number
func (*OutputStream) WriteFloat64 ¶
func (w *OutputStream) WriteFloat64(v float64) error
WriteFloat64 a 64-bit floating point number
func (*OutputStream) WriteInt16 ¶
func (w *OutputStream) WriteInt16(v int16) error
WriteInt16 writes an int16
func (*OutputStream) WriteInt32 ¶
func (w *OutputStream) WriteInt32(v int32) error
WriteInt32 writes an int32
func (*OutputStream) WriteInt64 ¶
func (w *OutputStream) WriteInt64(v int64) error
WriteInt64 writes an int64
func (*OutputStream) WriteInt8 ¶
func (w *OutputStream) WriteInt8(v int8) error
WriteInt8 writes an int8
func (*OutputStream) WriteRange ¶
func (w *OutputStream) WriteRange(length int, fn func(i int, w *OutputStream) error) error
WriteRange writes a specified length of an array and for each element of that array calls the callback function with its index.
func (*OutputStream) WriteSelf ¶
func (w *OutputStream) WriteSelf(v io.WriterTo) error
WriteSelf uses the provider io.WriterTo in order to write the data into the destination writer.
func (*OutputStream) WriteString ¶
func (w *OutputStream) WriteString(v string) error
WriteString writes a string prefixed with a variable-size integer.
func (*OutputStream) WriteText ¶
func (w *OutputStream) WriteText(v encoding.TextMarshaler) error
WriteText marshals the type to its text representation and writes it downstream, prefixed with its size as a variable-size integer.
func (*OutputStream) WriteUint ¶
func (w *OutputStream) WriteUint(v uint) error
WriteUint writes a Uint
func (*OutputStream) WriteUint16 ¶
func (w *OutputStream) WriteUint16(v uint16) error
WriteUint16 writes a Uint16
func (*OutputStream) WriteUint32 ¶
func (w *OutputStream) WriteUint32(v uint32) error
WriteUint32 writes a Uint32
func (*OutputStream) WriteUint64 ¶
func (w *OutputStream) WriteUint64(v uint64) error
WriteUint64 writes a Uint64
func (*OutputStream) WriteUint8 ¶
func (w *OutputStream) WriteUint8(v uint8) error
WriteUint8 writes a Uint8
func (*OutputStream) WriteUvarint ¶
func (w *OutputStream) WriteUvarint(x uint64) error
WriteUvarint writes a variable size unsigned integer
func (*OutputStream) WriteVarint ¶
func (w *OutputStream) WriteVarint(v int64) error
WriteVarint writes a variable size signed integer