Skip to main content

ConversionOptions

Struct ConversionOptions 

Source
pub struct ConversionOptions {
    pub from: Option<String>,
    pub backend: Option<String>,
    pub forced_plan: Option<Plan>,
    pub params: BTreeMap<String, String>,
    pub verify: bool,
    pub reencode: bool,
    pub preserve: Vec<String>,
    pub inspect_content: bool,
}
Expand description

Per-conversion identification and route-selection choices.

Defaults use file identification and normal planning without a backend filter or quality params. Resource budgets are configured separately through Converter::limits. All fields are public; construct with ConversionOptions { field: value, ..ConversionOptions::default() }.

Fields§

§from: Option<String>

Override format identification for every input (a format ID or extension).

Skips content identification, including its empty-file rejection. Staging still requires regular files within the per-file input budget. This is a caller assertion, not a content validation request.

§backend: Option<String>

Require every executed step to use this backend.

Normal planning first finds a bounded set of routes, then filters it; a matching route outside that set is not searched for. Identity plans have no steps and pass any backend filter. Forced plans are checked step by step.

§forced_plan: Option<Plan>

Skip route search and attempt only this caller-supplied plan.

Prefer a plan obtained from Converter::plan. Steps must have concrete format IDs. Execution checks kind gates, the external flag against Policy::allow_external, backend filtering, format continuity, and returned artifacts. It does not verify edge membership in the graph, recompute cost, enforce search budgets or decode-only gates, or apply Policy::allow_external_packaging. Metadata is trusted: forced plans are not a safe boundary for untrusted callers.

§params: BTreeMap<String, String>

Quality knobs forwarded verbatim to every executed step.

The reserved key quality carries a 0-100 integer string; the engine validates that range and adapters map it onto their closest encoder control (JPEG/WebP quality, ffmpeg -q, imageMagick -quality). Unknown keys are ignored by adapters, so passing knobs for a backend that is not selected is harmless. Params never select paths or tools: values are opaque strings and are never interpolated into argv as executable or filesystem locations.

§verify: bool

Re-sniff every step’s artifacts by content magic before accepting them.

When enabled, the engine reads the first bytes of each returned file and compares the detected format with the step target. A contradiction fails the route and the engine falls back to the next plan. Bytes with no known signature are accepted, because absence of evidence is not evidence of a mismatch. Disabled by default because detection only covers formats with registered signatures.

§reencode: bool

Request a genuine re-encode when source and target formats match.

By default a same-format request stages a byte-for-byte copy with an empty plan. When set, planning searches for nonempty routes that return to the requested format (image recompression, codec change inside a container) and the identity copy is not offered. If no re-encode route exists with the registered adapters, conversion fails with an explanatory Error::Invalid rather than silently copying.

§preserve: Vec<String>

Content properties every executed step must declare it preserves.

Names are adapter vocabulary (pixels, alpha, metadata, structure, …), matched case-insensitively against crate::Conversion::retained during planning and enforced again for forced plans at execution. An empty list (the default) adds no requirement. The zero-step identity copy satisfies any retention request because it preserves bytes.

§inspect_content: bool

Ask adapters to inspect this input’s content before planning.

When set (and no Self::from override is given), Converter::convert profiles the first identified input through Converter::profile and searches with Graph::routes_with_profile, so edges with crate::Conversion::requires content are gated on the observed streams. With an override, format identification (and any inspection) is the caller’s job and no profile is taken. The converter’s Policy::inspect_content sets the same behavior for every request; this field overrides it per call.

Trait Implementations§

Source§

impl Clone for ConversionOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConversionOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConversionOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.