pub struct GraphicsRenderOptions {
pub strategy: BTreeMap<String, Strategy>,
pub convert: BTreeMap<String, Vec<ConversionRule>>,
pub magnification: BTreeMap<String, Magnification>,
}Expand description
The render options of the graphics feature: for each output, how its
images are published, which conversion rules apply, and by how much its
images are magnified.
An option type is a plain Rust struct a feature declares once; its values
are set on a document or on a render request
(crate::model::options). This one is set on the render request. Each
field is a map from an output’s name (html, latex-recomposed, text)
to that output’s value; an output that a map does not list takes the
default. When a host combines several sources of settings, a source that
writes one output’s entry leaves the other outputs’ entries as the
lower-ranked sources wrote them. The publish stage of a backend reads the
entries of the output of the backend’s name: each standard backend makes
one output, named after the backend.
§Examples
use flm_core::stdlib::features::graphics::{GraphicsRenderOptions, ImageFormat, Strategy};
let options: GraphicsRenderOptions = serde_json::from_value(serde_json::json!({
"strategy": { "html": "data-uri", "latex-recomposed": "copy", "text": "content" },
"convert": { "html": [ { "from": "pdf", "to": "png", "options": { "dpi": 192 } } ] },
"magnification": { "html": { "raster": 1.5, "vector": 1.25 } },
}))
.unwrap();
assert_eq!(options.strategy_for("html"), Strategy::DataUri);
assert_eq!(options.strategy_for("text"), Strategy::Content);
assert_eq!(options.strategy_for("latex-rendered"), Strategy::Reference);
assert_eq!(options.rules_for("html")[0].to, ImageFormat::Png);
assert!(options.rules_for("latex-recomposed").is_empty());
assert_eq!(options.magnification_for("html").raster.value().to_string(), "1.5");
assert_eq!(options.magnification_for("text").vector.value().to_string(), "1");Fields§
§strategy: BTreeMap<String, Strategy>How each output publishes its images, by the output’s name:
reference (the address of the file where it is, the default), copy
(a copy of the file beside the output), data-uri (the file’s content
written into the address) or content (the address of the file where
it is, and the file’s content kept for an output that renders images
itself). copy, data-uri and content need a way to read image
files, which the program must supply.
convert: BTreeMap<String, Vec<ConversionRule>>The conversion rules of each output, by the output’s name, applied
under copy, data-uri and content and never under reference.
Each rule has from (a format or a list of formats among png,
jpeg, gif, webp, svg, pdf), to (one format), via (the
names of the converters allowed; any converter where empty) and
options (dpi, transparent_bg). For each image, the first rule
whose from lists the image’s format applies. No rule by default.
magnification: BTreeMap<String, Magnification>The magnification of each output, by the output’s name: raster and
vector, each a number greater than zero (1 where not given), by
which every dimension of a raster or a vector image shown on that
output is multiplied, including the width and height the author
gave. An image whose type is not known uses vector. No
magnification by default.
Implementations§
Source§impl GraphicsRenderOptions
impl GraphicsRenderOptions
Sourcepub fn strategy_for(&self, output: &str) -> Strategy
pub fn strategy_for(&self, output: &str) -> Strategy
Returns the strategy of the output output: its entry, else
reference.
Sourcepub fn rules_for(&self, output: &str) -> &[ConversionRule]
pub fn rules_for(&self, output: &str) -> &[ConversionRule]
Returns the conversion rules of the output output: its entry, else
none.
Sourcepub fn magnification_for(&self, output: &str) -> Magnification
pub fn magnification_for(&self, output: &str) -> Magnification
Returns the magnification of the output output: its entry, else a
factor of 1 for both types of images.
Trait Implementations§
Source§impl Clone for GraphicsRenderOptions
impl Clone for GraphicsRenderOptions
Source§impl Debug for GraphicsRenderOptions
impl Debug for GraphicsRenderOptions
Source§impl Default for GraphicsRenderOptions
impl Default for GraphicsRenderOptions
Source§impl<'de> Deserialize<'de> for GraphicsRenderOptionswhere
GraphicsRenderOptions: Default,
impl<'de> Deserialize<'de> for GraphicsRenderOptionswhere
GraphicsRenderOptions: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for GraphicsRenderOptions
Source§impl Hash for GraphicsRenderOptions
impl Hash for GraphicsRenderOptions
Source§impl JsonSchema for GraphicsRenderOptions
impl JsonSchema for GraphicsRenderOptions
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for GraphicsRenderOptions
impl PartialEq for GraphicsRenderOptions
impl StructuralPartialEq for GraphicsRenderOptions
Auto Trait Implementations§
impl Forget for GraphicsRenderOptions
impl Freeze for GraphicsRenderOptionswhere
*const LeafNode<String, Strategy> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Strategy)>>: Freeze,
*const LeafNode<String, Vec<ConversionRule>> is !null: Freeze,
PhantomData<Box<(String, Vec<ConversionRule>)>>: Freeze,
*const LeafNode<String, Magnification> is !null: Freeze,
PhantomData<Box<(String, Magnification)>>: Freeze,
impl Move for GraphicsRenderOptions
impl RefUnwindSafe for GraphicsRenderOptions
impl Send for GraphicsRenderOptionswhere
NodeRef<Owned, String, Strategy, LeafOrInternal>: Send,
BoxRaw<(String, Strategy)>: Send,
NodeRef<Owned, String, Vec<ConversionRule>, LeafOrInternal>: Send,
BoxRaw<(String, Vec<ConversionRule>)>: Send,
NodeRef<Owned, String, Magnification, LeafOrInternal>: Send,
BoxRaw<(String, Magnification)>: Send,
impl Sync for GraphicsRenderOptionswhere
NodeRef<Owned, String, Strategy, LeafOrInternal>: Sync,
BoxRaw<(String, Strategy)>: Sync,
NodeRef<Owned, String, Vec<ConversionRule>, LeafOrInternal>: Sync,
BoxRaw<(String, Vec<ConversionRule>)>: Sync,
NodeRef<Owned, String, Magnification, LeafOrInternal>: Sync,
BoxRaw<(String, Magnification)>: Sync,
impl Unpin for GraphicsRenderOptions
impl UnsafeUnpin for GraphicsRenderOptionswhere
*const LeafNode<String, Strategy> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Strategy)>>: UnsafeUnpin,
*const LeafNode<String, Vec<ConversionRule>> is !null: UnsafeUnpin,
PhantomData<Box<(String, Vec<ConversionRule>)>>: UnsafeUnpin,
*const LeafNode<String, Magnification> is !null: UnsafeUnpin,
PhantomData<Box<(String, Magnification)>>: UnsafeUnpin,
impl UnwindSafe for GraphicsRenderOptionswhere
BTreeMap<String, Strategy>: UnwindSafe,
BTreeMap<String, Vec<ConversionRule>>: UnwindSafe,
BTreeMap<String, Magnification>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more