mediatype

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApplicationGoogleProtobuf tdl.MediaType = "application/vnd.google.protobuf"
	ApplicationJson           tdl.MediaType = "application/json"
	ApplicationProtobuf       tdl.MediaType = "application/protobuf"
	ApplicationXProtobuf      tdl.MediaType = "application/x-protobuf"
	ApplicationXYaml          tdl.MediaType = "application/x-yaml"
	ApplicationYaml           tdl.MediaType = "application/yaml"
	TextJson                  tdl.MediaType = "text/json"
	TextYaml                  tdl.MediaType = "text/yaml"
)
View Source
var Unmatched = errors.New("no match for mediatype")

Error returned by Match when no match was found

Functions

func Guess

func Guess(path string) (tdl.MediaType, error)

func Marshal

func Marshal(m proto.Message, media tdl.MediaType) ([]byte, error)

func Match

func Match[T any](media tdl.MediaType, match Matcher[T]) (T, error)

func Parse

func Parse(value string) (tdl.MediaType, error)

func PipeFs

func PipeFs[
	I c.Pipeline[M, T],
	M proto.Message, T any,
](pipeline I, path string, zero func() M) pipe.Func[afero.Fs, T]

func PipeInput

func PipeInput[
	I c.Pipeline[M, T],
	M proto.Message, T any,
](pipeline I, zero func() M) pipe.Func[tdl.Input, T]

func PipeRead

func PipeRead[
	I c.Pipeline[M, T],
	M proto.Message, T any,
](pipeline I, media tdl.MediaType, zero func() M) pipe.Func[io.Reader, T]

func Supported

func Supported(media tdl.MediaType) bool

func Unmarshal

func Unmarshal(data []byte, m proto.Message, media tdl.MediaType) error

func UnsupportedErr

func UnsupportedErr[M string | tdl.MediaType](media M) error

Types

type MatchFunc

type MatchFunc[T any] func() (T, error)

type Matcher

type Matcher[T any] struct {
	Protobuf MatchFunc[T]
	Json     MatchFunc[T]
	Yaml     MatchFunc[T]
	Other    MatchFunc[T]
}

type Option

type Option func() tdl.MediaType

Jump to

Keyboard shortcuts

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