rbx_asset: cloud: tweak asset info requests, remove get_asset
This commit is contained in:
parent
fb9dd8660d
commit
71cae5c089
@ -119,7 +119,7 @@ impl std::error::Error for UpdateError{}
|
||||
struct GetAssetOperationRequest{
|
||||
operation_id:String,
|
||||
}
|
||||
pub struct GetAssetInfoRequest{
|
||||
pub struct GetAssetLatestRequest{
|
||||
pub asset_id:u64,
|
||||
}
|
||||
/*
|
||||
@ -164,11 +164,6 @@ pub struct GetAssetVersionRequest{
|
||||
pub asset_id:u64,
|
||||
pub version:u64,
|
||||
}
|
||||
#[allow(nonstandard_style,dead_code)]
|
||||
pub struct GetAssetRequest{
|
||||
pub asset_id:u64,
|
||||
pub version:Option<u64>,
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub enum GetError{
|
||||
ParseError(url::ParseError),
|
||||
@ -394,7 +389,7 @@ impl Context{
|
||||
).await.map_err(GetError::Response)?
|
||||
.json::<RobloxOperation>().await.map_err(GetError::Reqwest)
|
||||
}
|
||||
pub async fn get_asset_info(&self,config:GetAssetInfoRequest)->Result<AssetResponse,GetError>{
|
||||
pub async fn get_asset_info(&self,config:GetAssetLatestRequest)->Result<AssetResponse,GetError>{
|
||||
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}",config.asset_id);
|
||||
let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?;
|
||||
|
||||
@ -403,30 +398,14 @@ impl Context{
|
||||
).await.map_err(GetError::Response)?
|
||||
.json::<AssetResponse>().await.map_err(GetError::Reqwest)
|
||||
}
|
||||
pub async fn get_asset_version(&self,config:GetAssetVersionRequest)->Result<Vec<u8>,GetError>{
|
||||
pub async fn get_asset_version_info(&self,config:GetAssetVersionRequest)->Result<AssetResponse,GetError>{
|
||||
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions/{}",config.asset_id,config.version);
|
||||
let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?;
|
||||
|
||||
let body=crate::response_ok(
|
||||
crate::response_ok(
|
||||
self.get(url).await.map_err(GetError::Reqwest)?
|
||||
).await.map_err(GetError::Response)?
|
||||
.bytes().await.map_err(GetError::Reqwest)?;
|
||||
|
||||
match maybe_gzip_decode(&mut std::io::Cursor::new(body)){
|
||||
Ok(ReaderType::GZip(readable))=>read_readable(readable),
|
||||
Ok(ReaderType::Raw(readable))=>read_readable(readable),
|
||||
Err(e)=>Err(e),
|
||||
}.map_err(GetError::IO)
|
||||
}
|
||||
pub async fn get_asset(&self,config:GetAssetRequest)->Result<Vec<u8>,GetError>{
|
||||
let version=match config.version{
|
||||
Some(version)=>version,
|
||||
None=>self.get_asset_info(GetAssetInfoRequest{asset_id:config.asset_id}).await?.revisionId.parse().unwrap(),
|
||||
};
|
||||
self.get_asset_version(GetAssetVersionRequest{
|
||||
asset_id:config.asset_id,
|
||||
version,
|
||||
}).await
|
||||
.json::<AssetResponse>().await.map_err(GetError::Reqwest)
|
||||
}
|
||||
pub async fn get_asset_versions(&self,config:AssetVersionsRequest)->Result<AssetVersionsResponse,AssetVersionsError>{
|
||||
let raw_url=format!("https://apis.roblox.com/assets/v1/assets/{}/versions",config.asset_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user