Identicon

Struct Identicon 

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

Generic Identicon struct.

This is the base struct to be used.

Implementations§

Source§

impl Identicon

Source

pub fn new(input_value: &str) -> Identicon

Generates a new identicon from an input value.

The defaults are:

  • border: 50
  • size: 5
  • scale: 500
  • background_color: (240, 240, 240)
  • mirrored: true
Source

pub fn set_input(&mut self, input_value: &str) -> &mut Self

Sets the identicon input value, regenerating the hash.

Source

pub fn border(&self) -> u32

Gets the identicon border size.

Source

pub fn set_border(&mut self, border: u32) -> &mut Self

Sets the identicon border size.

Default is 5

Source

pub fn size(&self) -> u32

Gets the identicon size.

The size represents the number of viewable blocks of the identicon.

Source

pub fn set_size(&mut self, size: u32) -> Result<&mut Self, IdenticonError>

Sets the number of viewable blocks of the identicon.

This must be <= the scale.

Default is 5, representing an identicon with a grid of 5x5.

Source

pub fn scale(&self) -> u32

Gets the identicon scale.

The scale represents the height and width of the identicon portion of any generated image.

The full image size is: scale + ( 2 * border )

Source

pub fn set_scale(&mut self, scale: u32) -> Result<&mut Self, IdenticonError>

Sets the scale of the image.

The full image size is: scale + ( 2 * border )

This must be >= the size.

Source

pub fn mirrored(&self) -> bool

Gets if the identicon is mirrored.

Source

pub fn set_mirrored(&mut self, mirrored: bool) -> &mut Self

Sets whether the identicon is mirrored along the y axis.

This is a boolean.

Source

pub fn theme(&self) -> Arc<dyn Theme>

Gets the current theme.

Source

pub fn set_theme(&mut self, theme: Arc<dyn Theme + Send + Sync>) -> &mut Self

Sets the current identicon theme.

Source

pub fn generate_image(&self) -> Result<DynamicImage, IdenticonError>

Generates the DynamicImage representing the Identicon.

Source

pub fn save_image(&self, output_filename: &str) -> Result<(), IdenticonError>

Saves the generated image to the given filename.

The file formats .png, .jpg, .jpeg, .bmp, and .ico work.

Source

pub fn export_png_data(&self) -> Result<Vec<u8>, IdenticonError>

Export a PNG file buffer as a Vec<u8>.

This is for creating a file for a buffer or network response without creating a file on the filesystem.

Source

pub fn export_jpeg_data(&self) -> Result<Vec<u8>, IdenticonError>

Export a JPEG file buffer as a Vec<u8>.

This is for creating a file for a buffer or network response without creating a file on the filesystem.

Trait Implementations§

Source§

impl Clone for Identicon

Source§

fn clone(&self) -> Identicon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Identicon

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FromStr for Identicon

Source§

type Err = IdenticonError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.