Struct ConfigBuilder

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

A builder for Configs.

Implementations§

Source§

impl ConfigBuilder

Source

pub fn hues(self, hues: impl AsRef<[f64]>) -> Self

Sets the hues to be used in the identicon. All hues should be specified in degrees in the range [0.0, 360.0).

Source

pub fn color_lightness(self, lightness: impl NormalizableRange) -> Self

Sets the lightness range of colored shapes in the identicon. This should be a sub-range of 0.0..=1.0.

Source

pub fn grayscale_lightness(self, lightness: impl NormalizableRange) -> Self

Sets the lightness range of grayscale shapes in the identicon. This should be a sub-range of 0.0..=1.0.

Source

pub const fn color_saturation(self, saturation: f64) -> Self

Sets the saturation range of colored shapes in the identicon, between 0 and 1. Defaults to 0.5.

Source

pub const fn grayscale_saturation(self, saturation: f64) -> Self

Sets the saturation range of grayscale shapes in the identicon, between 0 and 1. Defaults to 0.0.

Source

pub const fn background_color(self, color: Rgba) -> Self

Sets the background color to be rendered behind the identicon. Defaults to Rgba::white.

Source

pub const fn padding(self, padding: f64) -> Self

Sets the padding surrounding the icon relative to the size of the icon. This should be within the range [0.0, 0.5]. Defaults to 0.08.

Source

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

Sets the size of the icon in pixels. Defaults to 256.

Source

pub fn build(self) -> Result<Config, ConfigBuilderError>

Builds the Config.

§Errors
  • If hues are not within the range [0.0, 360.0).
  • If color lightness is not within the range 0.0..=1.0.
  • If grayscale lightness is not within the range 0.0..=1.0.
  • If color saturation is not within the range [0.0, 1.0].
  • If grayscale saturation is not within the range [0.0, 1.0].
  • If padding is not within the range [0.0, 0.5].

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.