core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendStatus

type BackendStatus struct {
	Name         string
	BinaryName   string
	Capabilities int
	Installed    bool
	Version      string
	Path         string
	InstallHint  string
	Description  string
	Edges        []Edge
}

type ConvertRequest

type ConvertRequest struct {
	From        string
	To          string
	InputPath   string
	OutputPath  string
	Options     backend.Options
	RoutePolicy router.RoutePolicy
}

type ConvertResult

type ConvertResult struct {
	Success bool
	Hops    int
}

type Edge

type Edge struct {
	From string
	To   string
}

type Engine

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

Engine is the central conversion orchestrator. It owns a Registry and a routing Graph built from that registry. Adapters (CLI, TUI, server) construct an Engine and call its methods instead of using global state.

func NewEngine

func NewEngine(registry *backend.Registry) *Engine

NewEngine creates an Engine that routes conversions using only the backends in the supplied Registry. The graph is built once at construction time; if the registry is mutated later, call RebuildGraph to refresh.

func (*Engine) Backends

func (e *Engine) Backends(_ context.Context) []BackendStatus

Backends returns status info for every backend in the engine's registry.

func (*Engine) Convert

func (e *Engine) Convert(ctx context.Context, req ConvertRequest) (*ConvertResult, error)

Convert executes a single conversion by routing from→to, then running each step through the matched backend. This is a simplified single-file path; for batch conversion with full source/sink/progress support, use ExecuteJobs.

func (*Engine) ExecuteJobs

func (e *Engine) ExecuteJobs(ctx context.Context, jobs []runner.Job, opts runner.RunOpts) (*runner.Summary, error)

ExecuteJobs delegates to runner.Execute, providing a single entry point for all adapters (CLI, TUI, server). The caller is responsible for constructing jobs (source, route, sink, options) before calling this.

func (*Engine) FindRoute

func (e *Engine) FindRoute(src, dst string) (*router.Route, error)

FindRoute returns the lowest-cost conversion path from src to dst as a router.Route with live backend references. Adapters that need to execute conversions (CLI, TUI) should use this instead of Route which returns DTOs without backend references.

func (*Engine) FindRouteWithPolicy

func (e *Engine) FindRouteWithPolicy(src, dst string, policy router.RoutePolicy) (*router.Route, error)

func (*Engine) Formats

func (e *Engine) Formats(_ context.Context) []string

Formats returns all format IDs reachable in the engine's graph.

func (*Engine) Process

Process delegates a processing operation to the first Processor registered for the given operation type. This is separate from the conversion pipeline (Convert/ExecuteJobs) because processing operations like merge/split/rotate are not format-to-format conversions.

func (*Engine) RebuildGraph

func (e *Engine) RebuildGraph()

RebuildGraph reconstructs the routing graph from the current registry state.

func (*Engine) Route

func (e *Engine) Route(ctx context.Context, src, dst string) (*RouteResult, error)

Route finds the lowest-cost conversion path from src to dst and returns a DTO without backend references. Suitable for inspection/API responses.

func (*Engine) RouteWithPolicy

func (e *Engine) RouteWithPolicy(ctx context.Context, src, dst string, policy router.RoutePolicy) (*RouteResult, error)

RouteWithPolicy finds the best conversion path from src to dst according to the given policy and returns a DTO with per-step and aggregate metadata.

type RouteResult

type RouteResult struct {
	Steps     []RouteStep
	TotalCost int
	Quality   int
	Lossy     bool
}

type RouteStep

type RouteStep struct {
	From        string
	To          string
	BackendName string
	Cost        int
	Quality     int
	Lossy       bool
}

Jump to

Keyboard shortcuts

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