Struct humantalk::Config

source ·
pub struct Config {
    pub colors: HashMap<Severity, Color>,
    pub bug_report: Option<HowToBugReport>,
}
Expand description

configuration struct for humantalk

Fields§

§colors: HashMap<Severity, Color>

colors hashmap for each severity level

§bug_report: Option<HowToBugReport>

the bug reporting struct

Implementations§

source§

impl Config

source

pub fn default() -> Config

create a new configuration, with default colors and no bug report (auto-filled with default values on use)

source

pub fn custom( colors: HashMap<Severity, Color>, bug_report: HowToBugReport ) -> Config

create a custom config, with your own colors and bug report. If you just want custom bug report, just use this code (inverse for colors):

use humantalk::{Config, Severity, HowToBugReport};
 
let my_config = Config::custom(
    Config::default().colors,
    HowToBugReport::new(
        "message".to_string(),
        "url".to_string()
    )
);
source

pub fn get_color(&self, severity: &Severity) -> Color

find the specified color for a given severity

source

pub fn set_color(&mut self, severity: Severity, color: Color)

set the color for the specified severity level

source

pub fn write(&self, severity: Severity, message: &str)

write a logging message to stdout. if the binary has been compiled with –release, it will not print debug assertions.

source

pub fn debug(&self, message: &str)

shorthand for config.write(Severity::Debug, ...)

source

pub fn info(&self, message: &str)

shorthand for config.write(Severity::Info, ...)

source

pub fn error(&self, message: &str)

shorthand for config.write(Severity::Error, ...)

source

pub fn warning(&self, message: &str)

shorthand for config.write(Severity::Warning, ...)

source

pub fn machine_info(&self) -> String

get machine info represented as a string. Contains info including OS family, os, arch, rust version, llvm version and humantalk version

source

pub fn fatal_error(&self, message: &str)

error fatally, crashing the program. then exits with error code 3, indincating that erroring out has succeeded

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

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 Config

source§

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

Formats the value using the given formatter. 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> 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.