fastbytes

package module
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 4 Imported by: 1

README

Test Go Report CardGo Reference

FastBytes

FastBytes is a go package for translating between slices with fixed-size integers/floats and byte slices.

Supported Types

Floats and all signed/unsigned integers except uint and int can be translated by this package. uint and int are not supported since their size is platform dependent.

Usage

GoDoc

Usage of assembly code

This package uses assembly for copying data on certain platforms. To disable the usage of assembly set the purego build tag when building.

Usage of unsafe.Pointer

This package uses the unsafe package to covert between slice/array types and to extract pointers from interface{} values. To disable the usage of unsafe set the no_unsafe build tag when building. Note that this also disables the usage of assembly.

Documentation

Index

Constants

View Source
const (
	// ErrUnsupported the given type is not supported.
	// All signed and unsigned integers except uint and int, and floats are supported
	// uint and int are unsupported since their size is platform dependent.
	ErrUnsupported = errors.Error("bytes: unsupported target/source type")
	// ErrUnaddressable the give reflect.Value cannot be addressed
	ErrUnaddressable = errors.Error("bytes: un-addressable value")
	// ErrUnadressable typo
	// Deprecated: Use [ErrUnaddressable] instead.
	ErrUnadressable = ErrUnaddressable
)

Variables

View Source
var (
	// BigEndian copies bytes to and from big endian byte slices
	BigEndian = bytes{/* contains filtered or unexported fields */}
	// LittleEndian copies bytes to and from little endian byte slices
	LittleEndian = bytes{/* contains filtered or unexported fields */}
)

Functions

This section is empty.

Types

type ByteOrder

type ByteOrder interface {
	// FromI8 converts and copies bytes from `src` into `dst`.
	// The number of bytes copied is min(len(src), len(dst))
	FromI8(src []int8, dst []byte) (n int)
	// FromI16 converts and copies []int16 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*2, len(dst))
	FromI16(src []int16, dst []byte) (n int)
	// FromU16 converts and copies []uint16 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*2, len(dst))
	FromU16(src []uint16, dst []byte) (n int)
	// FromI32 converts and copies []int32 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*4, len(dst))
	FromI32(src []int32, dst []byte) (n int)
	// FromU32 converts and copies []uint32 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*4, len(dst))
	FromU32(src []uint32, dst []byte) (n int)
	// FromF32 converts and copies []float32 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*4, len(dst))
	FromF32(src []float32, dst []byte) (n int)
	// FromI64 converts and copies []int64 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*8, len(dst))
	FromI64(src []int64, dst []byte) (n int)
	// FromU64 converts and copies []int64 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*8, len(dst))
	FromU64(src []uint64, dst []byte) (n int)
	// FromF64 converts and copies []float64 from `src` into `dst`.
	// The number of bytes copied is min(len(src)*8, len(dst))
	FromF64(src []float64, dst []byte) (n int)
	// ToI8 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst))
	ToI8(src []byte, dst []int8) (n int)
	// ToI16 converts and copies bytes form `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*2)
	ToI16(src []byte, dst []int16) (n int)
	// ToU16 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*2)
	ToU16(src []byte, dst []uint16) (n int)
	// ToI32 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*4)
	ToI32(src []byte, dst []int32) (n int)
	// ToU32 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*4)
	ToU32(src []byte, dst []uint32) (n int)
	// ToF32 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*4)
	ToF32(src []byte, dst []float32) (n int)
	// ToI64 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*8)
	ToI64(src []byte, dst []int64) (n int)
	// ToU64 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*8)
	ToU64(src []byte, dst []uint64) (n int)
	// ToU64 converts and copies bytes from `src` into `dst`
	// The number of bytes copied is min(len(src), len(dst)*8)
	ToF64(src []byte, dst []float64) (n int)

	// To copies bytes from `s` into the given slice.
	// The given interface must be a type  that can be safely written to.
	// The number of bytes copied is min(len(src), len(dst)* element size of dst)
	To(src []byte, dst interface{}) (n int, err error)
	// From copies bytes from the given interface.
	// The provided interface must be a type that can be safely copied.
	// The number of bytes copied is min(len(src)* element size of dst, len(dst))
	From(src interface{}, dst []byte) (n int, err error)
	// ToValue copies bytes from `src` into the given value
	// The given interface must be a type that can be safely written to.
	// The number of bytes copied is min(len(src), len(dst)* element size of dst)
	ToValue(src []byte, dst reflect.Value) (n int, err error)
	// FromValue copies bytes from the given value.
	// The provided value must be a type that can be safely converted to bytes.
	// The number of bytes copied is min(len(src)* element size of dst, len(dst))
	FromValue(src reflect.Value, dst []byte) (n int, err error)
}

ByteOrder the byteorder

Directories

Path Synopsis
unsafe/asm/gen command

Jump to

Keyboard shortcuts

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