stream

package
v2.0.0-rc.1.0...-64c530f Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoTo

func GoTo(seeker io.Seeker, offset int64) (newOffset int64, err error)

GoTo seeks to the given offset and returns the new offset.

func Offset

func Offset(seeker io.Seeker) (offset int64, err error)

Offset returns the current offset of the reader.

func Read

func Read[T any](reader io.ReadSeeker) (result T, err error)

Read reads a generic basic type from the stream.

func ReadBlob

func ReadBlob(reader io.ReadSeeker) (blob []byte, err error)

ReadBlob reads a byte slice from the stream (the first 8 bytes are the length of the blob).

func ReadBytes

func ReadBytes(reader io.ReadSeeker, size uint64) (bytes []byte, err error)

ReadBytes reads a byte slice of the given size from the stream.

func ReadCollection

func ReadCollection(reader io.ReadSeeker, readCallback func(int) error) (err error)

ReadCollection reads a collection from the stream (the first 8 bytes are the length of the collection).

func ReadSerializable

func ReadSerializable[T any, TPtr serializer.MarshalablePtr[T]](reader io.ReadSeeker, target TPtr, optFixedSize ...int) (err error)

ReadSerializable reads a serializable type from the stream (if the serialized field is of fixed size, we can provide the length to omit additional information about the length of the serializable).

func Skip

func Skip(seeker io.Seeker, offset int64) (newOffset int64, err error)

Skip skips the given number of bytes and returns the new offset.

func Write

func Write[T any](writer io.WriteSeeker, value T) (err error)

Write writes a generic basic type from the stream.

func WriteBlob

func WriteBlob(writer io.WriteSeeker, blob []byte) (err error)

WriteBlob writes a byte slice to the stream (the first 8 bytes are the length of the blob).

func WriteCollection

func WriteCollection(writer io.WriteSeeker, writeCollection func() (elementsCount uint64, err error)) (err error)

WriteCollection writes a collection to the stream (the first 8 bytes are the length of the collection).

func WriteSerializable

func WriteSerializable[T serializer.Byter](writer io.WriteSeeker, target T, optFixedSize ...int) (err error)

WriteSerializable writes a serializable type to the stream (if the serialized field is of fixed size, we can provide the length to omit additional information about the length of the serializable).

Types

This section is empty.

Jump to

Keyboard shortcuts

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