v0.4.8 better errors #9
@ -58,7 +58,12 @@ impl std::fmt::Display for UploadError{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::error::Error for UploadError{}
|
impl std::error::Error for UploadError{}
|
||||||
type UploadResponse=u64;
|
type RobloxUploadResponse=u64;
|
||||||
|
#[derive(Debug,serde::Deserialize,serde::Serialize)]
|
||||||
|
#[allow(nonstandard_style,dead_code)]
|
||||||
|
pub struct UploadResponse{
|
||||||
|
pub AssetId:u64,
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style,dead_code)]
|
#[allow(nonstandard_style,dead_code)]
|
||||||
pub struct GetAssetRequest{
|
pub struct GetAssetRequest{
|
||||||
@ -267,11 +272,14 @@ impl CookieContext{
|
|||||||
query.append_pair("groupId",group_id.to_string().as_str());
|
query.append_pair("groupId",group_id.to_string().as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let asset_id=crate::response_ok(
|
||||||
crate::response_ok(
|
|
||||||
self.post(url,body).await.map_err(CreateError::PostError)?
|
self.post(url,body).await.map_err(CreateError::PostError)?
|
||||||
).await.map_err(CreateError::Response)?
|
).await.map_err(CreateError::Response)?
|
||||||
.json::<UploadResponse>().await.map_err(CreateError::Reqwest)
|
.json::<RobloxUploadResponse>().await.map_err(CreateError::Reqwest)?;
|
||||||
|
|
||||||
|
Ok(UploadResponse{
|
||||||
|
AssetId:asset_id,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
|
pub async fn upload(&self,config:UploadRequest,body:impl Into<reqwest::Body>+Clone)->Result<UploadResponse,UploadError>{
|
||||||
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
|
let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?;
|
||||||
@ -299,11 +307,14 @@ impl CookieContext{
|
|||||||
query.append_pair("groupId",group_id.to_string().as_str());
|
query.append_pair("groupId",group_id.to_string().as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let asset_id=crate::response_ok(
|
||||||
crate::response_ok(
|
|
||||||
self.post(url,body).await.map_err(UploadError::PostError)?
|
self.post(url,body).await.map_err(UploadError::PostError)?
|
||||||
).await.map_err(UploadError::Response)?
|
).await.map_err(UploadError::Response)?
|
||||||
.json::<UploadResponse>().await.map_err(UploadError::Reqwest)
|
.json::<RobloxUploadResponse>().await.map_err(UploadError::Reqwest)?;
|
||||||
|
|
||||||
|
Ok(UploadResponse{
|
||||||
|
AssetId:asset_id,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
||||||
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;
|
let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user