Documentation ¶
Index ¶
- Constants
- Variables
- func Byte2Int(data []byte) int
- func Byte2Int64(data []byte) int64
- func Byte2UInt16(data []byte) uint16
- func Byte2UInt32(data []byte) uint32
- func Byte2UInt64(data []byte) uint64
- func Int2Bytes(v int) []byte
- func Int2BytesTo(v int, ret []byte)
- func Int64ToBytes(v int64) []byte
- func Int64ToBytesTo(v int64, ret []byte)
- func ReadInt(r io.Reader) (int, error)
- func ReadN(r io.Reader, n int) ([]byte, error)
- func UInt16ToBytes(v uint16) []byte
- func UInt32ToBytes(v uint32) []byte
- func Uint16ToBytesTo(v uint16, ret []byte)
- func Uint32ToBytesTo(v uint32, ret []byte)
- func Uint64ToBytesTo(v uint64, ret []byte)
- func UseMemPool(min, max int)
- type ByteBuf
- func (b *ByteBuf) Capacity() int
- func (b *ByteBuf) Clear()
- func (b *ByteBuf) Expansion(n int)
- func (b *ByteBuf) GetMarkedRemind() int
- func (b *ByteBuf) GetMarkedRemindData() []byte
- func (b *ByteBuf) GetMarkerIndex() int
- func (b *ByteBuf) GetReaderIndex() int
- func (b *ByteBuf) GetWriteIndex() int
- func (b *ByteBuf) MarkIndex(index int) error
- func (b *ByteBuf) MarkN(n int) error
- func (b *ByteBuf) MarkWrite()
- func (b *ByteBuf) MarkedBytesReaded()
- func (b *ByteBuf) PeekByte(offset int) (byte, error)
- func (b *ByteBuf) PeekInt(offset int) (int, error)
- func (b *ByteBuf) PeekN(offset int, n int) ([]byte, error)
- func (b *ByteBuf) RawBuf() []byte
- func (b *ByteBuf) Read(p []byte) (n int, err error)
- func (b *ByteBuf) ReadAll() (int, []byte, error)
- func (b *ByteBuf) ReadByte() (byte, error)
- func (b *ByteBuf) ReadBytes(n int) (int, []byte, error)
- func (b *ByteBuf) ReadFrom(r io.Reader) (n int64, err error)
- func (b *ByteBuf) ReadInt() (int, error)
- func (b *ByteBuf) ReadInt64() (int64, error)
- func (b *ByteBuf) ReadMarkedBytes() (int, []byte, error)
- func (b *ByteBuf) ReadRawBytes(n int) (int, []byte, error)
- func (b *ByteBuf) ReadUInt16() (uint16, error)
- func (b *ByteBuf) ReadUInt32() (uint32, error)
- func (b *ByteBuf) ReadUInt64() (uint64, error)
- func (b *ByteBuf) Readable() int
- func (b *ByteBuf) Release()
- func (b *ByteBuf) Resume(capacity int)
- func (b *ByteBuf) SetReaderIndex(newReaderIndex int) error
- func (b *ByteBuf) SetWriterIndex(newWriterIndex int) error
- func (b *ByteBuf) Skip(n int) error
- func (b *ByteBuf) Slice(from, to int) Slice
- func (b *ByteBuf) Wrap(data []byte)
- func (b *ByteBuf) Write(p []byte) (int, error)
- func (b *ByteBuf) WriteByte(v byte) error
- func (b *ByteBuf) WriteByteBuf(from *ByteBuf) error
- func (b *ByteBuf) WriteInt(v int) (n int, err error)
- func (b *ByteBuf) WriteInt64(v int64) (n int, err error)
- func (b *ByteBuf) WriteString(v string) error
- func (b *ByteBuf) WriteUInt16(v uint16) (n int, err error)
- func (b *ByteBuf) WriteUInt32(v uint32) (n int, err error)
- func (b *ByteBuf) WriteUInt64(v uint64) (n int, err error)
- func (b *ByteBuf) WriteUint64(v uint64) (n int, err error)
- func (b *ByteBuf) Writeable() int
- func (b *ByteBuf) WrittenDataAfterMark() Slice
- type Pool
- type Slice
- type SyncPool
Constants ¶
const ( // KB kb KB = 1024 // MB mb MB = 1024 * 1024 )
Variables ¶
var ErrTooLarge = errors.New("goetty.ByteBuf: too large")
ErrTooLarge too larger error
Functions ¶
func Byte2Int64 ¶
Byte2Int64 byte array to int64 value using big order
func Byte2UInt16 ¶
Byte2UInt16 byte array to uint16 value using big order
func Byte2UInt32 ¶
Byte2UInt32 byte array to uint32 value using big order
func Byte2UInt64 ¶
Byte2UInt64 byte array to int64 value using big order
func Int2BytesTo ¶
Int2BytesTo int value to bytes array using big order
func Int64ToBytes ¶
Int64ToBytes int64 value to bytes array using big order
func Int64ToBytesTo ¶
Int64ToBytesTo int64 value to bytes array using big order
func UInt16ToBytes ¶
UInt16ToBytes uint16 value to bytes array using big order
func UInt32ToBytes ¶
UInt32ToBytes uint32 value to bytes array using big order
func Uint16ToBytesTo ¶
Uint16ToBytesTo uint16 value to bytes array using big order
func Uint32ToBytesTo ¶
Uint32ToBytesTo uint32 value to bytes array using big order
func Uint64ToBytesTo ¶
Uint64ToBytesTo uint64 value to bytes array using big order
Types ¶
type ByteBuf ¶
type ByteBuf struct {
// contains filtered or unexported fields
}
ByteBuf a buf with byte arrays
| discardable bytes | readable bytes | writeable bytes | | | | | | | | | 0 <= readerIndex <= writerIndex <= capacity
func NewByteBufPool ¶
NewByteBufPool create a new bytebuf using a mem pool
func (*ByteBuf) GetMarkedRemind ¶
GetMarkedRemind returns size in [readerIndex, markedIndex)
func (*ByteBuf) GetMarkedRemindData ¶
GetMarkedRemindData returns data in [readerIndex, markedIndex)
func (*ByteBuf) GetMarkerIndex ¶
GetMarkerIndex returns markerIndex
func (*ByteBuf) GetReaderIndex ¶
GetReaderIndex get the read index
func (*ByteBuf) GetWriteIndex ¶
GetWriteIndex get the write index
func (*ByteBuf) MarkedBytesReaded ¶
func (b *ByteBuf) MarkedBytesReaded()
MarkedBytesReaded reset reader index
func (*ByteBuf) PeekByte ¶
PeekByte get byte value from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) PeekInt ¶
PeekInt get int value from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) PeekN ¶
PeekN get bytes from buf based on currently read index, after read, read index not modifed
func (*ByteBuf) ReadAll ¶
ReadAll read all data from buf It's will copy the data to a new byte arrary return readedBytesCount, byte array, error
func (*ByteBuf) ReadBytes ¶
ReadBytes read bytes from buf It's will copy the data to a new byte arrary return readedBytesCount, byte array, error
func (*ByteBuf) ReadFrom ¶
ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with ErrTooLarge.
func (*ByteBuf) ReadMarkedBytes ¶
ReadMarkedBytes read data from buf in the range [readerIndex, markedIndex)
func (*ByteBuf) ReadRawBytes ¶
ReadRawBytes read bytes from buf without mem copy Note. If used complete, you must call b.Skip(n) to reset reader index
func (*ByteBuf) ReadUInt16 ¶
ReadUInt16 get uint16 value from buf
func (*ByteBuf) ReadUInt32 ¶
ReadUInt32 get uint32 value from buf
func (*ByteBuf) ReadUInt64 ¶
ReadUInt64 get uint64 value from buf
func (*ByteBuf) SetReaderIndex ¶
SetReaderIndex set the read index
func (*ByteBuf) SetWriterIndex ¶
SetWriterIndex set the write index
func (*ByteBuf) Write ¶
Write appends the contents of p to the buffer, growing the buffer as needed.
func (*ByteBuf) WriteByteBuf ¶
WriteByteBuf write all readable data to this buf
func (*ByteBuf) WriteInt ¶
WriteInt write int value to buf using big order return write bytes count, error
func (*ByteBuf) WriteInt64 ¶
WriteInt64 write int64 value to buf using big order return write bytes count, error
func (*ByteBuf) WriteString ¶
WriteString write a string value to buf
func (*ByteBuf) WriteUInt16 ¶
WriteUInt16 write uint16 value to buf using big order return write bytes count, error
func (*ByteBuf) WriteUInt32 ¶
WriteUInt32 write uint32 value to buf using big order return write bytes count, error
func (*ByteBuf) WriteUInt64 ¶
WriteUInt64 write uint64 value to buf using big order return write bytes count, error
func (*ByteBuf) WriteUint64 ¶
WriteUint64 write uint64 value to buf using big order return write bytes count, error
func (*ByteBuf) WrittenDataAfterMark ¶
WrittenDataAfterMark returns the data referance after mark write
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice the slice of byte buf
type SyncPool ¶
type SyncPool struct {
// contains filtered or unexported fields
}
SyncPool is a sync.Pool base slab allocation memory pool
func NewSyncPool ¶
NewSyncPool create a sync.Pool base slab allocation memory pool. minSize is the smallest chunk size. maxSize is the lagest chunk size. factor is used to control growth of chunk size.