Function mid::get

source ·
pub fn get(key: &str) -> Result<String, MIDError>
Expand description

Gets unique platform metrics and returns a Result, which can be a MID hash (SHA-256) or a MIDError.

§Errors

Returns Err if an error occurred while creating the MachineID.

§Examples

fn get_machine_id() -> Result<String, String> {
  // Generate a key on macOS/Linux with: openssl rand -hex 32
  let key = "293273abaf6fcb31d4a9b47b70a20b21133ff08852834c52c5f42ed8153b274a";

  match mid::get(key) {
      Ok(mid) => Ok(mid),
      Err(err) => {
          println!("MID error: {}", err.to_string());
          Err(err.to_string())
      }
  }
}