#[allow(dead_code)]
#[derive(Debug)]
pub enum Error{
	ModelLocationDownload(rbx_asset::cloud::GetError),
	NonFreeModel,
	ModelFileDownload(rbx_asset::cloud::GetError),
}
impl std::fmt::Display for Error{
	fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
		write!(f,"{self:?}")
	}
}
impl std::error::Error for Error{}

pub async fn download_asset_version(cloud_context:&rbx_asset::cloud::Context,request:rbx_asset::cloud::GetAssetVersionRequest)->Result<rbx_asset::types::MaybeGzippedBytes,Error>{
	// download the location of the map model
	let location=cloud_context.get_asset_version_location(request).await.map_err(Error::ModelLocationDownload)?;

	// if the location does not exist, you are not allowed to download it
	let location=location.location.ok_or(Error::NonFreeModel)?;

	// download the map model
	let maybe_gzip=cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;

	Ok(maybe_gzip)
}