pub struct VersionIdent { /* private fields */ }Expand description
A unique identifier for a package version, formatted as namespace-name-version.
This struct can be created in a number of ways:
use thunderstore::VersionIdent;
let a = VersionIdent::new("BepInEx", "BepInExPack", "5.4.2100");
let b: VersionIdent = "BepInEx-BepInExPack-5.4.2100".parse().unwrap();
let c: VersionIdent = ("BepInEx", "BepInExPack", "5.4.2100").into();Methods on crate::Client accept any type that implements IntoVersionIdent,
which allows any of the above methods to be used interchangeably.
The underlying string is either an owned String or a string literal (&'static str).
Implementations§
Source§impl VersionIdent
impl VersionIdent
Sourcepub fn new(
namespace: impl AsRef<str>,
name: impl AsRef<str>,
version: impl AsRef<str>,
) -> Self
pub fn new( namespace: impl AsRef<str>, name: impl AsRef<str>, version: impl AsRef<str>, ) -> Self
Creates a new VersionIdent.
This copies the arguments into a newly allocated String, delimited by -.
§Examples
use thunderstore::VersionIdent;
let ident = VersionIdent::new("BepInEx", "BepInExPack", "5.4.2100");
assert_eq!(ident.into_string(), "BepInEx-BepInExPack-5.4.2100");Sourcepub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
The namespace/owner of the package.
§Examples
use thunderstore::VersionIdent;
let ident: VersionIdent = "BepInEx-BepInExPack-5.4.2100".parse().unwrap();
assert_eq!(ident.namespace(), "BepInEx");Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
The name of the package.
§Examples
use thunderstore::VersionIdent;
let ident: VersionIdent = "BepInEx-BepInExPack-5.4.2100".parse().unwrap();
assert_eq!(ident.name(), "BepInExPack");Sourcepub fn version(&self) -> &str
pub fn version(&self) -> &str
The version number of the package.
§Examples
use thunderstore::VersionIdent;
let ident: VersionIdent = "BepInEx-BepInExPack-5.4.2100".parse().unwrap();
assert_eq!(ident.version(), "5.4.2100");Sourcepub fn parsed_version(&self) -> Version
pub fn parsed_version(&self) -> Version
The version number of the package as a semver::Version
§Examples
use thunderstore::VersionIdent;
let ident: VersionIdent = "BepInEx-BepInExPack-5.4.2100".parse().unwrap();
let version = ident.parsed_version();
assert_eq!(version.major, 5);
assert_eq!(version.minor, 4);
assert_eq!(version.patch, 2100);Sourcepub fn path(&self) -> impl Display + '_
pub fn path(&self) -> impl Display + '_
Returns an object that, when formatted with {}, will produce the URL path for this version.
§Example
use thunderstore::VersionIdent;
let id = VersionIdent::new("BepInEx", "BepInExPack", "5.4.2100");
assert_eq!(id.path().to_string(), "BepInEx/BepInExPack/5.4.2100");Sourcepub fn into_cow(self) -> Cow<'static, str>
pub fn into_cow(self) -> Cow<'static, str>
Unwraps the underlying string, formatted as namespace-name-version.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Unwraps the underlying string, formatted as namespace-name-version.
If the string is a 'static str, it is converted to an owned String. If you don’t want
that, see VersionIdent::into_cow.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns a reference to the underlying string, formatted as namespace-name-version.
Sourcepub fn package_id(&self) -> PackageIdent
pub fn package_id(&self) -> PackageIdent
Returns a copy of the identifier with the version removed.
Trait Implementations§
Source§impl AsRef<str> for VersionIdent
impl AsRef<str> for VersionIdent
Source§impl Clone for VersionIdent
impl Clone for VersionIdent
Source§fn clone(&self) -> VersionIdent
fn clone(&self) -> VersionIdent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VersionIdent
impl Debug for VersionIdent
Source§impl<'de> Deserialize<'de> for VersionIdent
impl<'de> Deserialize<'de> for VersionIdent
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>,
Source§impl Display for VersionIdent
impl Display for VersionIdent
Source§impl From<&VersionIdent> for PackageIdent
impl From<&VersionIdent> for PackageIdent
Source§fn from(id: &VersionIdent) -> Self
fn from(id: &VersionIdent) -> Self
Source§impl<T, U, V> From<(T, U, V)> for VersionIdent
impl<T, U, V> From<(T, U, V)> for VersionIdent
Source§impl From<VersionIdent> for Cow<'static, str>
impl From<VersionIdent> for Cow<'static, str>
Source§fn from(id: VersionIdent) -> Self
fn from(id: VersionIdent) -> Self
Source§impl From<VersionIdent> for String
impl From<VersionIdent> for String
Source§fn from(id: VersionIdent) -> Self
fn from(id: VersionIdent) -> Self
Source§impl FromStr for VersionIdent
impl FromStr for VersionIdent
Source§impl Hash for VersionIdent
impl Hash for VersionIdent
Source§impl<'a> IntoVersionIdent<'a> for &'a VersionIdent
impl<'a> IntoVersionIdent<'a> for &'a VersionIdent
Source§impl Ord for VersionIdent
impl Ord for VersionIdent
Source§impl PartialEq for VersionIdent
impl PartialEq for VersionIdent
Source§impl PartialOrd for VersionIdent
impl PartialOrd for VersionIdent
Source§impl Serialize for VersionIdent
impl Serialize for VersionIdent
Source§impl TryFrom<&'static str> for VersionIdent
impl TryFrom<&'static str> for VersionIdent
Source§impl TryFrom<String> for VersionIdent
impl TryFrom<String> for VersionIdent
impl Eq for VersionIdent
Auto Trait Implementations§
impl Freeze for VersionIdent
impl RefUnwindSafe for VersionIdent
impl Send for VersionIdent
impl Sync for VersionIdent
impl Unpin for VersionIdent
impl UnwindSafe for VersionIdent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.