pub struct PackageVersion {
pub version: Version,
pub url: FileUrl,
pub size: Option<u64>,
pub checksum: Option<Checksum>,
pub deps: Vec<Dependency>,
}Expand description
A single version entry inside an OfflineRegistry package.
Includes the download URL, optional size and checksum, and the dependency
list. Builder methods (with_size,
with_checksum,
with_deps) are provided for ergonomic
construction.
§Examples
use loadsmith_registry::PackageVersion;
use loadsmith_core::{Version, FileUrl, Dependency, VersionReq};
let dep = Dependency::new("other-mod", VersionReq::STAR, "thunderstore");
let pv = PackageVersion::new(
Version::new(1, 0, 0),
FileUrl::try_from_url("https://example.com/pkg.zip").unwrap(),
)
.with_size(4096)
.with_deps(vec![dep]);
assert_eq!(pv.version.to_string(), "1.0.0");
assert_eq!(pv.size, Some(4096));
assert_eq!(pv.deps.len(), 1);Fields§
§version: Version§url: FileUrl§size: Option<u64>§checksum: Option<Checksum>§deps: Vec<Dependency>Implementations§
Source§impl PackageVersion
impl PackageVersion
Sourcepub fn new(
version: impl Into<Version>,
download_url: impl Into<FileUrl>,
) -> Self
pub fn new( version: impl Into<Version>, download_url: impl Into<FileUrl>, ) -> Self
Create a new version entry with a version number and download URL.
Optional fields (size, checksum, deps) are initialised to None
or an empty vector. Use the builder methods to populate them.
Sourcepub fn with_checksum(self, checksum: impl Into<Checksum>) -> Self
pub fn with_checksum(self, checksum: impl Into<Checksum>) -> Self
Set the cryptographic checksum.
Sourcepub fn with_deps(self, deps: Vec<Dependency>) -> Self
pub fn with_deps(self, deps: Vec<Dependency>) -> Self
Replace the dependency list.
Trait Implementations§
Source§impl Clone for PackageVersion
impl Clone for PackageVersion
Source§fn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
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 PackageVersion
impl Debug for PackageVersion
Source§impl<'de> Deserialize<'de> for PackageVersion
impl<'de> Deserialize<'de> for PackageVersion
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
Auto Trait Implementations§
impl Freeze for PackageVersion
impl RefUnwindSafe for PackageVersion
impl Send for PackageVersion
impl Sync for PackageVersion
impl Unpin for PackageVersion
impl UnsafeUnpin for PackageVersion
impl UnwindSafe for PackageVersion
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