Struct ImageFile

Source
pub struct ImageFile { /* private fields */ }
Expand description

An image file generator.

The minimum required setup methods are: width, height and path

§Example

ImageFile::new()
    .width(600)
    .height(400)
    .path("images/plotters-histogram.html")
    .overwrite(true)
    .title("the title")
    .alt("the alt text")
    .wrapper("div")
    .wrapper_style("padding: 10px; background-color: red;")
    .generate(my_generator_function)?;

Implementations§

Source§

impl ImageFile

§Constructor & Generator

Source

pub fn new() -> Self

Start configuring a new image.

Source

pub fn generate( self, generator: impl Fn(&mut Vec<u8>, u32, u32) -> StdResult<()>, ) -> DocimaResult<()>

Finishes the image, calling the generator function and saving the file.

Source§

impl ImageFile

§Required Configuration methods

Source

pub fn width(self, width: u32) -> Self

Sets the width of the image.

Source

pub fn height(self, height: u32) -> Self

Sets the height of the image.

Source

pub fn path(self, path: &str) -> Self

Sets the name and path of the output file, including the path from the project’s root.

Source§

impl ImageFile

§Optional Configuration methods

Source

pub fn attr(self, attribute: &str, value: &str) -> Self

Sets the chosen attribute for the <img> tag.

Valid attributes are: “alt”, “title”, “id”, “class”, “style”, …

Source

pub fn wrapper(self, wrapper: &str) -> Self

Sets the wrapper HTML tag around <img>.

Source

pub fn wrapper_attr(self, attribute: &str, value: &str) -> Self

Sets an attribute for the wrapper tag around <img>.

Valid attributes are: “alt”, “title”, “id”, “class”, “style”… And if the wrapper is an anchor “a”, then “href” & “target”.

Source

pub fn overwrite(self, overwrite: bool) -> Self

Sets the overwrite preference for the generated image.

If false the image will only be generated if the chosen output file doesn’t already exist. If true the image will always be generated, and the file overwritten.

Trait Implementations§

Source§

impl Default for ImageFile

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<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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.