Struct machineid_rs::IdBuilder
source · [−]pub struct IdBuilder {
pub hash: Encryption,
/* private fields */
}Expand description
IdBuilder is the constructor for the HWID. It can be used with the 3 different options of the Encryption enum.
Fields
hash: EncryptionImplementations
sourceimpl IdBuilder
impl IdBuilder
sourcepub fn build(&mut self, key: &str) -> Result<String, HWIDError>
pub fn build(&mut self, key: &str) -> Result<String, HWIDError>
Joins every part together and returns a Result that may be the hashed HWID or a HWIDError.
Errors
Returns Err if there is an error while retrieving the component’s strings.
Examples
use machineid_rs::{IdBuilder, Encryption, HWIDComponent};
let mut builder = IdBuilder::new(Encryption::MD5);
builder.add_component(HWIDComponent::SystemID);
// Will panic if there is an error when the components return his values.
let key = builder.build("mykey").unwrap();sourcepub fn add_component(&mut self, component: HWIDComponent) -> &mut Self
pub fn add_component(&mut self, component: HWIDComponent) -> &mut Self
Adds a component to the IdBuilder that will be hashed once you call the IdBuilder::build function.
You can’t add the same component twice.
Examples
use machineid_rs::{IdBuilder, Encryption, HWIDComponent};
let mut builder = IdBuilder::new(Encryption::MD5);
builder.add_component(HWIDComponent::SystemID);sourcepub fn new(hash: Encryption) -> Self
pub fn new(hash: Encryption) -> Self
Makes a new IdBuilder with the selected Encryption
Examples
use machineid_rs::{IdBuilder, Encryption};
let mut builder = IdBuilder::new(Encryption::MD5);Auto Trait Implementations
impl RefUnwindSafe for IdBuilder
impl Send for IdBuilder
impl Sync for IdBuilder
impl Unpin for IdBuilder
impl UnwindSafe for IdBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more