fn sanitize_fetch(mut fetch: HashMap<String, String>) -> Result<HashMap<String, String>, UserErr> {
    for (key, value) in fetch.iter_mut() {
        if !NORMAL_FETCH_KEYS.contains(&key.as_ref()) {
            abort_with!(UserErr::Other(format!("Illegal fetch field: {}", key)))
        }
        match key.as_str() {
            MEMORY_KEY => {
                *value = byte_unit::Byte::from_str(&value)
                    .user_error("Malformed value provided for Memory")?
                    .get_bytes()
                    .to_string()
            }
            IMAGE_KEY => {
                if !util::validate_url(&value) {
                    abort_with!("Got malformed url for Image")
                }
            }
            _ => {}
        }
    }
    Ok(fetch)
}
/// Sanitize field values and check validity of user-provided fetch data.
Sanitize field values and check validity of user-provided fetch data.
Sanitize field values and check validity of user - provided fetch data .
fn sanitize_fetch(mut fetch: HashMap<String, String>) -> Result<HashMap<String, String>, UserErr> {
    for (key, value) in fetch.iter_mut() {
        if !NORMAL_FETCH_KEYS.contains(&key.as_ref()) {
            abort_with!(UserErr::Other(format!("Illegal fetch field: {}", key)))
        }
        match key.as_str() {
            MEMORY_KEY => {
                *value = byte_unit::Byte::from_str(&value)
                    .user_error("Malformed value provided for Memory")?
                    .get_bytes()
                    .to_string()
            }
            IMAGE_KEY => {
                if !util::validate_url(&value) {
                    abort_with!("Got malformed url for Image")
                }
            }
            _ => {}
        }
    }
    Ok(fetch)
}
fn sanitize_fetch ( mut fetch : HashMap < String , String > ) -> Result < HashMap < String , String > , UserErr > { for ( key , value ) in fetch . iter_mut ( ) { if ! NORMAL_FETCH_KEYS . contains ( & key . as_ref ( ) ) { abort_with ! ( UserErr Other ( format ( " " key ) ) ) } match key . as_str ( ) { MEMORY_KEY => { * value = byte_unit :: Byte :: from_str ( & value ) . user_error ( " " ) ? . get_bytes ( ) . to_string ( ) } IMAGE_KEY => { if ! util :: validate_url ( & value ) { abort_with ! ( " " ) } } _ => { } } } Ok ( fetch ) }
Sanitize field values and check validity of user-provided fetch data.
Sanitize field values and check validity of user - provided fetch data .
fetch
HashMap<String, String>
fetch
HashMap<String, String>