pub fn from_host_cpuid() -> Result<Self, Error> {
        let mut this = Self::new();
        let mut cpuid_regs = unsafe { host_cpuid(0x80000000) };

        if cpuid_regs.eax < 0x80000004 {
            // Brand string not supported by the host CPU
            return Err(Error::NotSupported);
        }

        for leaf in 0x80000002..=0x80000004 {
            cpuid_regs = unsafe { host_cpuid(leaf) };
            this.set_reg_for_leaf(leaf, Reg::EAX, cpuid_regs.eax);
            this.set_reg_for_leaf(leaf, Reg::EBX, cpuid_regs.ebx);
            this.set_reg_for_leaf(leaf, Reg::ECX, cpuid_regs.ecx);
            this.set_reg_for_leaf(leaf, Reg::EDX, cpuid_regs.edx);
        }

        let mut len = Self::MAX_LEN;
        {
            let this_bytes = this.as_bytes();
            while this_bytes[len - 1] == 0 && len > 0 {
                len -= 1;
            }
        }
        this.len = len;

        Ok(this)
    }
/// Creates a brand string, initialized from the CPUID leaves 0x80000002 through 0x80000004
/// of the host CPU.
Creates a brand string, initialized from the CPUID leaves 0x80000002 through 0x80000004
of the host CPU.
Creates a brand string initialized from the CPUID leaves 0x80000002 through 0x80000004 of the host CPU .
pub fn from_host_cpuid() -> Result<Self, Error> {
        let mut this = Self::new();
        let mut cpuid_regs = unsafe { host_cpuid(0x80000000) };
        if cpuid_regs.eax < 0x80000004 {
            // Brand string not supported by the host CPU
            return Err(Error::NotSupported);
        }
        for leaf in 0x80000002..=0x80000004 {
            cpuid_regs = unsafe { host_cpuid(leaf) };
            this.set_reg_for_leaf(leaf, Reg::EAX, cpuid_regs.eax);
            this.set_reg_for_leaf(leaf, Reg::EBX, cpuid_regs.ebx);
            this.set_reg_for_leaf(leaf, Reg::ECX, cpuid_regs.ecx);
            this.set_reg_for_leaf(leaf, Reg::EDX, cpuid_regs.edx);
        }
        let mut len = Self::MAX_LEN;
        {
            let this_bytes = this.as_bytes();
            while this_bytes[len - 1] == 0 && len > 0 {
                len -= 1;
            }
        }
        this.len = len;
        Ok(this)
    }
pub fn from_host_cpuid ( ) -> Result < Self , Error > { let mut this = Self :: new ( ) ; let mut cpuid_regs = unsafe { host_cpuid ( 0x80000000 ) } ; if cpuid_regs . eax < 0x80000004 { // Brand string not supported by the host CPU return Err ( Error :: NotSupported ) ; } for leaf in 0x80000002 ..= 0x80000004 { cpuid_regs = unsafe { host_cpuid ( leaf ) } ; this . set_reg_for_leaf ( leaf , Reg :: EAX , cpuid_regs . eax ) ; this . set_reg_for_leaf ( leaf , Reg :: EBX , cpuid_regs . ebx ) ; this . set_reg_for_leaf ( leaf , Reg :: ECX , cpuid_regs . ecx ) ; this . set_reg_for_leaf ( leaf , Reg :: EDX , cpuid_regs . edx ) ; } let mut len = Self :: MAX_LEN ; { let this_bytes = this . as_bytes ( ) ; while this_bytes [ len - 1 ] == 0 && len > 0 { len -= 1 ; } } this . len = len ; Ok ( this ) }
Creates a brand string, initialized from the CPUID leaves 0x80000002 through 0x80000004
of the host CPU.
Creates a brand string initialized from the CPUID leaves 0x80000002 through 0x80000004 of the host CPU .