PartialVersion

Enum PartialVersion 

Source
pub enum PartialVersion {
    Pre10m(u32, u32),
    Pre10mm(u32, u32, u32),
    Post10m(u32),
    Post10mm(u32, u32),
}
Expand description

Represents a PostgreSQL version with some parts missing. This is the kind of thing we might find in a cluster’s PG_VERSION file.

The “Version” column on the PostgreSQL “Versioning Policy” page is roughly what this models, but this can also optionally represent the “Current minor” column too.

Variants§

§

Pre10m(u32, u32)

Pre-PostgreSQL 10, with major and point version numbers, e.g. 9.6. It is an error to create this variant with a major number >= 10; see checked for a way to guard against this.

§

Pre10mm(u32, u32, u32)

Pre-PostgreSQL 10, with major, point, and minor version numbers, e.g. 9.6.17. It is an error to create this variant with a major number >=§ 10; see checked for a way to guard against this.

§

Post10m(u32)

PostgreSQL 10+, with major version number, e.g. 10. It is an error to create this variant with a major number < 10; see checked for a way to guard against this.

§

Post10mm(u32, u32)

PostgreSQL 10+, with major and minor version number, e.g. 10.3. It is an error to create this variant with a major number < 10; see checked for a way to guard against this.

Implementations§

Source§

impl PartialVersion

Source

pub fn checked(self) -> Result<Self, VersionError>

Return self if it is a valid PartialVersion.

This can be necessary when a PartialVersion has been constructed directly. It checks that PartialVersion::Pre10m and PartialVersion::Pre10mm have a major version number less than 10, and that PartialVersion::Post10m and PartialVersion::Post10mm have a major version number greater than or equal to 10.

Source

pub fn compatible(&self, version: Version) -> bool

Is the given Version compatible with this PartialVersion?

Put another way: can a server of the given Version be used to run a cluster of this PartialVersion?

This is an interesting question to answer because clusters contain a file named PG_VERSION which containing just the major version number of the cluster’s files, e.g. “15”, or the major.point number for older PostgreSQL releases, e.g. “9.6”.

For versions of PostgreSQL before 10, this means that the given version’s major and point numbers must match exactly, and the minor number must be greater than or equal to this PartialVersion’s minor number. When this PartialVersion has no point or minor number, the given version is assumed to be compatible.

For versions of PostgreSQL after and including 10, this means that the given version’s major number must match exactly, and the minor number must be greater than or equal to this PartialVersion’s minor number. When this PartialVersion has no minor number, the given version is assumed to be compatible.

Source

pub fn widened(&self) -> PartialVersion

Remove minor number.

Source

pub fn sort_key(&self) -> (u32, Option<u32>, Option<u32>)

Provide a sort key that implements Ord.

PartialVersion does not implement Eq or Ord because they would disagree with its PartialEq and PartialOrd implementations, so this function provides a sort key that implements Ord and can be used with sorting functions, e.g. slice::sort_by_key.

Trait Implementations§

Source§

impl Clone for PartialVersion

Source§

fn clone(&self) -> PartialVersion

Returns a duplicate 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 Debug for PartialVersion

Source§

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

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

impl Display for PartialVersion

Source§

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

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

impl From<&PartialVersion> for Version

Convert a PartialVersion into a Version that’s useful for comparisons.

The Version returned has 0 (zero) in the place of the missing parts. For example, a partial version of 9.6.* becomes 9.6.0, and 12.* becomes 12.0.

Source§

fn from(partial: &PartialVersion) -> Self

Converts to this type from the input type.
Source§

impl From<&Version> for PartialVersion

Convert a Version into a PartialVersion.

Source§

fn from(version: &Version) -> Self

Converts to this type from the input type.
Source§

impl From<PartialVersion> for Constraint

Source§

fn from(version: PartialVersion) -> Self

Source§

impl From<PartialVersion> for Version

See From<&PartialVersion> for Version.

Source§

fn from(partial: PartialVersion) -> Self

Converts to this type from the input type.
Source§

impl From<Version> for PartialVersion

See From<&Version> for PartialVersion.

Source§

fn from(version: Version) -> Self

Converts to this type from the input type.
Source§

impl FromStr for PartialVersion

Source§

type Err = VersionError

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 PartialEq for PartialVersion

Source§

fn eq(&self, other: &Self) -> 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 PartialOrd for PartialVersion

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for PartialVersion

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn push_quoted<'q, Q, S>(&mut self, _q: Q, s: S)
where Q: QuoteInto<T>, S: Into<Quotable<'q>>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> ErasedDestructor for T
where T: 'static,