Struct base16_color_scheme::scheme::RgbColorFormatter
source · pub struct RgbColorFormatter {
pub color: RgbColor,
pub format: Format,
}
Expand description
formatter that formats a color according to the specification
This formatter contains a color and a specifier in what format this color should be formatted.
Example
use base16_color_scheme::{
scheme::{RgbColor, RgbColorFormatter},
template::color_field::{Dec, Format, Hex, Hsl, Rgb},
};
let color = RgbColor([0x7c, 0xaf, 0xc2]);
// This macro is used to test the result of format!("{}") in a much more readable fashion
rgb_formatter_eq! {
color,
Format::Hex(Hex::Rgb), "7cafc2";
Format::Hex(Hex::R), "7c";
Format::Hex(Hex::G), "af";
Format::Hex(Hex::B), "c2";
Format::Hex(Hex::Bgr), "c2af7c";
Format::Rgb(Rgb::R), "124";
Format::Rgb(Rgb::G), "175";
Format::Rgb(Rgb::B), "194";
Format::Dec(Dec::R), "0.49";
Format::Dec(Dec::G), "0.69";
Format::Dec(Dec::B), "0.76";
Format::Hsl(Hsl::H), "196.29";
Format::Hsl(Hsl::S), "0.36";
Format::Hsl(Hsl::L), "0.62";
}
Fields§
§color: RgbColor
§format: Format
Trait Implementations§
source§impl Clone for RgbColorFormatter
impl Clone for RgbColorFormatter
source§fn clone(&self) -> RgbColorFormatter
fn clone(&self) -> RgbColorFormatter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Content for RgbColorFormatter
impl Content for RgbColorFormatter
source§fn is_truthy(&self) -> bool
fn is_truthy(&self) -> bool
Marks whether this content is truthy. Used when attempting to render a section.
source§fn render_escaped<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>
fn render_escaped<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>
Renders self as a variable to the encoder. Read more
source§fn capacity_hint(&self, _tpl: &Template<'_>) -> usize
fn capacity_hint(&self, _tpl: &Template<'_>) -> usize
How much capacity is likely required for all the data in this
Content
for a given Template
.source§fn render_unescaped<E>(
&self,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
E: Encoder,
fn render_unescaped<E>( &self, encoder: &mut E ) -> Result<(), <E as Encoder>::Error>where E: Encoder,
Renders self as a variable to the encoder. Read more
source§fn render_section<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_section<C, E>( &self, section: Section<'_, C>, encoder: &mut E ) -> Result<(), <E as Encoder>::Error>where C: ContentSequence, E: Encoder,
Render a section with self.
source§fn render_inverse<C, E>(
&self,
section: Section<'_, C>,
encoder: &mut E
) -> Result<(), <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_inverse<C, E>( &self, section: Section<'_, C>, encoder: &mut E ) -> Result<(), <E as Encoder>::Error>where C: ContentSequence, E: Encoder,
Render a section with self.
source§fn render_field_escaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
fn render_field_escaped<E>( &self, _hash: u64, _name: &str, _encoder: &mut E ) -> Result<bool, <E as Encoder>::Error>where E: Encoder,
Render a field by the hash or string of its name. Read more
source§fn render_field_unescaped<E>(
&self,
_hash: u64,
_name: &str,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
E: Encoder,
fn render_field_unescaped<E>( &self, _hash: u64, _name: &str, _encoder: &mut E ) -> Result<bool, <E as Encoder>::Error>where E: Encoder,
Render a field by the hash or string of its name. Read more
source§fn render_field_section<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_field_section<C, E>( &self, _hash: u64, _name: &str, _section: Section<'_, C>, _encoder: &mut E ) -> Result<bool, <E as Encoder>::Error>where C: ContentSequence, E: Encoder,
Render a field by the hash or string of its name, as a section.
If successful, returns
true
if the field exists in this content, otherwise false
.source§fn render_field_inverse<C, E>(
&self,
_hash: u64,
_name: &str,
_section: Section<'_, C>,
_encoder: &mut E
) -> Result<bool, <E as Encoder>::Error>where
C: ContentSequence,
E: Encoder,
fn render_field_inverse<C, E>( &self, _hash: u64, _name: &str, _section: Section<'_, C>, _encoder: &mut E ) -> Result<bool, <E as Encoder>::Error>where C: ContentSequence, E: Encoder,
Render a field, by the hash of or string its name, as an inverse section.
If successful, returns
true
if the field exists in this content, otherwise false
.source§impl Debug for RgbColorFormatter
impl Debug for RgbColorFormatter
source§impl Display for RgbColorFormatter
impl Display for RgbColorFormatter
source§impl Hash for RgbColorFormatter
impl Hash for RgbColorFormatter
source§impl Ord for RgbColorFormatter
impl Ord for RgbColorFormatter
source§fn cmp(&self, other: &RgbColorFormatter) -> Ordering
fn cmp(&self, other: &RgbColorFormatter) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<RgbColorFormatter> for RgbColorFormatter
impl PartialEq<RgbColorFormatter> for RgbColorFormatter
source§fn eq(&self, other: &RgbColorFormatter) -> bool
fn eq(&self, other: &RgbColorFormatter) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<RgbColorFormatter> for RgbColorFormatter
impl PartialOrd<RgbColorFormatter> for RgbColorFormatter
source§fn partial_cmp(&self, other: &RgbColorFormatter) -> Option<Ordering>
fn partial_cmp(&self, other: &RgbColorFormatter) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more