marshal

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package defines Spec which is a type to define marshaling behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesCompatible

type BytesCompatible interface {
	~string | []byte
}

Type compatible with byte array

type Spec

type Spec[S any] interface {
	// Convert a provided value into a byte array
	Marshal(v S) ([]byte, error)

	// Convert a provided a byte array into a value.
	// This should be an inverse operation of Marshal.
	Unmarshal([]byte) (S, error)
}

Specification of marshaling.

func Bytes

func Bytes[S BytesCompatible]() Spec[S]

Create a bytes spec.

This Spec simply cast a BytesCompatible type into a byte array.

func Gob

func Gob[S any]() Spec[S]

Create a gob spec.

This Spec converts a value into a gob format.

Jump to

Keyboard shortcuts

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