xbinary

package
v0.0.0-...-f9b9731 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalByte

func MarshalByte(v byte, buf []byte) (int, error)

MarshalByte writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalBytes

func MarshalBytes(v []byte, buf []byte) (int, error)

MarshalBytes writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalString

func MarshalString(v string, buf []byte) (int, error)

MarshalString writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalUint

func MarshalUint(v uint, buf []byte) (int, error)

MarshalUint writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalUint16

func MarshalUint16(v uint16, buf []byte) (int, error)

MarshalUint16 writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalUint32

func MarshalUint32(v uint32, buf []byte) (int, error)

MarshalUint32 writes value v to the buf. Returns number of bytes written or an error, if any

func MarshalUint64

func MarshalUint64(v uint64, buf []byte) (int, error)

MarshalUint64 writes value v to the buf. Returns number of bytes written or an error, if any

func UnmarshalByte

func UnmarshalByte(buf []byte) (int, byte, error)

UnmarshalByte reads next byte value from the buf. Retruns number of bytes read, the value or an error, if any.

func UnmarshalBytes

func UnmarshalBytes(buf []byte, newBuf bool) (int, []byte, error)

UnmarshalBytes reads next []byte value from the buf. It retruns number of bytes read, the value or an error, if any.

func UnmarshalString

func UnmarshalString(buf []byte, newBuf bool) (int, string, error)

UnmarshalString reads next string value from the buf. It retruns number of bytes read, the value or an error, if any.

func UnmarshalUint

func UnmarshalUint(buf []byte) (int, uint, error)

UnmarshalUint reads next uint value from the buf. It retruns number of bytes read, the value or an error, if any.

func UnmarshalUint16

func UnmarshalUint16(buf []byte) (int, uint16, error)

UnmarshalUint16 reads next uint16 value from the buf. Retruns number of bytes read, the value or an error, if any.

func UnmarshalUint32

func UnmarshalUint32(buf []byte) (int, uint32, error)

UnmarshalUint32 reads next uint32 value from the buf. Retruns number of bytes read, the value or an error, if any.

func UnmarshalUint64

func UnmarshalUint64(buf []byte) (int, uint64, error)

UnmarshalUint64 reads next int64 value from the buf. Retruns number of bytes read, the value or an error, if any.

func WritableStringSize

func WritableStringSize(v string) int

WritableStringSize returns size of encoded v

func WritableUintSize

func WritableUintSize(v uint64) int

WritableUintSize returns size of encoded uint64 size

func WritebleBytesSize

func WritebleBytesSize(buf []byte) int

WritebleBytesSize returns size of encoded buf

Types

type ObjectsWriter

type ObjectsWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func (*ObjectsWriter) WriteByte

func (ow *ObjectsWriter) WriteByte(v byte) (int, error)

WriteByte writes value v to the writer. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteBytes

func (ow *ObjectsWriter) WriteBytes(v []byte) (int, error)

WriteBytes writes unmarshalable v to the writer. The written value could be unmarshaled by UnmarshalBytes, It contains a header - length of the bytes slice at the beginning. The method returns number of bytes written or an error if any.

func (*ObjectsWriter) WritePureBytes

func (ow *ObjectsWriter) WritePureBytes(v []byte) (int, error)

WritePureBytes writes value v to the writer. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WritePureString

func (ow *ObjectsWriter) WritePureString(v string) (int, error)

WritePureString writes value v to writer w. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteString

func (ow *ObjectsWriter) WriteString(v string) (int, error)

WriteString writes unmarshalable v to the writer. The written value could be unmarshaled by UnmarshalString, It contains a header - length of the bytes slice at the beginning. The method returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteUint

func (ow *ObjectsWriter) WriteUint(v uint) (int, error)

WriteUint writes value v to the writer with the variable size. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteUint16

func (ow *ObjectsWriter) WriteUint16(v uint16) (int, error)

WriteUint16 writes value v to the writer. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteUint32

func (ow *ObjectsWriter) WriteUint32(v uint32) (int, error)

WriteUint32 writes value v to the writer. It returns number of bytes written or an error if any.

func (*ObjectsWriter) WriteUint64

func (ow *ObjectsWriter) WriteUint64(v uint64) (int, error)

WriteUint64 writes value v to the writer. It returns number of bytes written or an error if any.

type Writable

type Writable interface {
	// WritableSize returns how many bytes the marshalled object form takes
	WritableSize() int

	// WriteTo allows to write (marshal) the object into the writer. If no
	// error happens, the function will write number of bytes returned by the WritableSize() function
	// it returns number of bytes written and an error, if any
	WriteTo(writer *ObjectsWriter) (int, error)
}

Writable interface is implemented by objects that could be written into io.Writer. The objects that support the interface must provide the size of the object in binary form and the function for writing the object into a Writer.

type WritableString

type WritableString string

WritableString a string which implements Writable

func (WritableString) WritableSize

func (ws WritableString) WritableSize() int

WritableSize is part of Writable for WritableString

func (WritableString) WriteTo

func (ws WritableString) WriteTo(writer *ObjectsWriter) (int, error)

WriteTo is part of Writable for WritableString

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL