diff --git a/rbx_asset/src/cookie.rs b/rbx_asset/src/cookie.rs index b58c684..b4921bf 100644 --- a/rbx_asset/src/cookie.rs +++ b/rbx_asset/src/cookie.rs @@ -103,16 +103,16 @@ pub struct AssetVersionsPageResponse{ pub data:Vec, } #[derive(Debug)] -pub enum AssetVersionsPageError{ +pub enum PageError{ ParseError(url::ParseError), Reqwest(reqwest::Error), } -impl std::fmt::Display for AssetVersionsPageError{ +impl std::fmt::Display for PageError{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f,"{self:?}") } } -impl std::error::Error for AssetVersionsPageError{} +impl std::error::Error for PageError{} pub enum Owner{ User(u64), @@ -149,17 +149,6 @@ pub struct CreationsPageResponse{ pub nextPageCursor:Option, pub data:Vec, } -#[derive(Debug)] -pub enum CreationsPageError{ - ParseError(url::ParseError), - Reqwest(reqwest::Error), -} -impl std::fmt::Display for CreationsPageError{ - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f,"{self:?}") - } -} -impl std::error::Error for CreationsPageError{} //idk how to do this better enum ReaderType{ @@ -300,8 +289,8 @@ impl CookieContext{ Err(e)=>Err(e), }.map_err(GetError::IO) } - pub async fn get_asset_versions_page(&self,config:AssetVersionsPageRequest)->Result{ - let mut url=reqwest::Url::parse(format!("https://develop.roblox.com/v1/assets/{}/saved-versions",config.asset_id).as_str()).map_err(AssetVersionsPageError::ParseError)?; + pub async fn get_asset_versions_page(&self,config:AssetVersionsPageRequest)->Result{ + let mut url=reqwest::Url::parse(format!("https://develop.roblox.com/v1/assets/{}/saved-versions",config.asset_id).as_str()).map_err(PageError::ParseError)?; //url borrow scope { let mut query=url.query_pairs_mut();//borrow here @@ -313,13 +302,13 @@ impl CookieContext{ } } - self.get(url).await.map_err(AssetVersionsPageError::Reqwest)? - .error_for_status().map_err(AssetVersionsPageError::Reqwest)? - .json::().await.map_err(AssetVersionsPageError::Reqwest) + self.get(url).await.map_err(PageError::Reqwest)? + .error_for_status().map_err(PageError::Reqwest)? + .json::().await.map_err(PageError::Reqwest) } - pub async fn get_creations_page(&self,config:&CreationsPageRequest)->Result{ + pub async fn get_creations_page(&self,config:&CreationsPageRequest)->Result{ let (owner,id)=config.owner.get_url_info(); - let mut url=reqwest::Url::parse(format!("https://apis.roblox.com/toolbox-service/v1/creations/{}/{}/10?limit=50",owner,id).as_str()).map_err(CreationsPageError::ParseError)?; + let mut url=reqwest::Url::parse(format!("https://apis.roblox.com/toolbox-service/v1/creations/{}/{}/10?limit=50",owner,id).as_str()).map_err(PageError::ParseError)?; //url borrow scope { let mut query=url.query_pairs_mut();//borrow here @@ -328,8 +317,8 @@ impl CookieContext{ } } - self.get(url).await.map_err(CreationsPageError::Reqwest)? - .error_for_status().map_err(CreationsPageError::Reqwest)? - .json::().await.map_err(CreationsPageError::Reqwest) + self.get(url).await.map_err(PageError::Reqwest)? + .error_for_status().map_err(PageError::Reqwest)? + .json::().await.map_err(PageError::Reqwest) } }