delete useless enum

This commit is contained in:
Quaternions 2024-01-05 13:47:32 -08:00
parent 54ca5520b7
commit 4a081d5b8f

View File

@ -71,22 +71,12 @@ async fn main()->AResult<()>{
Cookie::File(path)=>tokio::fs::read_to_string(path).await?, 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{ match cli.command{
Commands::Download=>download_list(cookie,vec![cli.asset_id]).await, 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{ enum Cookie{
Literal(String), Literal(String),
Environment(String), Environment(String),
@ -110,22 +100,22 @@ fn maybe_gzip_decode<R:Read+Seek>(input:&mut R)->AResult<ReaderType<R>>{
} }
} }
async fn upload_list(cookie:String,owner:Owner,asset_id_file_map:AssetIDFileMap)->AResult<()>{ async fn upload_list(cookie:String,group:Option<u64>,asset_id_file_map:AssetIDFileMap)->AResult<()>{
let client=reqwest::Client::new(); let client=reqwest::Client::new();
futures::stream::iter(asset_id_file_map) futures::stream::iter(asset_id_file_map)
.map(|(asset_id,file)|{ .map(|(asset_id,file)|{
let client=&client; let client=&client;
let cookie=cookie.as_str(); let cookie=cookie.as_str();
let owner=&owner; let group=&group;
async move{ async move{
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")?; let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")?;
//url borrow scope //url borrow scope
{ {
let mut query=url.query_pairs_mut();//borrow here let mut query=url.query_pairs_mut();//borrow here
query.append_pair("assetid",asset_id.to_string().as_str()); query.append_pair("assetid",asset_id.to_string().as_str());
match owner{ match group{
Owner::Group(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());}, Some(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());},
Owner::User=>(), None=>(),
} }
} }