pub fn query(ident: &CrateIdentity) -> Option<[u8; 32]> {
    let name = ident.name.to_lowercase();

    let raw_path = match name.len() {
        0 => return None,
        1 => format!("1/{}", name),
        2 => format!("2/{}", name),
        3 => format!("3/{}/{}", &name[..1], name),
        _ => format!("{}/{}/{}", &name[..2], &name[2..4], name),
    };

    let real_path = GLOBAL_CONFIG.index.join(raw_path);
    if !real_path.exists() {
        return None;
    }

    std::fs::read_to_string(real_path)
        .ok()?
        .lines()
        .filter_map(|x| serde_json::from_str::<CrateMetadata>(x).ok())
        .find(|x: &CrateMetadata| x.version == ident.version)
        .map(|x| x.checksum)
}
// from crate name and version to checksum
from crate name and version to checksum
from crate name and version to checksum
pub fn query(ident: &CrateIdentity) -> Option<[u8; 32]> {
    let name = ident.name.to_lowercase();
    let raw_path = match name.len() {
        0 => return None,
        1 => format!("1/{}", name),
        2 => format!("2/{}", name),
        3 => format!("3/{}/{}", &name[..1], name),
        _ => format!("{}/{}/{}", &name[..2], &name[2..4], name),
    };
    let real_path = GLOBAL_CONFIG.index.join(raw_path);
    if !real_path.exists() {
        return None;
    }
    std::fs::read_to_string(real_path)
        .ok()?
        .lines()
        .filter_map(|x| serde_json::from_str::<CrateMetadata>(x).ok())
        .find(|x: &CrateMetadata| x.version == ident.version)
        .map(|x| x.checksum)
}
pub fn query ( ident : & CrateIdentity ) -> Option < [ u8 ; 32 ] > { let name = ident . name . to_lowercase ( ) ; let raw_path = match name . len ( ) { 0 => return None , 1 => format ! ( " " name ) , 2 => format ! ( " " name ) , 3 => format ! ( " " name [ 1 ] name ) , _ => format ! ( " " name [ 2 ] name [ 2 4 ] name ) , } ; let real_path = GLOBAL_CONFIG . index . join ( raw_path ) ; if ! real_path . exists ( ) { return None ; } std :: fs :: read_to_string ( real_path ) . ok ( ) ? . lines ( ) . filter_map ( | x | serde_json :: from_str :: < CrateMetadata > ( x ) . ok ( ) ) . find ( | x : & CrateMetadata | x . version == ident . version ) . map ( | x | x . checksum ) }
from crate name and version to checksum
from crate name and version to checksum
ident
&CrateIdentity
ident
&CrateIdentity