fret_ui/svg_source.rs
1use std::sync::Arc;
2
3use fret_core::{SvgId, UiServices};
4
5#[derive(Debug, Clone)]
6pub enum SvgSource {
7 Id(SvgId),
8 Static(&'static [u8]),
9 Bytes(Arc<[u8]>),
10}
11
12impl SvgSource {
13 pub fn resolve(&self, services: &mut dyn UiServices) -> SvgId {
14 match self {
15 SvgSource::Id(id) => *id,
16 SvgSource::Static(bytes) => services.svg().register_svg(bytes),
17 SvgSource::Bytes(bytes) => services.svg().register_svg(bytes),
18 }
19 }
20}