From 4a081d5b8f4edbb19e2bf80fae7da07f261ae4c8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 5 Jan 2024 13:47:32 -0800 Subject: [PATCH] delete useless enum --- src/main.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2ef3bee..ee2abf5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,22 +71,12 @@ async fn main()->AResult<()>{ Cookie::File(path)=>tokio::fs::read_to_string(path).await?, }); - let group=match cli.group{ - Some(group_id)=>Owner::Group(group_id), - None=>Owner::User, - }; - match cli.command{ Commands::Download=>download_list(cookie,vec![cli.asset_id]).await, - Commands::Upload=>upload_list(cookie,group,vec![cli.asset_id]).await, + Commands::Upload=>upload_list(cookie,cli.group,vec![cli.asset_id]).await, } } -enum Owner{ - Group(u64), - User -} - enum Cookie{ Literal(String), Environment(String), @@ -110,22 +100,22 @@ fn maybe_gzip_decode(input:&mut R)->AResult>{ } } -async fn upload_list(cookie:String,owner:Owner,asset_id_file_map:AssetIDFileMap)->AResult<()>{ +async fn upload_list(cookie:String,group:Option,asset_id_file_map:AssetIDFileMap)->AResult<()>{ let client=reqwest::Client::new(); futures::stream::iter(asset_id_file_map) .map(|(asset_id,file)|{ let client=&client; let cookie=cookie.as_str(); - let owner=&owner; + let group=&group; async move{ let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")?; //url borrow scope { let mut query=url.query_pairs_mut();//borrow here query.append_pair("assetid",asset_id.to_string().as_str()); - match owner{ - Owner::Group(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());}, - Owner::User=>(), + match group{ + Some(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());}, + None=>(), } }