Package bytewriter
Overview ▹
Index ▹
type ByteWriter ¶
ByteWriter is a simple wrapper over a byte slice that supports writing anywhere
type ByteWriter struct {
// contains filtered or unexported fields
}
func NewByteWriter ¶
func NewByteWriter(n int) *ByteWriter
NewByteWriter creates a new ByteWriter of the specified size
func NewByteWriterSlice ¶
func NewByteWriterSlice(buffer []byte) *ByteWriter
NewByteWriterSlice creates a new ByteWriter using the passed slice
func (*ByteWriter) Bytes ¶
func (w *ByteWriter) Bytes() []byte
Bytes returns the internal byte array of the ByteWriter
func (*ByteWriter) Len ¶
func (w *ByteWriter) Len() int
Len returns the maximum size of the ByteWriter
func (*ByteWriter) MustWrite ¶
func (w *ByteWriter) MustWrite(data []byte, offset int) int
MustWrite is a write that will panic if Write returns an error
func (*ByteWriter) MustWriteFloat32 ¶
func (w *ByteWriter) MustWriteFloat32(val float32, offset int) int
MustWriteFloat32 panics if WriteFloat32 fails
func (*ByteWriter) MustWriteFloat64 ¶
func (w *ByteWriter) MustWriteFloat64(val float64, offset int) int
MustWriteFloat64 panics if WriteFloat64 fails
func (*ByteWriter) MustWriteInt32 ¶
func (w *ByteWriter) MustWriteInt32(val int32, offset int) int
MustWriteInt32 panics if WriteInt32 fails
func (*ByteWriter) MustWriteInt64 ¶
func (w *ByteWriter) MustWriteInt64(val int64, offset int) int
MustWriteInt64 panics if WriteInt64 fails
func (*ByteWriter) MustWriteString ¶
func (w *ByteWriter) MustWriteString(val string, offset int) int
MustWriteString panics if WriteString fails
func (*ByteWriter) MustWriteUint32 ¶
func (w *ByteWriter) MustWriteUint32(val uint32, offset int) int
MustWriteUint32 panics if WriteInt32 fails
func (*ByteWriter) MustWriteUint64 ¶
func (w *ByteWriter) MustWriteUint64(val uint64, offset int) int
MustWriteUint64 panics if WriteUint64 fails
func (*ByteWriter) MustWriteVal ¶
func (w *ByteWriter) MustWriteVal(val interface{}, offset int) int
MustWriteVal panics if WriteVal fails
func (*ByteWriter) Write ¶
func (w *ByteWriter) Write(data []byte, offset int) (int, error)
func (*ByteWriter) WriteFloat32 ¶
func (w *ByteWriter) WriteFloat32(val float32, offset int) (int, error)
WriteFloat32 writes an float32 to the buffer
func (*ByteWriter) WriteFloat64 ¶
func (w *ByteWriter) WriteFloat64(val float64, offset int) (int, error)
WriteFloat64 writes an float64 to the buffer
func (*ByteWriter) WriteInt32 ¶
func (w *ByteWriter) WriteInt32(val int32, offset int) (int, error)
WriteInt32 writes an int32 to the buffer
func (*ByteWriter) WriteInt64 ¶
func (w *ByteWriter) WriteInt64(val int64, offset int) (int, error)
WriteInt64 writes an int64 to the buffer
func (*ByteWriter) WriteString ¶
func (w *ByteWriter) WriteString(val string, offset int) (int, error)
WriteString writes a string to the buffer
func (*ByteWriter) WriteUint32 ¶
func (w *ByteWriter) WriteUint32(val uint32, offset int) (int, error)
WriteUint32 writes an uint32 to the buffer
func (*ByteWriter) WriteUint64 ¶
func (w *ByteWriter) WriteUint64(val uint64, offset int) (int, error)
WriteUint64 writes an uint64 to the buffer
func (*ByteWriter) WriteVal ¶
func (w *ByteWriter) WriteVal(val interface{}, offset int) (int, error)
WriteVal writes an arbitrary value to the buffer
type MemoryMappedWriter ¶
MemoryMappedWriter is a ByteBuffer that is also mapped into memory
type MemoryMappedWriter struct {
*ByteWriter
// contains filtered or unexported fields
}
func NewMemoryMappedWriter ¶
func NewMemoryMappedWriter(loc string, size int) (*MemoryMappedWriter, error)
NewMemoryMappedWriter will create and return a new instance of a MemoryMappedWriter
func (*MemoryMappedWriter) Unmap ¶
func (b *MemoryMappedWriter) Unmap(removefile bool) error
Unmap will manually delete the memory mapping of a mapped buffer
type Writer ¶
Writer defines an abstraction for an object that allows writing of binary values anywhere within a fixed range
type Writer interface { Bytes() []byte Len() int Write([]byte, int) (int, error) WriteVal(interface{}, int) (int, error) WriteString(string, int) (int, error) WriteInt32(int32, int) (int, error) WriteInt64(int64, int) (int, error) WriteUint32(uint32, int) (int, error) WriteUint64(uint64, int) (int, error) WriteFloat32(float32, int) (int, error) WriteFloat64(float64, int) (int, error) MustWrite([]byte, int) int MustWriteVal(interface{}, int) int MustWriteString(string, int) int MustWriteInt32(int32, int) int MustWriteInt64(int64, int) int MustWriteUint32(uint32, int) int MustWriteUint64(uint64, int) int MustWriteFloat32(float32, int) int MustWriteFloat64(float64, int) int }