driver

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default(mime string) error

Default allows setting Codec as a default by mime type (using global instance of SmartRegistry).

func Global

func Global() codec.Registry

Global returns a global instance of SmartRegistry.

func Register

func Register(mime string, f codecInitFunc)

Register makes codec available for provided mime type (using global instance of SmartRegistry).

Types

type DummyRegistry

type DummyRegistry []codec.Codec

DummyRegistry represents simple slice-based codec registry.

func (DummyRegistry) Lookup

func (sr DummyRegistry) Lookup(mime string) codec.Codec

Lookup returns an appropriate codec from a slice by MimeType (if available) or nil.

type SmartRegistry

type SmartRegistry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SmartRegistry is a smart codec registry that is used to store available codecs and retrieve them by mime type.

func NewSmartRegistry

func NewSmartRegistry() *SmartRegistry

NewSmartRegistry is a SmartRegistry constructor func.

func (*SmartRegistry) Default

func (r *SmartRegistry) Default(mime string) error

Default allows setting Codec as a default by mime type. If codec was not found function returns an error. This function can be called multiple times overriding the previous values.

func (*SmartRegistry) Lookup

func (r *SmartRegistry) Lookup(mime string) codec.Codec

Lookup searches for appropriate codec by MimeType, if there is no exact match (that is possible using codecs such as Multipart), it tries to detect a codec in an opposite way, comparing default codec MimeType to the provided argument.

func (*SmartRegistry) Register

func (r *SmartRegistry) Register(mime string, f codecInitFunc) error

Register makes codec available for provided mime type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL