Struct NodeVersion
- Namespace
- Nyra
- Assembly
- Nyra.dll
A node server version (major.minor.patch), parsed from the string reported by the server.
public readonly struct NodeVersion : IEquatable<NodeVersion>, IComparable<NodeVersion>
- Implements
- Inherited Members
Constructors
NodeVersion(int, int, int)
A node server version (major.minor.patch), parsed from the string reported by the server.
public NodeVersion(int major, int minor, int patch)
Parameters
majorintThe major version number.
minorintThe minor version number.
patchintThe patch version number.
Properties
Major
The major version number.
public int Major { get; }
Property Value
MinimumLavalink
Oldest Lavalink version supported.
public static NodeVersion MinimumLavalink { get; }
Property Value
MinimumNodeLink
Oldest NodeLink version supported.
public static NodeVersion MinimumNodeLink { get; }
Property Value
Minor
The minor version number.
public int Minor { get; }
Property Value
Patch
The patch version number.
public int Patch { get; }
Property Value
Methods
CompareTo(NodeVersion)
Compares this version with another, oldest first.
public int CompareTo(NodeVersion other)
Parameters
otherNodeVersionThe version to compare with.
Returns
- int
Zero when equal, negative when this one is older, positive when newer.
Equals(NodeVersion)
Indicates whether both versions carry the same numbers.
public bool Equals(NodeVersion other)
Parameters
otherNodeVersionThe version to compare with.
Returns
- bool
Whether the numbers match.
Equals(object?)
Indicates whether the object is a version with the same numbers.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with.
Returns
- bool
Whether the object is an equal version.
GetHashCode()
Returns the hash code of the version.
public override int GetHashCode()
Returns
- int
A hash of the version's numbers.
ToString()
Returns the version as major.minor.patch.
public override string ToString()
Returns
- string
The dotted version text.
TryParse(ReadOnlySpan<char>, out NodeVersion)
Parses major.minor.patch out of the text, leniently.
public static bool TryParse(ReadOnlySpan<char> text, out NodeVersion version)
Parameters
textReadOnlySpan<char>The version text to parse.
versionNodeVersionThe parsed version, default when the text is not a version.
Returns
- bool
Whether the text parsed into a version.
Remarks
Missing trailing dot-and-component pairs default to zero (1.2 reads as 1.2.0), a dot with no
digits after it is not a version, a trailing pre-release/build tag (-/+) is ignored, and a
leading v or V (git describe style) is accepted.
A bare number is not a version, no supported server reports one without a dot, and an all-digit dev commit hash must stay unparsed so the dev-build policy keeps its null, a string that is not a version is treated as a dev build.
TryParse(string?, out NodeVersion)
Parses a version from a string, the span overload does the work.
public static bool TryParse(string? text, out NodeVersion version)
Parameters
textstringThe version text to parse.
versionNodeVersionThe parsed version, default when the text is not a version.
Returns
- bool
Whether the text parsed into a version.
Operators
operator ==(NodeVersion, NodeVersion)
Returns whether the versions are equal.
public static bool operator ==(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the versions are equal.
operator >(NodeVersion, NodeVersion)
Returns whether the left version is newer.
public static bool operator >(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the left version is newer.
operator >=(NodeVersion, NodeVersion)
Returns whether the left version is newer or equal.
public static bool operator >=(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the left version is newer or equal.
operator !=(NodeVersion, NodeVersion)
Returns whether the versions differ.
public static bool operator !=(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the versions differ.
operator <(NodeVersion, NodeVersion)
Returns whether the left version is older.
public static bool operator <(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the left version is older.
operator <=(NodeVersion, NodeVersion)
Returns whether the left version is older or equal.
public static bool operator <=(NodeVersion left, NodeVersion right)
Parameters
leftNodeVersionThe version on the left.
rightNodeVersionThe version on the right.
Returns
- bool
Whether the left version is older or equal.