use thiserror::Error;
use crate::{
internal::{conversion::IntoBindgen, wit},
prelude::EntityId,
};
#[derive(Error, Debug)]
pub enum UrlError {
#[error("Invalid URL: {0}")]
InvalidUrl(String),
}
impl From<wit::asset::UrlError> for UrlError {
fn from(value: wit::asset::UrlError) -> Self {
match value {
wit::asset::UrlError::InvalidUrl(err) => UrlError::InvalidUrl(err),
}
}
}
#[doc(hidden)]
pub fn url_for_package_asset(package_id: EntityId, path: &str) -> Result<String, UrlError> {
Ok(wit::asset::url(package_id.into_bindgen(), path)?)
}