github.com/go-board/x-go@v0.1.2-0.20220610024734-db1323f6cb15/xcodec/stream.go (about)

     1  package xcodec
     2  
     3  import (
     4  	"encoding/binary"
     5  	"io"
     6  )
     7  
     8  type StreamCodec interface {
     9  	Encode(w io.Writer, v interface{}) error
    10  	Decode(r io.Reader, v interface{}) error
    11  	Name() string
    12  }
    13  
    14  type StreamWrite interface {
    15  	Write(p []byte) error
    16  }
    17  
    18  type StreamWriteExt interface {
    19  	StreamWrite
    20  	ByteOrder() binary.ByteOrder
    21  	Codec() Codec
    22  	WriteInt8(i int8) error
    23  	WriteInt16(i int16) error
    24  	WriteInt32(i int32) error
    25  	WriteInt64(i int64) error
    26  
    27  	WriteUint8(i uint8) error
    28  	WriteUint16(i uint16) error
    29  	WriteUint32(i uint32) error
    30  	WriteUint64(i uint64) error
    31  
    32  	WriteFloat32(f float32) error
    33  	WriteFloat64(f float64) error
    34  
    35  	WriteString(str string) error
    36  
    37  	WriteBool(b bool) error
    38  
    39  	WriteAny(v interface{}) error
    40  }
    41  
    42  type StreamRead interface {
    43  	Read(p []byte) error
    44  }
    45  
    46  type StreamReadExt interface {
    47  	StreamRead
    48  	ByteOrder() binary.ByteOrder
    49  	Codec() Codec
    50  	ReadInt8(i *int8) error
    51  	ReadInt16(i *int16) error
    52  	ReadInt32(i *int32) error
    53  	ReadInt64(i *int64) error
    54  
    55  	ReadUint8(i *uint8) error
    56  	ReadUint16(i *uint16) error
    57  	ReadUint32(i *uint32) error
    58  	ReadUint64(i *uint64) error
    59  
    60  	ReadFloat32(f *float32) error
    61  	ReadFloat64(f *float64) error
    62  
    63  	ReadString(str *string) error
    64  
    65  	ReadBool(b *bool) error
    66  
    67  	ReadAny(v interface{}) error
    68  }