pub struct PackageIdent { /* private fields */ }
Expand description
A unique identifier for a package, formatted as namespace-name
.
This struct can be created in a number of ways:
use thunderstore::PackageIdent;
let a = PackageIdent::new("BepInEx", "BepInExPack");
let b: PackageIdent = "BepInEx-BepInExPack".parse().unwrap();
let c: PackageIdent = ("BepInEx", "BepInExPack").into();
Methods on crate::Client
accept any type that implements IntoPackageIdent
,
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 PackageIdent
impl PackageIdent
Sourcepub fn new(namespace: impl AsRef<str>, name: impl AsRef<str>) -> Self
pub fn new(namespace: impl AsRef<str>, name: impl AsRef<str>) -> Self
Creates a new PackageIdent
.
This copies the arguments into a newly allocated String
, delimited by -
.
§Examples
use thunderstore::PackageIdent;
let ident = PackageIdent::new("BepInEx", "BepInExPack");
assert_eq!(ident.into_string(), "BepInEx-BepInExPack");
Sourcepub fn namespace(&self) -> &str
pub fn namespace(&self) -> &str
The namespace/owner of the package.
§Examples
use thunderstore::PackageIdent;
let ident: PackageIdent = "BepInEx-BepInExPack".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::PackageIdent;
let ident: PackageIdent = "BepInEx-BepInExPack".parse().unwrap();
assert_eq!(ident.name(), "BepInExPack");
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 package.
§Examples
use thunderstore::PackageIdent;
let ident = PackageIdent::new("BepInEx", "BepInExPack");
assert_eq!(ident.path().to_string(), "BepInEx/BepInExPack");
Sourcepub fn into_cow(self) -> Cow<'static, str>
pub fn into_cow(self) -> Cow<'static, str>
Unwraps the underlying string, formatted as namespace-name
.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Unwraps the underlying string, formatted as namespace-name
.
If the string is a 'static str
, it is converted to an owned String
. If you don’t want
that, see PackageIdent::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
.
Sourcepub fn with_version(&self, version: impl AsRef<str>) -> VersionIdent
pub fn with_version(&self, version: impl AsRef<str>) -> VersionIdent
Creates a copy of the identifier with a specific version.
Trait Implementations§
Source§impl AsRef<str> for PackageIdent
impl AsRef<str> for PackageIdent
Source§impl Clone for PackageIdent
impl Clone for PackageIdent
Source§fn clone(&self) -> PackageIdent
fn clone(&self) -> PackageIdent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PackageIdent
impl Debug for PackageIdent
Source§impl<'de> Deserialize<'de> for PackageIdent
impl<'de> Deserialize<'de> for PackageIdent
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 PackageIdent
impl Display for PackageIdent
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> From<(T, U)> for PackageIdent
impl<T, U> From<(T, U)> for PackageIdent
Source§impl From<PackageIdent> for Cow<'static, str>
impl From<PackageIdent> for Cow<'static, str>
Source§fn from(id: PackageIdent) -> Self
fn from(id: PackageIdent) -> Self
Source§impl From<PackageIdent> for String
impl From<PackageIdent> for String
Source§fn from(id: PackageIdent) -> Self
fn from(id: PackageIdent) -> Self
Source§impl FromStr for PackageIdent
impl FromStr for PackageIdent
Source§impl Hash for PackageIdent
impl Hash for PackageIdent
Source§impl<'a> IntoPackageIdent<'a> for &'a PackageIdent
impl<'a> IntoPackageIdent<'a> for &'a PackageIdent
Source§impl Ord for PackageIdent
impl Ord for PackageIdent
Source§impl PartialEq for PackageIdent
impl PartialEq for PackageIdent
Source§impl PartialOrd for PackageIdent
impl PartialOrd for PackageIdent
Source§impl Serialize for PackageIdent
impl Serialize for PackageIdent
Source§impl TryFrom<&'static str> for PackageIdent
impl TryFrom<&'static str> for PackageIdent
Source§impl TryFrom<String> for PackageIdent
impl TryFrom<String> for PackageIdent
impl Eq for PackageIdent
Auto Trait Implementations§
impl Freeze for PackageIdent
impl RefUnwindSafe for PackageIdent
impl Send for PackageIdent
impl Sync for PackageIdent
impl Unpin for PackageIdent
impl UnwindSafe for PackageIdent
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.