[][src]Struct favy::Favicon

pub struct Favicon { /* fields omitted */ }

A comprehensive favicon encoder.

Example

use favy::{resample, encode::Encode, Image, Favicon, Size};
 
fn main() -> io::Result<()> {
    // Initialize the icon
    let mut icon = Favicon::new();
 
    // Add a single entry
    let image = Image::open("example.png")?;
    icon.add_entry(resample::linear, &image, Size(32))?;
 
    // Add multiple entries
    icon.add_entries(
        resample::linear,
        &image,
        vec![Size(64), Size(128), Size(256)]
    )?;
 
    // Save the icon to disk
    icon.save("~/favicon/")
}

Methods

impl Favicon[src]

pub fn apple_touch(&mut self, b: bool) -> &mut Self[src]

Indicates that the outputted html-helper should contain link tags for apple-touch icons.

This option defaults to false.

Example

let fav = Favicon::new().apple_touch(true);
<link rel="apple-touch-icon-precomposed" sizes="196x196" href="icons/favicon0.png">
<link rel="icon" sizes="196x196" href="icons/favicon0.png">

pub fn web_app(&mut self, b: bool) -> &mut Self[src]

Indicates that the output of self.write or self.save should contain a serialize.webmanifest file to assist on creating PWA icons.

This option defaults to false.

Example

let fav = Favicon::new().web_app(true);
...
<link rel="serialize" href="serialize.webmanifest">
{
  icons: [
    {
      src: "icons/favicon0.png",
      sizes: "196x196",
      type: "image/png"
    }
  ]
}

pub fn html_helper(&self) -> Result<Vec<u8>>[src]

Returns a buffer containing HTML link tags to assist on the creating of the icon.

pub fn manisfest(&self) -> Result<Vec<u8>>[src]

Returns a buffer containing a JSON helper for web manisfests.

Trait Implementations

impl Clone for Favicon[src]

impl Debug for Favicon[src]

impl Encode for Favicon[src]

type Key = Size

impl Save for Favicon[src]

Auto Trait Implementations

impl Send for Favicon

impl Sync for Favicon

impl Unpin for Favicon

impl UnwindSafe for Favicon

impl RefUnwindSafe for Favicon

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Save for T where
    T: Write
[src]

impl<T> SetParameter for T