pub struct OfflineRegistry { /* private fields */ }Expand description
An in-memory registry pre-populated with static package data.
Useful for testing, offline scenarios, or mirroring the public Thunderstore
index. Every package and its versions are loaded up-front and stored in a
HashMap keyed by PackageId.
§Examples
use std::collections::HashMap;
use loadsmith_registry::{OfflineRegistry, Package, PackageVersion, Registry};
use loadsmith_core::{PackageId, Version, FileUrl, PackageRef};
let pkg = Package::new(
PackageId::new("author-name"),
vec![PackageVersion::new(
Version::new(1, 0, 0),
FileUrl::try_from_url("https://example.com/pkg.zip").unwrap(),
)],
);
let mut packages = HashMap::new();
packages.insert(PackageId::new("author-name"), pkg);
let registry = OfflineRegistry::new(packages);
// List versions.
let versions = registry
.version_info(&PackageId::new("author-name"), None)
.await
.unwrap();
assert_eq!(versions.len(), 1);
// Resolve a specific version.
let ref_ = PackageRef::new("author-name", Version::new(1, 0, 0));
let resolved = registry.resolve(&ref_, None).await.unwrap();
assert!(resolved.url.to_string().contains("example.com"));Implementations§
Trait Implementations§
Source§impl Clone for OfflineRegistry
impl Clone for OfflineRegistry
Source§fn clone(&self) -> OfflineRegistry
fn clone(&self) -> OfflineRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OfflineRegistry
impl Debug for OfflineRegistry
Source§impl Default for OfflineRegistry
impl Default for OfflineRegistry
Source§fn default() -> OfflineRegistry
fn default() -> OfflineRegistry
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OfflineRegistry
impl<'de> Deserialize<'de> for OfflineRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Registry for OfflineRegistry
impl Registry for OfflineRegistry
Source§fn version_info<'a>(
&'a self,
id: &'a PackageId,
_metadata: Option<&'a Value>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VersionInfo>>> + 'a>>
fn version_info<'a>( &'a self, id: &'a PackageId, _metadata: Option<&'a Value>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VersionInfo>>> + 'a>>
List all available versions of the package identified by
id. Read moreSource§fn resolve<'a>(
&'a self,
ref_: &'a PackageRef,
_metadata: Option<&'a Value>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedVersion>> + 'a>>
fn resolve<'a>( &'a self, ref_: &'a PackageRef, _metadata: Option<&'a Value>, ) -> Pin<Box<dyn Future<Output = Result<ResolvedVersion>> + 'a>>
Resolve a package reference into concrete download information. Read more
Source§fn revalidate_checksum<'a>(
&'a self,
ref_: &'a PackageRef,
metadata: Option<&'a Value>,
) -> Result<Option<Checksum>>
fn revalidate_checksum<'a>( &'a self, ref_: &'a PackageRef, metadata: Option<&'a Value>, ) -> Result<Option<Checksum>>
Re-compute and return the checksum for the package identified by
ref_,
or return None if the registry does not support checksum revalidation. Read moreAuto Trait Implementations§
impl Freeze for OfflineRegistry
impl RefUnwindSafe for OfflineRegistry
impl Send for OfflineRegistry
impl Sync for OfflineRegistry
impl Unpin for OfflineRegistry
impl UnsafeUnpin for OfflineRegistry
impl UnwindSafe for OfflineRegistry
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
Mutably borrows from an owned value. Read more