//! Concept to Vector providers: what makes vector variations of a selected image. //! //! A provider ([`Provider`]) takes one image's encoded pixels and up to [`MAX_STYLES`] of its own //! style ids ([`Request`]), and returns one [`Variation`] per style, in the order asked, as paths //! in the image's pixel space with explicit paints. It sees nothing else of the session or the //! document. The session keeps the providers in a [`Registry`] and calls one only by its id: an //! unknown or incapable provider is an error, never a substitute. //! //! The host checks every result again ([`check_result`]) before it keeps it, whatever provider //! made it: the number and order of the variations, finite coordinates and widths within bounds, //! and the totals [`MAX_ANCHORS`] and [`MAX_PATHS`] across all styles. //! //! The one built-in provider ([`offline::ID`]) makes its styles with Image Trace, on this //! computer: it takes no prompt and makes vector art only. pub mod offline; #[cfg(test)] mod tests; use std::sync::Arc; use vectorcraft_geom::{PathData, Point}; /// The most styles one request may ask for. pub const MAX_STYLES: usize = 8; /// The most anchor points all the variations of one request may hold together. pub const MAX_ANCHORS: usize = 1_000_000; /// The most paths all the variations of one request may hold together, each subpath of a compound /// path counted as one. pub const MAX_PATHS: usize = 250_000; /// The most warnings a variation may carry, and the most characters in each. pub const MAX_WARNINGS: usize = 16; const MAX_WARNING_CHARS: usize = 500; /// One of a provider's styles: its stable id and its English name. #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct Style { pub id: &'static str, pub label: &'static str, } /// What a provider takes and makes. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Capabilities { /// It takes an image as its input. pub image_input: bool, /// It makes editable vector paths. pub vector_output: bool, /// It takes a text prompt. pub prompt: bool, /// It makes raster images. pub raster_output: bool, /// It runs on this computer without a network. pub offline: bool, /// Its styles, in the order it lists them. pub styles: Vec