fluvio_index

Struct PackageId

Source
pub struct PackageId<V = MaybeVersion> { /* private fields */ }
Expand description

A unique identifier for a package that describes its registry, group, name, and (possibly) version.

There are two different variations of a PackageId, which have different formatting and parsing rules.

  1. A PackageId<WithVersion> represents a fully-qualified package name that also refers to a specific version of the package. It is rendered (and parsed) as a string in the following form:
<registry>/<group>/<name>:<version>
OR
<group>/<name>:<version>
OR
<name>:<version>

Note that a PackageId<WithVersion> has strong guarantees on its FromStr implementation (and therefore, it’s parse() rules). This means that a PackageId<WithVersion> is guaranteed to have a version embedded in it, which can be accessed via .version().

  1. A PackageId (i.e. PackageId<MaybeVersion>) might or might not contain a version, and will parse a package string that does OR does not have a version in it. This is the type you should use if you don’t need a version or if you want to do something different based on whether or not a version is given. An example of this might be installing a specific version of a package if a version is given, or defaulting to the latest version if not given.

Valid forms that will parse into a PackageId include:

<registry>/<group>/<name>
<group>/<name>
<name>
<registry>/<group>/<name>:<version>
<group>/<name>:<version>
<name>:<version>

Implementations§

Source§

impl<T> PackageId<T>

Source

pub fn registry(&self) -> &Registry

Return the registry of the package specified by this identifier

Source

pub fn group(&self) -> &GroupName

Return the group of the package specified by this identifier

Source

pub fn name(&self) -> &PackageName

Return the name of the package specified by this identifier

Source

pub fn pretty(&self) -> impl Display

A printable representation of this PackageId

This displays the most concise representation of this PackageId that is still unique. For example, if the registry and group name are default values, this will display only the package name. If the group name is non-standard, it will be printed. If the registry is non-standard, both the registry and the group name will be printed.

Source

pub fn uid(&self) -> String

A unique representation of this package, excluding version.

This is intended to be used for comparing two PackageId’s to see whether they refer to the same package entity, regardless of version.

§Example
let pid1: PackageId<MaybeVersion> = "fluvio/fluvio".parse().unwrap();
let pid2: PackageId<WithVersion> = "https://packages.fluvio.io/v1/fluvio/fluvio:1.2.3".parse().unwrap();
assert_eq!(pid1.uid(), pid2.uid());
Source§

impl PackageId<WithVersion>

Source

pub fn version(&self) -> &PackageVersion

A PackageId indisputably has a version, no Option required.

Source

pub fn into_version(self) -> PackageVersion

Return the inner PackageVersion, consuming the PackageId

Source

pub fn into_maybe_versioned(self) -> PackageId<MaybeVersion>

Convert to a PackageId<WithVersion> preserving the inner Version

Source

pub fn into_unversioned(self) -> PackageId<MaybeVersion>

Convert to a PackageId<WithVersion>, dropping the inner Version

Source§

impl PackageId<MaybeVersion>

Source

pub fn into_versioned(self, version: PackageVersion) -> PackageId<WithVersion>

Add a Version to any PackageId to create a PackageId

Source§

impl PackageId<MaybeVersion>

Trait Implementations§

Source§

impl<V: Clone> Clone for PackageId<V>

Source§

fn clone(&self) -> PackageId<V>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for PackageId<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PackageId<MaybeVersion>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for PackageId<WithVersion>

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PackageId<MaybeVersion>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PackageId<WithVersion>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for PackageId<MaybeVersion>

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for PackageId<WithVersion>

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<V: PartialEq> PartialEq for PackageId<V>

Source§

fn eq(&self, other: &PackageId<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PackageId<MaybeVersion>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for PackageId<WithVersion>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V: Eq> Eq for PackageId<V>

Source§

impl<V> StructuralPartialEq for PackageId<V>

Auto Trait Implementations§

§

impl<V> Freeze for PackageId<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for PackageId<V>
where V: RefUnwindSafe,

§

impl<V> Send for PackageId<V>
where V: Send,

§

impl<V> Sync for PackageId<V>
where V: Sync,

§

impl<V> Unpin for PackageId<V>
where V: Unpin,

§

impl<V> UnwindSafe for PackageId<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T