diff --git a/src/builder/snippet.rs b/src/builder/snippet.rs index 0e73de4..aad51bf 100644 --- a/src/builder/snippet.rs +++ b/src/builder/snippet.rs @@ -17,13 +17,27 @@ pub struct GuiSnippet { } impl GuiSnippet { - pub fn new(gui_handler: Arc, path: &AssetPath) -> Result> { + pub fn new(gui_handler: &Arc, path: &AssetPath) -> Result> { let validator = Validator::new( #[cfg(feature = "audio")] &gui_handler, path, )?; + Self::_new(gui_handler, validator) + } + + pub fn from_str(gui_handler: &Arc, s: &str) -> Result> { + let validator = Validator::from_str( + #[cfg(feature = "audio")] + gui_handler, + s, + )?; + + Self::_new(gui_handler, validator) + } + + fn _new(gui_handler: &Arc, validator: Validator) -> Result> { let root = validator.root(); let mut ids = HashMap::new(); @@ -31,8 +45,7 @@ impl GuiSnippet { if root.children.len() != 1 { return Err(anyhow::Error::msg(format!( - "Expected exact 1 root in {}. Found {} roots", - path.full_path(), + "Expected exact 1 root. Found {} roots", root.children.len() ))); }