nuget_client/ops/
package_base_address.rs1use serde::Deserialize;
2use serde::Serialize;
3
4#[derive(Debug, Deserialize, Clone, Serialize)]
5pub struct PackageBaseAddressResponse {
6 pub versions: Vec<String>,
7}
8
9pub async fn execute(nuget: &crate::NugetRegistry, package_name: &str) -> crate::Result<Option<PackageBaseAddressResponse>> {
10 let url = nuget.resource("PackageBaseAddress/3.0.0")?;
11 let mut extension = format!("{}/index.json", package_name);
12 extension.make_ascii_lowercase();
13
14 let url = url.join(&extension)?;
15
16 let request = nuget.client.get(url).send().await?;
17 if request.status() == 404 {
18 return Ok(None);
19 }
20 request.error_for_status_ref()?;
21
22 let response = request.bytes().await?;
23 let response : PackageBaseAddressResponse = serde_json::from_slice(&response)?;
24
25 Ok(Some(response))
26}