use std::sync::Arc;
use renderer_assets::SvgData;
use ui_core::{AssetDecoder, AssetError};
pub struct SvgDecoder;
impl AssetDecoder for SvgDecoder {
fn kind(&self) -> &'static str {
"svg"
}
type Output = Arc<SvgData>;
fn decode(&self, bytes: &[u8]) -> Result<Self::Output, AssetError> {
let text = std::str::from_utf8(bytes)
.map_err(|e| AssetError(format!("svg is not valid utf-8: {e}")))?;
SvgData::from_str(text)
.map(Arc::new)
.map_err(|e| AssetError(e.to_string()))
}
}
#[cfg(test)]
#[path = "svg_test.rs"]
mod tests;