JsImage

Enum JsImage 

Source
#[non_exhaustive]
pub enum JsImage {
#[non_exhaustive]
Path(PathBuf),
#[non_exhaustive]
Bytes(Vec<u8>),
#[non_exhaustive]
Resource(ResourceId),
#[non_exhaustive]
Rgba { rgba: Vec<u8>, width: u32, height: u32, }, }
Expand description

An image type that accepts file paths, raw bytes, previously loaded images and image objects.

This type is meant to be used along the transformImage API.

§Stability

The stability of the variants are not guaranteed, and matching against them is not recommended. Use JsImage::into_img instead.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
Path(PathBuf)

A reference to a image in the filesystem.

§

#[non_exhaustive]
Bytes(Vec<u8>)

Image from raw bytes.

§

#[non_exhaustive]
Resource(ResourceId)

An image that was previously loaded with the API and is stored in the resource table.

§

#[non_exhaustive]
Rgba

Raw RGBA definition of an image.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§rgba: Vec<u8>

Image bytes.

§width: u32

Image width.

§height: u32

Image height.

Implementations§

Source§

impl JsImage

Source

pub fn into_img(self, resources_table: &ResourceTable) -> Result<Arc<Image<'_>>>

Converts this intermediate image format into an actual Image.

This will retrieve the image from the passed ResourceTable if it is JsImage::Resource and will return an error if it doesn’t exist in the passed ResourceTable so make sure the passed ResourceTable is the same one used to store the image, usually this should be the webview resources table.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for JsImage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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<'de, D, R> CommandArg<'de, R> for D
where D: Deserialize<'de>, R: Runtime,

Source§

fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>

Derives an instance of Self from the CommandItem. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,