Struct purl::GenericPurl
source · pub struct GenericPurl<T> { /* private fields */ }
Expand description
An immutable PURL.
This type does not directly include any package-type-specific behavior. Any
package-type-specific behavior is added using PurlShape
.
§Example
use purl::GenericPurl;
// Use the builder if you want to set fields besides the type and name.
let purl = GenericPurl::builder(String::from("npm"), "my-package")
.with_version("1.2.3")
.build()
.unwrap();
assert_eq!("pkg:npm/my-package@1.2.3", &purl.to_string());
§See also
See Purl
for information about using the built-in PackageType
enum.
See PurlShape
if you want to use your own package types.
Implementations§
source§impl<T> GenericPurl<T>
impl<T> GenericPurl<T>
sourcepub fn builder<S>(package_type: T, name: S) -> GenericPurlBuilder<T>
pub fn builder<S>(package_type: T, name: S) -> GenericPurlBuilder<T>
Create a new PurlBuilder
.
sourcepub fn new<S>(package_type: T, name: S) -> Result<Self, T::Error>
pub fn new<S>(package_type: T, name: S) -> Result<Self, T::Error>
Create a new PURL.
An error will be returned if the PurlShape
implementation T
requires additional fields to be specified for package_type
. For
example, Purl::new(PackageType::Maven, "my-package")
will fail because
Maven requires a namespace. In that case, you must use Self::builder
to set the additional required fields.
sourcepub fn package_type(&self) -> &T
pub fn package_type(&self) -> &T
Get the package type.
sourcepub fn qualifiers(&self) -> &Qualifiers
pub fn qualifiers(&self) -> &Qualifiers
Get the qualifiers.
sourcepub fn into_builder(self) -> GenericPurlBuilder<T>
pub fn into_builder(self) -> GenericPurlBuilder<T>
Convert this PURL into a mutable form.
Trait Implementations§
source§impl<T: Clone> Clone for GenericPurl<T>
impl<T: Clone> Clone for GenericPurl<T>
source§fn clone(&self) -> GenericPurl<T>
fn clone(&self) -> GenericPurl<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for GenericPurl<T>
impl<T: Debug> Debug for GenericPurl<T>
source§impl<'de, T> Deserialize<'de> for GenericPurl<T>
Available on crate feature serde
only.
impl<'de, T> Deserialize<'de> for GenericPurl<T>
Available on crate feature
serde
only.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<T> Display for GenericPurl<T>where
T: PurlShape,
impl<T> Display for GenericPurl<T>where
T: PurlShape,
source§impl<T> FromStr for GenericPurl<T>
impl<T> FromStr for GenericPurl<T>
source§impl<T: Hash> Hash for GenericPurl<T>
impl<T: Hash> Hash for GenericPurl<T>
source§impl<T: Ord> Ord for GenericPurl<T>
impl<T: Ord> Ord for GenericPurl<T>
source§fn cmp(&self, other: &GenericPurl<T>) -> Ordering
fn cmp(&self, other: &GenericPurl<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq> PartialEq for GenericPurl<T>
impl<T: PartialEq> PartialEq for GenericPurl<T>
source§fn eq(&self, other: &GenericPurl<T>) -> bool
fn eq(&self, other: &GenericPurl<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd for GenericPurl<T>
impl<T: PartialOrd> PartialOrd for GenericPurl<T>
source§fn partial_cmp(&self, other: &GenericPurl<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &GenericPurl<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T> Serialize for GenericPurl<T>where
T: PurlShape,
Available on crate feature serde
only.
impl<T> Serialize for GenericPurl<T>where
T: PurlShape,
Available on crate feature
serde
only.impl<T: Eq> Eq for GenericPurl<T>
impl<T> StructuralPartialEq for GenericPurl<T>
Auto Trait Implementations§
impl<T> Freeze for GenericPurl<T>where
T: Freeze,
impl<T> RefUnwindSafe for GenericPurl<T>where
T: RefUnwindSafe,
impl<T> Send for GenericPurl<T>where
T: Send,
impl<T> Sync for GenericPurl<T>where
T: Sync,
impl<T> Unpin for GenericPurl<T>where
T: Unpin,
impl<T> UnwindSafe for GenericPurl<T>where
T: UnwindSafe,
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