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 contents_folder=entry.path();
|
||||||
let file_name=entry.file_name();
|
let file_name=entry.file_name();
|
||||||
let search_name=file_name.to_str().unwrap();
|
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...
|
//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));
|
let model_query=get_file_async(contents_folder.clone(),format!("{}.rbxmx",search_name));
|
||||||
//model? script? both?
|
//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?,
|
(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?,
|
(Err(QueryResolveError::NotFound),Ok(file))=>model_node(search_name,file).await?,
|
||||||
(Ok(_),Ok(_))=>Err(QueryResolveError::Ambiguous)?,
|
(Ok(_),Ok(_))=>Err(QueryResolveError::Ambiguous)?,
|
||||||
@ -1345,7 +1345,7 @@ async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileS
|
|||||||
//other error
|
//other error
|
||||||
(Err(e),_)
|
(Err(e),_)
|
||||||
|(_,Err(e))=>Err(e)?
|
|(_,Err(e))=>Err(e)?
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1354,7 +1354,7 @@ enum FileDiscernment{
|
|||||||
Script(ScriptHint),
|
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 path=entry.path();
|
||||||
let file_discernment=match path.extension(){
|
let file_discernment=match path.extension(){
|
||||||
Some(extension)=>match extension.to_str(){
|
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 search_name=path.to_str().unwrap();
|
||||||
let file=tokio::fs::File::open(path.as_path()).await?;
|
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::Model=>model_node(search_name,file).await?,
|
||||||
FileDiscernment::Script(hint)=>script_node(search_name,file,hint).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;
|
let style=config.style;
|
||||||
join_set.spawn(async move{
|
join_set.spawn(async move{
|
||||||
let met=entry.metadata().await?;
|
let met=entry.metadata().await?;
|
||||||
let scooby_doo=if met.is_dir(){
|
let compile_class=if met.is_dir(){
|
||||||
locate_override_file(&entry,style).await
|
locate_override_file(&entry,style).await?
|
||||||
}else{
|
}else{
|
||||||
discern_file(&entry,style).await
|
discern_file(&entry,style).await?
|
||||||
};
|
};
|
||||||
//discern that bad boy
|
//discern that bad boy
|
||||||
Ok::<_,anyhow::Error>(match scooby_doo?{
|
Ok::<_,anyhow::Error>(
|
||||||
Some(compile_class)=>{
|
|
||||||
//prepare data structure
|
//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::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::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::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::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))?),
|
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
|
//push child objects onto dom
|
||||||
while let Some(goober)=join_set.join_next().await{
|
while let Some(goober)=join_set.join_next().await{
|
||||||
match goober??{
|
match goober??{
|
||||||
Some(PreparedData::Model(mut model_dom))=>model_dom.transfer(model_dom.root().children()[0],&mut dom,item_ref),
|
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);},
|
PreparedData::Builder(script)=>{dom.insert(item_ref,script);},
|
||||||
None=>print!("There was a None"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//push dom children objects onto stack
|
//push dom children objects onto stack
|
||||||
|
Loading…
Reference in New Issue
Block a user