backend

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBinary    = errors.New("binary not found")
	ErrNoRoute     = errors.New("no conversion route")
	ErrConvertFail = errors.New("conversion failed")
)

Functions

func Register

func Register(b Backend)

Register adds a backend to the global registry. Backends should call Register in their init() or via a constructor.

func Wrap

func Wrap(name, from, to string, err error) error

Wrap creates a ConvertError.

Types

type Backend

type Backend interface {
	Name() string
	BinaryName() string
	Capabilities() []Capability
	Convert(ctx context.Context, in, out string, opts Options) error
}

Backend is the interface every converter must satisfy.

func All

func All() []Backend

All returns a snapshot of all registered backends.

func Resolve

func Resolve(from, to string) (Backend, error)

Resolve returns the first backend that can convert from→to. Returns ErrNoRoute if none found.

type Capability

type Capability struct {
	From    string
	To      string
	Cost    int // 1=fast, 5=slow/lossy
	Quality int // 0-100
	Lossy   bool
}

Capability declares a single From→To conversion that a backend can perform.

func AllCapabilities

func AllCapabilities() []Capability

AllCapabilities returns every declared capability across all backends.

type ConvertError

type ConvertError struct {
	BackendName string
	From        string
	To          string
	Err         error
}

ConvertError wraps a backend error with routing context.

func (*ConvertError) Error

func (e *ConvertError) Error() string

func (*ConvertError) Is

func (e *ConvertError) Is(target error) bool

Is makes ConvertError satisfy errors.Is(err, ErrConvertFail) for retry logic.

func (*ConvertError) Unwrap

func (e *ConvertError) Unwrap() error

type Options

type Options struct {
	Quality   int
	StripMeta bool
	Workers   int
	ExtraArgs []string
	Named     map[string]string // "backend.key" → value
}

Options carries conversion parameters passed from CLI / config.

func (Options) Get

func (o Options) Get(backend, key string) string

Get returns the named option for a specific backend ("pandoc.wrap" etc.).

Directories

Path Synopsis
backends
asciidoctor
Package asciidoctor provides AsciiDoc conversion via the asciidoctor binary.
Package asciidoctor provides AsciiDoc conversion via the asciidoctor binary.
csvkit
Package csvkit provides CSV/XLSX/JSON conversion via csvkit or xlsx2csv.
Package csvkit provides CSV/XLSX/JSON conversion via csvkit or xlsx2csv.
ffmpeg
Package ffmpeg provides audio/video conversion via the ffmpeg binary.
Package ffmpeg provides audio/video conversion via the ffmpeg binary.
figlet
Package figlet converts plain text to ASCII art via the figlet binary.
Package figlet converts plain text to ASCII art via the figlet binary.
imagemagick
Package imagemagick provides image conversion via ImageMagick (magick or convert).
Package imagemagick provides image conversion via ImageMagick (magick or convert).
jq
Package jq provides JSON formatting/transformation via the jq binary.
Package jq provides JSON formatting/transformation via the jq binary.
libreoffice
Package libreoffice provides a backend that delegates to soffice (LibreOffice).
Package libreoffice provides a backend that delegates to soffice (LibreOffice).
pandoc
Package pandoc provides a backend that delegates conversions to pandoc.
Package pandoc provides a backend that delegates conversions to pandoc.
plugin
Package plugin discovers and registers external convertr-* executables as backends.
Package plugin discovers and registers external convertr-* executables as backends.
tesseract
Package tesseract provides OCR via the tesseract binary.
Package tesseract provides OCR via the tesseract binary.
textutil
Package textutil provides a macOS-native backend using the textutil(1) command.
Package textutil provides a macOS-native backend using the textutil(1) command.
yq
Package yq provides YAML/JSON/TOML conversion via the yq binary.
Package yq provides YAML/JSON/TOML conversion via the yq binary.

Jump to

Keyboard shortcuts

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