pub struct PaletteMap(/* private fields */);
Expand description

Mapping of the association between a function name and the color used when drawing information from this function.

Implementations§

source§

impl PaletteMap

source

pub fn get(&self, func: &str) -> Option<Color>

Returns the color value corresponding to the given function name.

source

pub fn insert<S: ToString>(&mut self, func: S, color: Color) -> Option<Color>

Inserts a function name/color pair in the map.

source

pub fn iter(&self) -> impl Iterator<Item = (&str, Color)>

Provides an iterator over the elements of the map.

source

pub fn from_reader(reader: &mut dyn BufRead) -> Result<Self>

Builds a mapping based on the inputs given by the reader.

The reader should provide name/color pairs as text input, each pair separated by a line separator.

Each line should follow the format: NAME->rgb(RED, GREEN, BLUE) where NAME is the function name, and RED, GREEN, BLUE integer values between 0 and 255 included. Any line which does not follow the previous format will be ignored.

This function will propagate any std::io::Error returned by the given reader.

source

pub fn to_writer(&self, writer: &mut dyn Write) -> Result<()>

Writes the palette map using the given writer.

The output content will follow the same format described in from_reader.

The name/color pairs will be sorted by name in lexicographic order.

source

pub fn load_from_file_or_empty(path: &dyn AsRef<Path>) -> Result<Self>

Utility function to load a palette map from a file.

The file content should follow the format described in from_reader.

If the file does not exist, an empty palette map is returned.

source

pub fn save_to_file(&self, path: &dyn AsRef<Path>) -> Result<()>

Utility function to save a palette map to a file.

The file content will follow the format described in from_reader.

Trait Implementations§

source§

impl Clone for PaletteMap

source§

fn clone(&self) -> PaletteMap

Returns a copy 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 Debug for PaletteMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PaletteMap

source§

fn default() -> PaletteMap

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

impl PartialEq for PaletteMap

source§

fn eq(&self, other: &PaletteMap) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for PaletteMap

source§

impl StructuralEq for PaletteMap

source§

impl StructuralPartialEq for PaletteMap

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.