pub struct ImageAssetBuilder;
Expand description

A builder for an image asset. This must be used in the mg! macro.

Note: This will do nothing outside of the mg! macro

Implementations§

source§

impl ImageAssetBuilder

source

pub const fn format(self, format: ImageType) -> Self

Sets the format of the image

Note: This will do nothing outside of the mg! macro

The choosing the right format can make your site load much faster. Webp and avif images tend to be a good default for most images

const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").format(ImageType::Webp));
source

pub const fn size(self, x: u32, y: u32) -> Self

Sets the size of the image

Note: This will do nothing outside of the mg! macro

If you only use the image in one place, you can set the size of the image to the size it will be displayed at. This will make the image load faster

const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").size(512, 512));
source

pub const fn low_quality_preview(self) -> Self

Make the image use a low quality preview

Note: This will do nothing outside of the mg! macro

A low quality preview is a small version of the image that will load faster. This is useful for large images on mobile devices that may take longer to load

const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").low_quality_preview());
source

pub const fn preload(self) -> Self

Make the image preloaded

Note: This will do nothing outside of the mg! macro

Preloading an image will make the image start to load as soon as possible. This is useful for images that will be displayed soon after the page loads or images that may not be visible immediately, but should start loading sooner

const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").preload());
source

pub const fn url_encoded(self) -> Self

Make the image URL encoded

Note: This will do nothing outside of the mg! macro

URL encoding an image inlines the data of the image into the URL. This is useful for small images that should load as soon as the html is parsed

const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").url_encoded());

Trait Implementations§

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, O> SuperFrom<T> for O
where O: From<T>,

source§

fn super_from(input: T) -> O

Convert from a type to another type.
source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

source§

fn super_into(self) -> O

Convert from a type to another type.
source§

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

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more