diff --git a/validation/src/check.rs b/validation/src/check.rs index 1a59124..c6c1bbd 100644 --- a/validation/src/check.rs +++ b/validation/src/check.rs @@ -127,10 +127,7 @@ pub struct ModelInfo<'a>{ counts:Counts, } -pub fn get_model_info(dom:&rbx_dom_weak::WeakDom)->Result<ModelInfo,GetRootInstanceError>{ - // extract the root instance, otherwise immediately return - let model_instance=get_root_instance(&dom)?; - +pub fn get_model_info<'a>(dom:&'a rbx_dom_weak::WeakDom,model_instance:&'a rbx_dom_weak::Instance)->ModelInfo<'a>{ // extract model info let map_info=get_mapinfo(&dom,model_instance); @@ -161,12 +158,12 @@ pub fn get_model_info(dom:&rbx_dom_weak::WeakDom)->Result<ModelInfo,GetRootInsta } } - Ok(ModelInfo{ + ModelInfo{ model_class:model_instance.class.as_str(), model_name:model_instance.name.as_str(), map_info, counts, - }) + } } // check if an observed string matches an expected string @@ -515,8 +512,11 @@ impl crate::message_handler::MessageHandler{ // decode dom (slow!) let dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::ModelFileDecode)?; + // extract the root instance + let model_instance=get_root_instance(&dom).map_err(Error::GetRootInstance)?; + // extract information from the model - let model_info=get_model_info(&dom).map_err(Error::GetRootInstance)?; + let model_info=get_model_info(&dom,model_instance); // convert the model information into a structured report let map_check=model_info.check();