diff --git a/rbx_asset/src/cloud.rs b/rbx_asset/src/cloud.rs index f65c7aa..0016b97 100644 --- a/rbx_asset/src/cloud.rs +++ b/rbx_asset/src/cloud.rs @@ -178,22 +178,28 @@ impl std::fmt::Display for GetError{ } impl std::error::Error for GetError{} +#[derive(Debug,serde::Deserialize,serde::Serialize)] +pub struct AssetLocation( + // the location is private so users cannot mutate it + String +); +impl AssetLocation{ + pub fn location(&self)->&str{ + let Self(location)=self; + location + } +} + #[derive(Debug,serde::Deserialize)] #[allow(nonstandard_style,dead_code)] -pub struct AssetLocation{ - // this field is private so users cannot mutate it - location:String, +pub struct AssetLocationInfo{ + pub location:Option<AssetLocation>, pub requestId:String, pub IsHashDynamic:bool, pub IsCopyrightProtected:bool, pub isArchived:bool, pub assetTypeId:u32, } -impl AssetLocation{ - pub fn location(&self)->&str{ - &self.location - } -} pub struct AssetVersionsRequest{ pub asset_id:u64, @@ -424,7 +430,7 @@ impl Context{ ).await.map_err(GetError::Response)? .json::<AssetResponse>().await.map_err(GetError::Reqwest) } - pub async fn get_asset_location(&self,config:GetAssetLatestRequest)->Result<AssetLocation,GetError>{ + pub async fn get_asset_location(&self,config:GetAssetLatestRequest)->Result<AssetLocationInfo,GetError>{ let raw_url=format!("https://apis.roblox.com/asset-delivery-api/v1/assetId/{}",config.asset_id); let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?; @@ -433,7 +439,7 @@ impl Context{ ).await.map_err(GetError::Response)? .json().await.map_err(GetError::Reqwest) } - pub async fn get_asset_version_location(&self,config:GetAssetVersionRequest)->Result<AssetLocation,GetError>{ + pub async fn get_asset_version_location(&self,config:GetAssetVersionRequest)->Result<AssetLocationInfo,GetError>{ let raw_url=format!("https://apis.roblox.com/asset-delivery-api/v1/assetId/{}/version/{}",config.asset_id,config.version); let url=reqwest::Url::parse(raw_url.as_str()).map_err(GetError::ParseError)?; @@ -443,7 +449,7 @@ impl Context{ .json().await.map_err(GetError::Reqwest) } pub async fn get_asset(&self,config:&AssetLocation)->Result<Vec<u8>,GetError>{ - let url=reqwest::Url::parse(config.location.as_str()).map_err(GetError::ParseError)?; + let url=reqwest::Url::parse(config.location()).map_err(GetError::ParseError)?; let body=crate::response_ok( self.get(url).await.map_err(GetError::Reqwest)?