fn supported_image(filename: &str)-> Result<bool> {
    if filename.contains("."){
        let extension: &str = match (filename.split(".").collect::<Vec<&str>>()).last() {
            Some(ext)=> ext,
            None=> bail!("Error getting image extension.")
        };
        let normalized_extension = extension.to_lowercase();
        if SUPPORTED_EXTENSIONS.contains(&normalized_extension.as_str()) {
            Ok(true)
        } else {
            Ok(false)
        }
    } else {
        bail!("Error: host file has no extension to check it is supported.")
    }
}
/// Check if this file is supported as a valid host image.
///
/// Actually this function only check image as a valid extension. Valid extensions for
/// image file are in this module *SUPPORTED_EXTENSIONS* const list.
///
/// # Parameters:
/// * filename: Host image filename. It must include an extension.
///
/// # Returns:
/// * True if this images type is supported and false if not.
/// * Can raise an error if we can not get file extension.
Check if this file is supported as a valid host image.
Actually this function only check image as a valid extension. Valid extensions for
image file are in this module *SUPPORTED_EXTENSIONS* const list.
Check if this file is supported as a valid host image . Actually this function only check image as a valid extension . Valid extensions for image file are in this module * SUPPORTED_EXTENSIONS * const list .
fn supported_image(filename: &str)-> Result<bool> {
    if filename.contains("."){
        let extension: &str = match (filename.split(".").collect::<Vec<&str>>()).last() {
            Some(ext)=> ext,
            None=> bail!("Error getting image extension.")
        };
        let normalized_extension = extension.to_lowercase();
        if SUPPORTED_EXTENSIONS.contains(&normalized_extension.as_str()) {
            Ok(true)
        } else {
            Ok(false)
        }
    } else {
        bail!("Error: host file has no extension to check it is supported.")
    }
}
fn supported_image ( filename : & str ) -> Result < bool > { if filename . contains ( " " ) { let extension : & str = match ( filename . split ( " " ) . collect :: < Vec < & str > > ( ) ) . last ( ) { Some ( ext ) => ext , None => bail ! ( " " ) } ; let normalized_extension = extension . to_lowercase ( ) ; if SUPPORTED_EXTENSIONS . contains ( & normalized_extension . as_str ( ) ) { Ok ( true ) } else { Ok ( false ) } } else { bail ! ( " " ) } }
Check if this file is supported as a valid host image.
Check if this file is supported as a valid host image .
filename
&str
filename
&str
parameters:
Host image filename. It must include an extension.
Host image filename . It must include an extension .
returns:
True if this images type is supported and false if not.
Can raise an error if we can not get file extension.
True if this images type is supported and false if not . Can raise an error if we can not get file extension .