pub struct Client<R, C, N>{ /* private fields */ }
Expand description
A client for a Warg registry.
Implementations§
Source§impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C, N>
impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C, N>
Sourcepub fn new(
url: impl IntoUrl,
registry: R,
content: C,
namespace_map: N,
auth_token: Option<Secret<String>>,
ignore_federation_hints: bool,
disable_auto_accept_federation_hints: bool,
disable_auto_package_init: bool,
disable_interactive: bool,
keyring_backend: Option<String>,
keys: IndexSet<String>,
) -> ClientResult<Self>
pub fn new( url: impl IntoUrl, registry: R, content: C, namespace_map: N, auth_token: Option<Secret<String>>, ignore_federation_hints: bool, disable_auto_accept_federation_hints: bool, disable_auto_package_init: bool, disable_interactive: bool, keyring_backend: Option<String>, keys: IndexSet<String>, ) -> ClientResult<Self>
Creates a new client for the given URL, registry storage, and content storage.
Sourcepub fn url(&self) -> &RegistryUrl
pub fn url(&self) -> &RegistryUrl
Gets the URL of the client.
Sourcepub fn namespace_map(&self) -> &N
pub fn namespace_map(&self) -> &N
Gets the namespace map
Sourcepub async fn get_warg_registry(
&self,
namespace: &str,
) -> Result<Option<RegistryDomain>, ClientError>
pub async fn get_warg_registry( &self, namespace: &str, ) -> Result<Option<RegistryDomain>, ClientError>
Get warg registry domain.
Sourcepub async fn store_namespace(
&self,
namespace: String,
registry_domain: RegistryDomain,
) -> Result<()>
pub async fn store_namespace( &self, namespace: String, registry_domain: RegistryDomain, ) -> Result<()>
Stores namespace mapping in local storage
Sourcepub async fn reset_namespaces(&self) -> Result<()>
pub async fn reset_namespaces(&self) -> Result<()>
Resets the namespace map
Sourcepub async fn reset_registry(&self) -> ClientResult<()>
pub async fn reset_registry(&self) -> ClientResult<()>
Reset client storage for the registry.
Sourcepub async fn clear_content_cache(&self) -> ClientResult<()>
pub async fn clear_content_cache(&self) -> ClientResult<()>
Clear client content cache.
Sourcepub async fn lock_component(&self, info: &PackageInfo) -> ClientResult<Vec<u8>>
pub async fn lock_component(&self, info: &PackageInfo) -> ClientResult<Vec<u8>>
Locks component
Sourcepub async fn bundle_component(
&self,
info: &PackageInfo,
) -> ClientResult<Vec<u8>>
pub async fn bundle_component( &self, info: &PackageInfo, ) -> ClientResult<Vec<u8>>
Bundles component
Sourcepub async fn publish(&self, signing_key: &PrivateKey) -> ClientResult<RecordId>
pub async fn publish(&self, signing_key: &PrivateKey) -> ClientResult<RecordId>
Submits the publish information in client storage.
If there’s no publishing information in client storage, an error is returned.
Returns the identifier of the record that was published.
Use wait_for_publish
to wait for the record to transition to the published
state.
Sourcepub async fn sign_with_keyring_and_publish(
&self,
publish_info: Option<PublishInfo>,
) -> ClientResult<RecordId>
pub async fn sign_with_keyring_and_publish( &self, publish_info: Option<PublishInfo>, ) -> ClientResult<RecordId>
Submits the provided publish information or, if not provided, loads from client storage. Uses the keyring to retrieve a key and sign.
If there’s no publishing information in client storage, an error is returned.
Returns the identifier of the record that was published.
Use wait_for_publish
to wait for the record to transition to the published
state.
Sourcepub async fn publish_with_info(
&self,
signing_key: &PrivateKey,
publish_info: PublishInfo,
) -> ClientResult<RecordId>
pub async fn publish_with_info( &self, signing_key: &PrivateKey, publish_info: PublishInfo, ) -> ClientResult<RecordId>
Submits the provided publish information.
Any publish information in client storage is ignored.
Returns the identifier of the record that was published.
Use wait_for_publish
to wait for the record to transition to the published
state.
Sourcepub async fn wait_for_publish(
&self,
package: &PackageName,
record_id: &RecordId,
interval: Duration,
) -> ClientResult<()>
pub async fn wait_for_publish( &self, package: &PackageName, record_id: &RecordId, interval: Duration, ) -> ClientResult<()>
Waits for a package record to transition to the published
state.
The interval
is the amount of time to wait between checks.
Returns an error if the package record was rejected.
Sourcepub async fn update(&self) -> ClientResult<()>
pub async fn update(&self) -> ClientResult<()>
Updates all package logs in client registry storage to the latest registry checkpoint.
Sourcepub async fn download(
&self,
package: &PackageName,
requirement: &VersionReq,
) -> Result<Option<PackageDownload>, ClientError>
pub async fn download( &self, package: &PackageName, requirement: &VersionReq, ) -> Result<Option<PackageDownload>, ClientError>
Downloads the latest version of a package into client storage that satisfies the given version requirement.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package does not exist.
If a version satisfying the requirement does not exist, None
is
returned.
Returns the path within client storage of the package contents for the resolved version.
Sourcepub async fn download_as_stream(
&self,
package: &PackageName,
requirement: &VersionReq,
) -> Result<Option<(PackageDownloadInfo, impl Stream<Item = Result<Bytes>>)>, ClientError>
pub async fn download_as_stream( &self, package: &PackageName, requirement: &VersionReq, ) -> Result<Option<(PackageDownloadInfo, impl Stream<Item = Result<Bytes>>)>, ClientError>
Downloads the latest version of a package.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package does not exist.
If a version satisfying the requirement does not exist, None
is
returned.
Sourcepub async fn download_exact(
&self,
package: &PackageName,
version: &Version,
) -> Result<PackageDownload, ClientError>
pub async fn download_exact( &self, package: &PackageName, version: &Version, ) -> Result<PackageDownload, ClientError>
Downloads the specified version of a package into client storage.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package or version does not exist.
Returns the path within client storage of the package contents for the specified version.
Sourcepub async fn download_exact_as_stream(
&self,
package: &PackageName,
version: &Version,
) -> Result<(PackageDownloadInfo, impl Stream<Item = Result<Bytes>>), ClientError>
pub async fn download_exact_as_stream( &self, package: &PackageName, version: &Version, ) -> Result<(PackageDownloadInfo, impl Stream<Item = Result<Bytes>>), ClientError>
Downloads the specified version of a package.
If the requested package log is not present in client storage, it will be fetched from the registry first.
An error is returned if the package or version does not exist.
Sourcepub async fn fetch_packages(
&self,
names: impl IntoIterator<Item = &PackageName>,
) -> Result<Vec<PackageInfo>, ClientError>
pub async fn fetch_packages( &self, names: impl IntoIterator<Item = &PackageName>, ) -> Result<Vec<PackageInfo>, ClientError>
Fetches package logs without checking local storage first.
Sourcepub async fn fetch_package(
&self,
name: &PackageName,
) -> Result<PackageInfo, ClientError>
pub async fn fetch_package( &self, name: &PackageName, ) -> Result<PackageInfo, ClientError>
Fetches the PackageInfo
without checking local storage first.
Sourcepub async fn package(
&self,
name: &PackageName,
) -> Result<PackageInfo, ClientError>
pub async fn package( &self, name: &PackageName, ) -> Result<PackageInfo, ClientError>
Retrieves the PackageInfo
from local storage, if present, otherwise fetches from the
registry.
Source§impl Client<FileSystemRegistryStorage, FileSystemContentStorage, FileSystemNamespaceMapStorage>
impl Client<FileSystemRegistryStorage, FileSystemContentStorage, FileSystemNamespaceMapStorage>
Sourcepub async fn try_new_with_config(
registry: Option<&str>,
config: &Config,
auth_token: Option<Secret<String>>,
) -> Result<StorageLockResult<Self>, ClientError>
pub async fn try_new_with_config( registry: Option<&str>, config: &Config, auth_token: Option<Secret<String>>, ) -> Result<StorageLockResult<Self>, ClientError>
Attempts to create a client for the given registry URL.
If the URL is None
, the home registry URL is used; if there is no home registry
URL, an error is returned.
If a lock cannot be acquired for a storage directory, then
NewClientResult::Blocked
is returned with the path to the
directory that could not be locked.
Sourcepub async fn try_new_with_default_config(
url: Option<&str>,
) -> Result<StorageLockResult<Self>, ClientError>
pub async fn try_new_with_default_config( url: Option<&str>, ) -> Result<StorageLockResult<Self>, ClientError>
Attempts to create a client for the given registry URL.
If the URL is None
, the home registry URL is used; if there is no home registry
URL, an error is returned.
If a lock cannot be acquired for a storage directory, then
NewClientResult::Blocked
is returned with the path to the
directory that could not be locked.
Same as calling try_new_with_config
with
Config::from_default_file()?.unwrap_or_default()
.
Sourcepub async fn new_with_config(
registry: Option<&str>,
config: &Config,
auth_token: Option<Secret<String>>,
) -> Result<Self, ClientError>
pub async fn new_with_config( registry: Option<&str>, config: &Config, auth_token: Option<Secret<String>>, ) -> Result<Self, ClientError>
Creates a client for the given registry URL.
If the URL is None
, the home registry URL is used; if there is no home registry
URL, an error is returned.
This method blocks if storage locks cannot be acquired.
Sourcepub async fn new_with_default_config(
url: Option<&str>,
) -> Result<Self, ClientError>
pub async fn new_with_default_config( url: Option<&str>, ) -> Result<Self, ClientError>
Creates a client for the given registry URL.
If the URL is None
, the home registry URL is used; if there is no home registry
URL, an error is returned.
This method blocks if storage locks cannot be acquired.
Same as calling new_with_config
with
Config::from_default_file()?.unwrap_or_default()
.
Auto Trait Implementations§
impl<R, C, N> Freeze for Client<R, C, N>
impl<R, C, N> !RefUnwindSafe for Client<R, C, N>
impl<R, C, N> Send for Client<R, C, N>
impl<R, C, N> Sync for Client<R, C, N>
impl<R, C, N> Unpin for Client<R, C, N>
impl<R, C, N> !UnwindSafe for Client<R, C, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more