Documentation ¶
Index ¶
- func GZipCompress(data []byte) []byte
- func GZipUncompress(src []byte) []byte
- func NewWriterF(f func(writer *Builder)) []byte
- func OpenWriterF(f func(builder *Builder)) (b []byte, cl func())
- func PutBuilder(w *Builder)
- func ReleaseGzipWriter(w *GzipWriter)
- func ToBytes(i any) []byte
- func UInt32ToIPV4Address(i uint32) string
- func ZlibCompress(data []byte) []byte
- func ZlibUncompress(src []byte) []byte
- type Builder
- func (b *Builder) Buffer() *bytes.Buffer
- func (b *Builder) EncryptAndWrite(key []byte, data []byte) *Builder
- func (b *Builder) Len() int
- func (b *Builder) Pack(typ uint16) []byte
- func (b *Builder) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Builder) ToBytes() []byte
- func (b *Builder) ToReader() io.Reader
- func (b *Builder) Write(p []byte) (n int, err error)
- func (b *Builder) WriteBool(v bool) *Builder
- func (b *Builder) WriteBytes(v []byte) *Builder
- func (b *Builder) WriteDouble(v float64) *Builder
- func (b *Builder) WriteFloat(v float32) *Builder
- func (b *Builder) WriteI16(v int16) *Builder
- func (b *Builder) WriteI32(v int32) *Builder
- func (b *Builder) WriteI64(v int64) *Builder
- func (b *Builder) WriteI8(v int8) *Builder
- func (b *Builder) WriteLenBytes(v []byte) *Builder
- func (b *Builder) WriteLenString(v string) *Builder
- func (b *Builder) WritePacketBytes(v []byte, prefix string, withPrefix bool) *Builder
- func (b *Builder) WritePacketString(s, prefix string, withPrefix bool) *Builder
- func (b *Builder) WriteStruct(data ...any) *Builder
- func (b *Builder) WriteTLV(tlvs ...[]byte) *Builder
- func (b *Builder) WriteU16(v uint16) *Builder
- func (b *Builder) WriteU32(v uint32) *Builder
- func (b *Builder) WriteU64(v uint64) *Builder
- func (b *Builder) WriteU8(v uint8) *Builder
- type GzipWriter
- type NetworkReader
- type Reader
- func (r *Reader) Len() int
- func (r *Reader) ReadAll() []byte
- func (r *Reader) ReadBytes(length int) (v []byte)
- func (r *Reader) ReadBytesNoCopy(length int) (v []byte)
- func (r *Reader) ReadBytesWithLength(prefix string, withPerfix bool) []byte
- func (r *Reader) ReadI16() (v int16)
- func (r *Reader) ReadI32() (v int32)
- func (r *Reader) ReadI64() (v int64)
- func (r *Reader) ReadI8() (v int8)
- func (r *Reader) ReadString(length int) string
- func (r *Reader) ReadStringWithLength(prefix string, withPerfix bool) string
- func (r *Reader) ReadTlv() (result map[uint16][]byte)
- func (r *Reader) ReadU16() (v uint16)
- func (r *Reader) ReadU32() (v uint32)
- func (r *Reader) ReadU64() (v uint64)
- func (r *Reader) ReadU8() (v uint8)
- func (r *Reader) SkipBytes(length int)
- func (r *Reader) SkipBytesWithLength(prefix string, withPerfix bool)
- func (r *Reader) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GZipCompress ¶
func GZipUncompress ¶
func NewWriterF ¶
NewWriterF from https://github.com/Mrs4s/MiraiGo/blob/master/binary/writer.go
func OpenWriterF ¶
OpenWriterF must call func cl to close from https://github.com/Mrs4s/MiraiGo/blob/master/binary/writer.go
func ReleaseGzipWriter ¶
func ReleaseGzipWriter(w *GzipWriter)
func ToBytes ¶
ToBytes from https://github.com/Mrs4s/MiraiGo/blob/master/binary/writer.go
func UInt32ToIPV4Address ¶
func ZlibCompress ¶
func ZlibUncompress ¶
Types ¶
type Builder ¶
type Builder struct { io.Writer io.ReaderFrom // contains filtered or unexported fields }
func NewBuilder ¶
NewBuilder with finalizer of itself.
Be sure to use all data before builder is GCed.
func (*Builder) EncryptAndWrite ¶
func (*Builder) Pack ¶
Pack TLV with tea encryption if key is set
GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取, 但是只能调用一次, 调用后 Builder 即失效
func (*Builder) ToBytes ¶
ToBytes return data with tea encryption if key is set
GC 安全, 返回的数据在 Builder 被销毁之后仍能被正确读取, 但是只能调用一次, 调用后 Builder 即失效
func (*Builder) WriteBytes ¶
func (*Builder) WriteDouble ¶
func (*Builder) WriteFloat ¶
func (*Builder) WriteLenBytes ¶
func (*Builder) WriteLenString ¶
func (*Builder) WritePacketBytes ¶
WritePacketBytes prefix must not be empty
func (*Builder) WritePacketString ¶
func (*Builder) WriteStruct ¶
type GzipWriter ¶
type GzipWriter struct {
// contains filtered or unexported fields
}
func AcquireGzipWriter ¶
func AcquireGzipWriter() *GzipWriter
func (*GzipWriter) Bytes ¶
func (w *GzipWriter) Bytes() []byte
func (*GzipWriter) Close ¶
func (w *GzipWriter) Close() error
type NetworkReader ¶
type NetworkReader struct {
// contains filtered or unexported fields
}
func NewNetworkReader ¶
func NewNetworkReader(conn net.Conn) *NetworkReader
func (*NetworkReader) ReadByte ¶
func (r *NetworkReader) ReadByte() (byte, error)
func (*NetworkReader) ReadInt32 ¶
func (r *NetworkReader) ReadInt32() (int32, error)
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func ParseReader ¶
func (*Reader) ReadAll ¶
ReadAll means read all available data and return them
if r.reader got error, it will return nil