decode to UploadResponse struct
This commit is contained in:
parent
809d6df3f0
commit
bd382ef885
15
src/main.rs
15
src/main.rs
@ -225,6 +225,13 @@ struct InventoryItem{
|
||||
name:String,
|
||||
}
|
||||
|
||||
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||
#[allow(nonstandard_style,dead_code)]
|
||||
struct UploadResponse{
|
||||
AssetId:u64,
|
||||
AssetVersionId:u64,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main()->AResult<()>{
|
||||
let cli=Cli::parse();
|
||||
@ -380,11 +387,11 @@ async fn create(config:CreateConfig)->AResult<()>{
|
||||
}
|
||||
}
|
||||
let body=match resp.status(){
|
||||
reqwest::StatusCode::OK=>Ok(resp.bytes().await?),
|
||||
reqwest::StatusCode::OK=>Ok(resp.json::<UploadResponse>().await?),
|
||||
other=>Err(anyhow::Error::msg(other)),
|
||||
};
|
||||
|
||||
println!("response.body={:?}",body?);
|
||||
println!("UploadResponse={:?}",body?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -427,7 +434,7 @@ async fn upload_list(cookie:String,group:Option<u64>,asset_id_file_map:AssetIDFi
|
||||
}
|
||||
}
|
||||
match resp.status(){
|
||||
reqwest::StatusCode::OK=>Ok((asset_id,resp.bytes().await?)),
|
||||
reqwest::StatusCode::OK=>Ok((asset_id,resp.json::<UploadResponse>().await?)),
|
||||
other=>Err(anyhow::Error::msg(other)),
|
||||
}
|
||||
}
|
||||
@ -436,7 +443,7 @@ async fn upload_list(cookie:String,group:Option<u64>,asset_id_file_map:AssetIDFi
|
||||
.for_each(|b:AResult<_>|async{
|
||||
match b{
|
||||
Ok((asset_id,body))=>{
|
||||
println!("asset_id={} response.body={:?}",asset_id,body);
|
||||
println!("asset_id={} UploadResponse={:?}",asset_id,body);
|
||||
},
|
||||
Err(e)=>eprintln!("ul error: {}",e),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user