pub struct RedisVersion {
pub major: u32,
pub minor: u32,
pub patch: u32,
}redis-store only.Expand description
Represents a parsed Redis server version with major, minor, and patch components.
Supports ordering and equality comparisons, allowing you to check minimum version requirements before using version-specific Redis features.
§Examples
use kiomq::{RedisVersion};
let raw = get_redis_info();
let version = RedisVersion::parse(&raw).expect("Failed to parse Redis version");
if version >= (RedisVersion { major: 7, minor: 2, patch: 0 }) {
// use Redis 7.2+ features
}Fields§
§major: u32Major version number (e.g. 7 in 7.2.4)
minor: u32Minor version number (e.g. 2 in 7.2.4)
patch: u32Patch version number (e.g. 4 in 7.2.4), defaults to 0 if absent
Implementations§
Source§impl RedisVersion
impl RedisVersion
Sourcepub fn parse(raw: &str) -> Option<Self>
pub fn parse(raw: &str) -> Option<Self>
Parses a RedisVersion from the raw output of the INFO server command.
Looks for the redis_version: field in the INFO response and splits
it into major, minor, and patch components.
§Arguments
raw- The raw string output fromINFO server
§Returns
Some(RedisVersion) if the version field was found and parsed successfully,
None otherwise.
§Examples
use kiomq::{RedisVersion};
let raw = "redis_version:7.2.4\r\nos:Linux\r\n";
let version = RedisVersion::parse(raw).unwrap();
assert_eq!(version.major, 7);
assert_eq!(version.minor, 2);
assert_eq!(version.patch, 4);Sourcepub fn is_at_least(&self, version: &str) -> Option<bool>
pub fn is_at_least(&self, version: &str) -> Option<bool>
Checks if this version is greater than or equal to a version string.
§Arguments
version- A version string in the format"major.minor.patch"or"major.minor"
§Returns
Some(bool) if the string was parsed successfully, None if the format is invalid.
§Examples
use kiomq::{RedisVersion};
let version = RedisVersion { major: 7, minor: 2, patch: 4 };
assert_eq!(version.is_at_least("7.2"), Some(true));
assert_eq!(version.is_at_least("7.2.4"), Some(true));
assert_eq!(version.is_at_least("8.0"), Some(false));Trait Implementations§
Source§impl Clone for RedisVersion
impl Clone for RedisVersion
Source§fn clone(&self) -> RedisVersion
fn clone(&self) -> RedisVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedisVersion
impl Debug for RedisVersion
Source§impl Ord for RedisVersion
impl Ord for RedisVersion
Source§fn cmp(&self, other: &RedisVersion) -> Ordering
fn cmp(&self, other: &RedisVersion) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RedisVersion
impl PartialEq for RedisVersion
Source§fn eq(&self, other: &RedisVersion) -> bool
fn eq(&self, other: &RedisVersion) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for RedisVersion
impl PartialOrd for RedisVersion
impl Copy for RedisVersion
impl Eq for RedisVersion
impl StructuralPartialEq for RedisVersion
Auto Trait Implementations§
impl Freeze for RedisVersion
impl RefUnwindSafe for RedisVersion
impl Send for RedisVersion
impl Sync for RedisVersion
impl Unpin for RedisVersion
impl UnsafeUnpin for RedisVersion
impl UnwindSafe for RedisVersion
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.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