fn validate_library(path: &Path) -> Result<(), String> {
    if cfg!(any(target_os = "linux", target_os = "freebsd")) {
        let class = parse_elf_header(path).map_err(|e| e.to_string())?;

        if cfg!(target_pointer_width = "32") && class != 1 {
            return Err("invalid ELF class (64-bit)".into());
        }

        if cfg!(target_pointer_width = "64") && class != 2 {
            return Err("invalid ELF class (32-bit)".into());
        }

        Ok(())
    } else if cfg!(target_os = "windows") {
        let magic = parse_pe_header(path).map_err(|e| e.to_string())?;

        if cfg!(target_pointer_width = "32") && magic != 267 {
            return Err("invalid DLL (64-bit)".into());
        }

        if cfg!(target_pointer_width = "64") && magic != 523 {
            return Err("invalid DLL (32-bit)".into());
        }

        Ok(())
    } else {
        Ok(())
    }
}
/// Checks that a `libclang` shared library matches the target platform.

Checks that a `libclang` shared library matches the target platform.
Checks that a ` libclang ` shared library matches the target platform .
fn validate_library(path: &Path) -> Result<(), String> {
    if cfg!(any(target_os = "linux", target_os = "freebsd")) {
        let class = parse_elf_header(path).map_err(|e| e.to_string())?;
        if cfg!(target_pointer_width = "32") && class != 1 {
            return Err("invalid ELF class (64-bit)".into());
        }
        if cfg!(target_pointer_width = "64") && class != 2 {
            return Err("invalid ELF class (32-bit)".into());
        }
        Ok(())
    } else if cfg!(target_os = "windows") {
        let magic = parse_pe_header(path).map_err(|e| e.to_string())?;
        if cfg!(target_pointer_width = "32") && magic != 267 {
            return Err("invalid DLL (64-bit)".into());
        }
        if cfg!(target_pointer_width = "64") && magic != 523 {
            return Err("invalid DLL (32-bit)".into());
        }
        Ok(())
    } else {
        Ok(())
    }
}
fn validate_library ( path : & Path ) -> Result < ( ) , String > { if cfg ! ( any ( target_os " " target_os " " ) ) { let class = parse_elf_header ( path ) . map_err ( | e | e . to_string ( ) ) ? ; if cfg ! ( target_pointer_width " " ) && class != 1 { return Err ( " " . into ( ) ) ; } if cfg ! ( target_pointer_width " " ) && class != 2 { return Err ( " " . into ( ) ) ; } Ok ( ( ) ) } else if cfg ! ( target_os " " ) { let magic = parse_pe_header ( path ) . map_err ( | e | e . to_string ( ) ) ? ; if cfg ! ( target_pointer_width " " ) && magic != 267 { return Err ( " " . into ( ) ) ; } if cfg ! ( target_pointer_width " " ) && magic != 523 { return Err ( " " . into ( ) ) ; } Ok ( ( ) ) } else { Ok ( ( ) ) } }
Checks that a `libclang` shared library matches the target platform.
Checks that a ` libclang ` shared library matches the target platform .
path
&Path