pub struct ConversionRule {
pub from: Vec<ImageFormat>,
pub to: ImageFormat,
pub via: Vec<String>,
pub options: ConversionOptions,
}Expand description
A conversion rule: which formats are turned into which, by which converters, with which options. See the module documentation.
In settings, a rule is written as a map with the keys from, to, via
and options; from and to are required.
§Examples
use flm_core::stdlib::features::graphics::{ConversionRule, ImageFormat};
let rule: ConversionRule = serde_json::from_value(serde_json::json!({
"from": "pdf",
"to": "png",
"options": { "dpi": 192 },
}))
.unwrap();
assert_eq!(rule.from, [ImageFormat::Pdf]);
assert_eq!(rule.to, ImageFormat::Png);
assert!(rule.via.is_empty());
assert_eq!(rule.options.dpi, Some(192));Fields§
§from: Vec<ImageFormat>The formats the rule turns into to: one format (pdf) or a list
([svg, pdf]), each one of png, jpeg, gif, webp, svg and
pdf.
to: ImageFormatThe format the rule turns them into.
via: Vec<String>The names of the converters allowed to perform the rule, in no particular order; where the list is empty (the default), every converter is allowed.
options: ConversionOptionsThe options the converter reads, such as the resolution at which a drawing is turned into pixels.
Implementations§
Source§impl ConversionRule
impl ConversionRule
Sourcepub fn new(
from: impl IntoIterator<Item = ImageFormat>,
to: ImageFormat,
) -> ConversionRule
pub fn new( from: impl IntoIterator<Item = ImageFormat>, to: ImageFormat, ) -> ConversionRule
Returns the rule that turns each of the formats from into to, by
any converter, with no option given.
Sourcepub fn via(self, name: impl Into<String>) -> ConversionRule
pub fn via(self, name: impl Into<String>) -> ConversionRule
Builder: adds the converter named name to the converters allowed to
perform the rule.
Sourcepub fn options(self, options: ConversionOptions) -> ConversionRule
pub fn options(self, options: ConversionOptions) -> ConversionRule
Builder: sets the rule’s options.
Sourcepub fn applies_to(&self, format: ImageFormat) -> bool
pub fn applies_to(&self, format: ImageFormat) -> bool
Returns whether the rule applies to an image of the format format:
whether its from lists the format.
Trait Implementations§
Source§impl Clone for ConversionRule
impl Clone for ConversionRule
Source§impl Debug for ConversionRule
impl Debug for ConversionRule
Source§impl<'de> Deserialize<'de> for ConversionRule
impl<'de> Deserialize<'de> for ConversionRule
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 ConversionRule
Source§impl Hash for ConversionRule
impl Hash for ConversionRule
Source§impl JsonSchema for ConversionRule
impl JsonSchema for ConversionRule
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 ConversionRule
impl PartialEq for ConversionRule
impl StructuralPartialEq for ConversionRule
Auto Trait Implementations§
impl Forget for ConversionRule
impl Freeze for ConversionRule
impl Move for ConversionRule
impl RefUnwindSafe for ConversionRule
impl Send for ConversionRulewhere
RawVecInner: Send,
impl Sync for ConversionRulewhere
RawVecInner: Sync,
impl Unpin for ConversionRule
impl UnsafeUnpin for ConversionRulewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<ImageFormat>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for ConversionRulewhere
RawVecInner: 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