remove unnecessary Option
This commit is contained in:
parent
17bfbef482
commit
994eb9c4be
34
src/main.rs
34
src/main.rs
@ -1313,7 +1313,7 @@ async fn model_node(search_name:&str,mut file:tokio::fs::File)->AResult<CompileN
|
||||
})
|
||||
}
|
||||
|
||||
async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<Option<CompileNode>>{
|
||||
async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<CompileNode>{
|
||||
let contents_folder=entry.path();
|
||||
let file_name=entry.file_name();
|
||||
let search_name=file_name.to_str().unwrap();
|
||||
@ -1333,7 +1333,7 @@ async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileS
|
||||
//model files are rox & rox-rojo only, so it's a lot less work...
|
||||
let model_query=get_file_async(contents_folder.clone(),format!("{}.rbxmx",search_name));
|
||||
//model? script? both?
|
||||
Ok(Some(match tokio::join!(script_query,model_query){
|
||||
Ok(match tokio::join!(script_query,model_query){
|
||||
(Ok(FileHint{file,hint}),Err(QueryResolveError::NotFound))=>script_node(search_name,file,hint).await?,
|
||||
(Err(QueryResolveError::NotFound),Ok(file))=>model_node(search_name,file).await?,
|
||||
(Ok(_),Ok(_))=>Err(QueryResolveError::Ambiguous)?,
|
||||
@ -1345,7 +1345,7 @@ async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileS
|
||||
//other error
|
||||
(Err(e),_)
|
||||
|(_,Err(e))=>Err(e)?
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1354,7 +1354,7 @@ enum FileDiscernment{
|
||||
Script(ScriptHint),
|
||||
}
|
||||
|
||||
async fn discern_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<Option<CompileNode>>{
|
||||
async fn discern_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<CompileNode>{
|
||||
let path=entry.path();
|
||||
let file_discernment=match path.extension(){
|
||||
Some(extension)=>match extension.to_str(){
|
||||
@ -1375,10 +1375,10 @@ async fn discern_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->
|
||||
}
|
||||
let search_name=path.to_str().unwrap();
|
||||
let file=tokio::fs::File::open(path.as_path()).await?;
|
||||
Ok(Some(match file_discernment{
|
||||
Ok(match file_discernment{
|
||||
FileDiscernment::Model=>model_node(search_name,file).await?,
|
||||
FileDiscernment::Script(hint)=>script_node(search_name,file,hint).await?,
|
||||
}))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@ -1479,25 +1479,22 @@ async fn compile(config:CompileConfig)->AResult<()>{
|
||||
let style=config.style;
|
||||
join_set.spawn(async move{
|
||||
let met=entry.metadata().await?;
|
||||
let scooby_doo=if met.is_dir(){
|
||||
locate_override_file(&entry,style).await
|
||||
let compile_class=if met.is_dir(){
|
||||
locate_override_file(&entry,style).await?
|
||||
}else{
|
||||
discern_file(&entry,style).await
|
||||
discern_file(&entry,style).await?
|
||||
};
|
||||
//discern that bad boy
|
||||
Ok::<_,anyhow::Error>(match scooby_doo?{
|
||||
Some(compile_class)=>{
|
||||
Ok::<_,anyhow::Error>(
|
||||
//prepare data structure
|
||||
Some(match compile_class.class{
|
||||
match compile_class.class{
|
||||
CompileClass::Folder=>PreparedData::Builder(rbx_dom_weak::InstanceBuilder::new("Folder").with_name(compile_class.name.as_str())),
|
||||
CompileClass::Script(source)=>PreparedData::Builder(script_builder("Script",compile_class.name.as_str(),source)),
|
||||
CompileClass::LocalScript(source)=>PreparedData::Builder(script_builder("LocalScript",compile_class.name.as_str(),source)),
|
||||
CompileClass::ModuleScript(source)=>PreparedData::Builder(script_builder("ModuleScript",compile_class.name.as_str(),source)),
|
||||
CompileClass::Model(buf)=>PreparedData::Model(rbx_xml::from_reader_default(std::io::Cursor::new(buf))?),
|
||||
})
|
||||
},
|
||||
None=>None,
|
||||
})
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1505,9 +1502,8 @@ async fn compile(config:CompileConfig)->AResult<()>{
|
||||
//push child objects onto dom
|
||||
while let Some(goober)=join_set.join_next().await{
|
||||
match goober??{
|
||||
Some(PreparedData::Model(mut model_dom))=>model_dom.transfer(model_dom.root().children()[0],&mut dom,item_ref),
|
||||
Some(PreparedData::Builder(script))=>{dom.insert(item_ref,script);},
|
||||
None=>print!("There was a None"),
|
||||
PreparedData::Model(mut model_dom)=>model_dom.transfer(model_dom.root().children()[0],&mut dom,item_ref),
|
||||
PreparedData::Builder(script)=>{dom.insert(item_ref,script);},
|
||||
}
|
||||
}
|
||||
//push dom children objects onto stack
|
||||
|
Loading…
Reference in New Issue
Block a user