Struct inferno::flamegraph::color::PaletteMap
source · 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
impl PaletteMap
sourcepub fn get(&self, func: &str) -> Option<Color>
pub fn get(&self, func: &str) -> Option<Color>
Returns the color value corresponding to the given function name.
sourcepub fn insert<S: ToString>(&mut self, func: S, color: Color) -> Option<Color>
pub fn insert<S: ToString>(&mut self, func: S, color: Color) -> Option<Color>
Inserts a function name/color pair in the map.
sourcepub fn iter(&self) -> impl Iterator<Item = (&str, Color)>
pub fn iter(&self) -> impl Iterator<Item = (&str, Color)>
Provides an iterator over the elements of the map.
sourcepub fn from_reader(reader: &mut dyn BufRead) -> Result<Self>
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.
sourcepub fn to_writer(&self, writer: &mut dyn Write) -> Result<()>
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.
sourcepub fn load_from_file_or_empty(path: &dyn AsRef<Path>) -> Result<Self>
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.
sourcepub fn save_to_file(&self, path: &dyn AsRef<Path>) -> Result<()>
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
impl Clone for PaletteMap
source§fn clone(&self) -> PaletteMap
fn clone(&self) -> PaletteMap
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PaletteMap
impl Debug for PaletteMap
source§impl Default for PaletteMap
impl Default for PaletteMap
source§fn default() -> PaletteMap
fn default() -> PaletteMap
source§impl PartialEq for PaletteMap
impl PartialEq for PaletteMap
source§fn eq(&self, other: &PaletteMap) -> bool
fn eq(&self, other: &PaletteMap) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for PaletteMap
impl StructuralEq for PaletteMap
impl StructuralPartialEq for PaletteMap
Auto Trait Implementations§
impl RefUnwindSafe for PaletteMap
impl Send for PaletteMap
impl Sync for PaletteMap
impl Unpin for PaletteMap
impl UnwindSafe for PaletteMap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.