use std::collections::HashMap;
use std::path::PathBuf;
use alpha2_model::{Project, ProviderSource};
pub fn check_resources(
project: &Project,
resources: &HashMap<String, HashMap<String, PathBuf>>,
) -> Result<(), String> {
let mut named = resources.keys().collect::<Vec<_>>();
named.sort();
for id in named {
let reads_resources = project.sources.iter().any(|source| {
source.id.as_str() == id
&& matches!(
source.provider,
Some(ProviderSource::Svg | ProviderSource::Lottie { .. })
)
});
if !reads_resources {
return Err(crate::protocol::code_tag(
"INVALID_INPUT",
format!(
"resources names {id}, which is not an SVG or Lottie source of the project: \
only those read files outside themselves"
),
));
}
}
Ok(())
}
#[allow(clippy::needless_pass_by_value)] pub fn tagged(error: alpha2_host_core::providers::ProviderError) -> String {
match error.code {
Some(code) => crate::protocol::code_tag(code, error.message),
None => error.message,
}
}