mediatype

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualFormats

func EqualFormats(a, b Format) bool

EqualFormats returns true if two Formats are the same type

Types

type Format

type Format struct {
	// contains filtered or unexported fields
}

Format is union type of all known mediatype formats

func ID

func ID(path string, useSignature bool) (Format, error)

ID identifies media into a known mediatype format. If useSignature is true, then the existing file extension is ignored and we use the file magic signature instead REF: https://en.wikipedia.org/wiki/File_format#Magic_number

func NewHEIFFormat

func NewHEIFFormat(h HEIF) Format

NewHEIFFormat returns a new HEIF format

func NewJPEGFormat

func NewJPEGFormat(j JPEG) Format

NewJPEGFormat returns a new JPEG format

func NewMP4Format

func NewMP4Format(h MP4) Format

NewMP4Format returns a new MPEG-4 format

func NewPNGFormat

func NewPNGFormat(p PNG) Format

NewPNGFormat returns a new PNG format

func NewQTFFFormat

func NewQTFFFormat(h QTFF) Format

NewQTFFFormat returns a new Quicktime format

func NewTIFFFormat

func NewTIFFFormat(h TIFF) Format

NewTIFFFormat returns a new TIFF format

type FormatWithVisitor

type FormatWithVisitor[T any] Format

FormatWithVisitor is a generic Format union type visitor

func (*FormatWithVisitor[T]) Accept

func (f *FormatWithVisitor[T]) Accept(ctx context.Context, v VisitorFunc[T]) (T, error)

Accept visits all known Format types

type HEIF

type HEIF struct {
	Path string
}

HEIF identifies HEIF media Ref: https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format

func (HEIF) Aliases

func (t HEIF) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (HEIF) Ext

func (t HEIF) Ext() string

Ext returns the file extension

func (HEIF) String

func (t HEIF) String() string

String implements Stringer interface

type JPEG

type JPEG struct {
	Path string
}

JPEG indetifies JPEG media REF: https://en.wikipedia.org/wiki/JPEG

func (JPEG) Aliases

func (t JPEG) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (JPEG) Ext

func (t JPEG) Ext() string

Ext returns the file extension

func (JPEG) String

func (t JPEG) String() string

String implements Stringer interface

type MP4

type MP4 struct {
	Path string
}

MP4 indetifies Quicktime media Ref: https://en.wikipedia.org/wiki/MP4_file_format

func (MP4) Aliases

func (t MP4) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (MP4) Ext

func (t MP4) Ext() string

Ext returns the file extension

func (MP4) String

func (t MP4) String() string

String implements Stringer interface

type PNG

type PNG struct {
	Path string
}

PNG identifies PNG media. REF: https://en.wikipedia.org/wiki/PNG

func (PNG) Aliases

func (t PNG) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (PNG) Ext

func (t PNG) Ext() string

Ext returns the file extension

func (PNG) String

func (t PNG) String() string

String implements Stringer interface

type QTFF

type QTFF struct {
	Path string
}

QTFF indetifies Quicktime media Ref: https://en.wikipedia.org/wiki/QuickTime_File_Format

func (QTFF) Aliases

func (t QTFF) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (QTFF) Ext

func (t QTFF) Ext() string

Ext returns the file extension

func (QTFF) String

func (t QTFF) String() string

String implements Stringer interface

type TIFF

type TIFF struct {
	Path string
}

TIFF indetifies TIFF media REF: https://en.wikipedia.org/wiki/TIFF

func (TIFF) Aliases

func (t TIFF) Aliases() map[string]struct{}

Aliases returns known file type aliases for this media type

func (TIFF) Ext

func (t TIFF) Ext() string

Ext returns the file extension

func (TIFF) String

func (t TIFF) String() string

String implements Stringer interface

type VisitorFunc

type VisitorFunc[T any] interface {
	VisitJPEG(context.Context, JPEG) (T, error)
	VisitPNG(context.Context, PNG) (T, error)
	VisitHEIF(context.Context, HEIF) (T, error)
	VisitTIFF(context.Context, TIFF) (T, error)
	VisitQTFF(context.Context, QTFF) (T, error)
	VisitMP4(context.Context, MP4) (T, error)
}

VisitorFunc implements a Visitor type that handles all known Format types

Jump to

Keyboard shortcuts

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