From bd382ef8851bfe9ede0c7d0018a440501765e5fe Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 25 Apr 2024 23:28:55 -0700 Subject: [PATCH] decode to UploadResponse struct --- src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 332e28f..295f90a 100644 --- a/src/main.rs +++ b/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::().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,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::().await?)), other=>Err(anyhow::Error::msg(other)), } } @@ -436,7 +443,7 @@ async fn upload_list(cookie:String,group:Option,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), }