global::utils

Utility functions to interact with the system.

fn get_root_domain

fn get_root_domain(domain: SharedObject) -> String
fn get_root_domain(domain: String) -> String
Get the root domain (the registrable part)

foo.bar.example.com => example.com


fn env

fn env(variable: String) -> ?
fn env(variable: SharedObject) -> ?
Fetch an environment variable from the current process.
  • variable - the variable to fetch.
  • string - the value of the fetched variable.
  • () - when the variable is not set, when the variable contains the sign character (=) or the NUL character, or that the variable does not contain valid Unicode.
#{
  connect: [
    rule "get env variable" || {

      // get the HOME environment variable.
      let home = utils::env("HOME");


      // "VSMTP=ENV" is malformed, this will return the unit type '()'.
      let invalid = utils::env("VSMTP=ENV");


      // ...
    }
  ],
}