codec

package
v1.53.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetNotPointer        = errors.New("unable to set value of non-pointer")
	ErrInvalidOctetStreamType  = errors.New("unable to unmarshal octet-stream type")
	ErrInvalidJsonType         = errors.New("unable to unmarshal json type")
	ErrUnableMarshalMimeType   = errors.New("unable to marshal with unknown mime type")
	ErrUnableUnmarshalMimeType = errors.New("unable to unmarshal with unknown mime type")
)

Functions

func DecodeAndBind added in v1.36.0

func DecodeAndBind(input []byte, mime MimeType, target any) error

func DecodeValue added in v1.36.0

func DecodeValue(input []byte, mime MimeType) (any, error)

func Encode

func Encode(v any) ([]byte, error)

Types

type MimeType

type MimeType string
const (
	MimeTypeJson        MimeType = "application/json"
	MimeTypeText        MimeType = "application/text"
	MimeTypeOctetStream MimeType = "application/octet-stream"
	MimeTypeImageJpeg   MimeType = "image/jpeg"
	MimeTypeImagePng    MimeType = "image/png"
	MimeTypeImageGif    MimeType = "image/gif"
	MimeTypeImageSvg    MimeType = "image/svg"

	TypeApplication = "application"
	TypeImage       = "image"
)

func (MimeType) BaseType added in v1.36.0

func (mt MimeType) BaseType() MimeType

func (MimeType) Type added in v1.47.0

func (mt MimeType) Type() string

func (MimeType) WithType

func (mt MimeType) WithType(subType string) MimeType

Jump to

Keyboard shortcuts

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