Struct rualdlib::Aliases[][src]

pub struct Aliases {
    pub aliases: Option<BTreeMap<String, String>>,
    pub vars: Option<BTreeMap<String, String>>,
    pub colors: Option<BTreeMap<String, String>>,
    pub alias_hash: Option<BTreeMap<String, String>>,
    // some fields omitted
}
Expand description

Contain aliases and assiociated path

use serde_derive::{Serialize,Deserialize};
use std::collections::BTreeMap;

#[derive(Serialize, Deserialize, Debug)]
pub struct Aliases {
    aliases: Option<BTreeMap<String, String>>,
}

Fields

aliases: Option<BTreeMap<String, String>>vars: Option<BTreeMap<String, String>>colors: Option<BTreeMap<String, String>>alias_hash: Option<BTreeMap<String, String>>

Implementations

Get alias from rad TOML structure

let home = std::env::var("HOME").unwrap();
let aliases: Aliases = toml::from_str(r#"
[aliases]
Home = '~'
workdir = '~/workdir'
local = '/usr/local'
"#).unwrap();

let alias = "Home";
let pointed = aliases.get(alias);

assert_eq!(pointed, Some(home));

Open rualdi aliases file from default aliases directory, default directory can be configured by _RAD_ALIASES_DIR env variable.

Save rualdi aliases file in default aliases directory, default directory can be configured by _RAD_ALIASES_DIR env variable.

Add alias on path in aliase configuration file, raise an error if alias already exists.

Add environment variable assiociated with an alias configuration file to load it in shell environment, raise an error if environment variable already exists.

Remove alias on path in aliase configuration file, raise an error if alias not exists.

Remove environment variable associated to an alias in aliase configuration file, raise an error if variable not exists.

Get a formatted String conaining aliases/paths found in configuration file

Get a String conaining aliases/vars found in configuration file

Search alias in rualdi aliases configuration file, return None if alias not found

Search environment variable associated to alias in rualdi aliases configuration file, return None if variable not found

Trait Implementations

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Executes the destructor for this type. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.