/// Checks if `input` is a valid path for a file in a Fuchsia package.
/// Fuchsia package resource paths are Fuchsia object relative paths without
/// the limit on maximum path length.
/// Passes the input through if it is valid.
Checks if `input` is a valid path for a file in a Fuchsia package.
Fuchsia package resource paths are Fuchsia object relative paths without
the limit on maximum path length.
Passes the input through if it is valid.
Checks if ` input ` is a valid path for a file in a Fuchsia package . Fuchsia package resource paths are Fuchsia object relative paths without the limit on maximum path length . Passes the input through if it is valid .
pub fn check_resource_path(input: &str) -> Result<&str, ResourcePathError> {
    if input.is_empty() {
        return Err(ResourcePathError::PathIsEmpty);
    }
    if input.starts_with('/') {
        return Err(ResourcePathError::PathStartsWithSlash);
    }
    if input.ends_with('/') {
        return Err(ResourcePathError::PathEndsWithSlash);
    }
    for segment in input.split('/') {
        if segment.contains('\0') {
            return Err(ResourcePathError::NameContainsNull);
        }
        if segment == "." {
            return Err(ResourcePathError::NameIsDot);
        }
        if segment == ".." {
            return Err(ResourcePathError::NameIsDotDot);
        }
        if segment.is_empty() {
            return Err(ResourcePathError::NameEmpty);
        }
        if segment.len() > MAX_OBJECT_BYTES {
            return Err(ResourcePathError::NameTooLong);
        }
    }
    Ok(input)
}
pub fn check_resource_path ( input : & str ) -> Result < & str , ResourcePathError > { if input . is_empty ( ) { return Err ( ResourcePathError :: PathIsEmpty ) ; } if input . starts_with ( '/' ) { return Err ( ResourcePathError :: PathStartsWithSlash ) ; } if input . ends_with ( '/' ) { return Err ( ResourcePathError :: PathEndsWithSlash ) ; } for segment in input . split ( '/' ) { if segment . contains ( '\0' ) { return Err ( ResourcePathError :: NameContainsNull ) ; } if segment == " " { return Err ( ResourcePathError :: NameIsDot ) ; } if segment == " " { return Err ( ResourcePathError :: NameIsDotDot ) ; } if segment . is_empty ( ) { return Err ( ResourcePathError :: NameEmpty ) ; } if segment . len ( ) > MAX_OBJECT_BYTES { return Err ( ResourcePathError :: NameTooLong ) ; } } Ok ( input ) }
Checks if `input` is a valid path for a file in a Fuchsia package.
Checks if ` input ` is a valid path for a file in a Fuchsia package .
input
&str