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
impl PartialVersion
Sourcepub fn checked(self) -> Result<Self, VersionError>
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.
Sourcepub fn compatible(&self, version: Version) -> bool
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.
Sourcepub fn widened(&self) -> PartialVersion
pub fn widened(&self) -> PartialVersion
Remove minor number.
Sourcepub fn sort_key(&self) -> (u32, Option<u32>, Option<u32>)
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
impl Clone for PartialVersion
Source§fn clone(&self) -> PartialVersion
fn clone(&self) -> PartialVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PartialVersion
impl Debug for PartialVersion
Source§impl Display for PartialVersion
impl Display for PartialVersion
Source§impl From<&PartialVersion> for Version
Convert a PartialVersion
into a Version
that’s useful for
comparisons.
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
fn from(partial: &PartialVersion) -> Self
Source§impl From<&Version> for PartialVersion
Convert a Version
into a PartialVersion
.
impl From<&Version> for PartialVersion
Convert a Version
into a PartialVersion
.
Source§impl From<PartialVersion> for Constraint
impl From<PartialVersion> for Constraint
Source§fn from(version: PartialVersion) -> Self
fn from(version: PartialVersion) -> Self
Convert a PartialVersion
into a Constraint::Version
.
Source§impl From<PartialVersion> for Version
See From<&PartialVersion> for Version
.
impl From<PartialVersion> for Version
See From<&PartialVersion> for Version
.
Source§fn from(partial: PartialVersion) -> Self
fn from(partial: PartialVersion) -> Self
Source§impl From<Version> for PartialVersion
See From<&Version> for PartialVersion
.
impl From<Version> for PartialVersion
See From<&Version> for PartialVersion
.
Source§impl FromStr for PartialVersion
impl FromStr for PartialVersion
Source§impl PartialEq for PartialVersion
impl PartialEq for PartialVersion
Source§impl PartialOrd for PartialVersion
impl PartialOrd for PartialVersion
impl Copy for PartialVersion
Auto Trait Implementations§
impl Freeze for PartialVersion
impl RefUnwindSafe for PartialVersion
impl Send for PartialVersion
impl Sync for PartialVersion
impl Unpin for PartialVersion
impl UnwindSafe for PartialVersion
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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