pub struct Fetcher {
pub host: Host,
pub provider_scope: String,
/* private fields */
}
Fields§
§host: Host
The host url (defaults to https://jsr.io
)
provider_scope: String
The jsr provider scope on npm-side. Defaults to jsr
NOTE: This is DIFFERENT than normal package scope
See https://jsr.io/docs/api#npm-compatibility-registry-api
Implementations§
Source§impl Fetcher
impl Fetcher
Sourcepub fn new(builder: FetcherBuilder) -> Self
pub fn new(builder: FetcherBuilder) -> Self
Creates a new Fetcher
§Panics
See the docs for reqwest::Client::new. You can prevent this by setting your own reqwest Client in FetcherBuilder
Sourcepub async fn get_meta(
&self,
value: impl AsRef<MetaBuilder>,
) -> Result<Option<Meta>>
pub async fn get_meta( &self, value: impl AsRef<MetaBuilder>, ) -> Result<Option<Meta>>
Get package metadata, contains version details, and more
Returns Ok(None)
if the server returned 404
.
If the other failed status code returned, Err
will be returned.
Else, Ok(Some(Meta))
returned normally as success
See https://jsr.io/docs/api#package-version
§Errors
Throws reqwest::Error or serde_json::Error
Sourcepub async fn get_metas<T: AsRef<MetaBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>(
&self,
values: U,
) -> Result<Vec<Meta>>
pub async fn get_metas<T: AsRef<MetaBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>( &self, values: U, ) -> Result<Vec<Meta>>
Get metadatas from packages, contains version details, and more
See https://jsr.io/docs/api#package-version
§Errors
Throws reqwest::Error or serde_json::Error
Sourcepub async fn get_package(
&self,
value: impl AsRef<PackageBuilder>,
) -> Result<Option<Package>>
pub async fn get_package( &self, value: impl AsRef<PackageBuilder>, ) -> Result<Option<Package>>
Get package with specific version on it.
Returns Ok(None)
if the server returned 404
.
If the other failed status code returned, Err
will be returned.
Else, Ok(Some(Package))
returned normally as success
See https://jsr.io/docs/api#package-version-metadata
To get the list of versions, use Fetcher::get_meta
§Errors
Throws reqwest::Error or serde_json::Error
Sourcepub async fn get_packages<T: AsRef<PackageBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>(
&self,
values: U,
) -> Result<Vec<Package>>
pub async fn get_packages<T: AsRef<PackageBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>( &self, values: U, ) -> Result<Vec<Package>>
Get each packages with specific version on it
See https://jsr.io/docs/api#package-version-metadata
§Errors
Throws reqwest::Error or serde_json::Error
Sourcepub async fn get_npm_comp_meta(
&self,
value: impl AsRef<MetaBuilder>,
) -> Result<Option<NpmCompMeta>>
pub async fn get_npm_comp_meta( &self, value: impl AsRef<MetaBuilder>, ) -> Result<Option<NpmCompMeta>>
Get JSR-to-npm package meta
The difference for Meta other than the compability, is that you dont need to fetch again for specific version. You just need to get from NpmCompMeta::versions, and then the result will show up
Returns Ok(None)
if the server returned 404
.
If the other failed status code returned, Err
will be returned.
Else, Ok(Some(NpmCompMeta))
returned normally as success
See https://jsr.io/docs/api#package-version-metadata
§Errors
Throws reqwest::Error or serde_json::Error
Sourcepub async fn get_npm_comp_metas<T: AsRef<MetaBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>(
&self,
values: U,
) -> Result<Vec<NpmCompMeta>>
pub async fn get_npm_comp_metas<T: AsRef<MetaBuilder>, U: IntoIterator<Item = T> + ExactSizeIterator>( &self, values: U, ) -> Result<Vec<NpmCompMeta>>
Get JSR-to-npm package metas
The difference for Meta other than the compability, is that you dont need to fetch again for specific version. You just need to get NpmCompMeta::versions from one of them, and then the result will show up
See https://jsr.io/docs/api#package-version-metadata
§Errors
Throws reqwest::Error or serde_json::Error
Trait Implementations§
Source§impl Default for Fetcher
impl Default for Fetcher
Source§fn default() -> Self
fn default() -> Self
Creates a new fetcher with default configuration
§Panics
See the docs for reqwest::Client::new. You can prevent this by making your own FetcherBuilder and set the reqwest Client to Self::new