-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkerProtocolVersion.cs
More file actions
27 lines (20 loc) · 989 Bytes
/
Copy pathWorkerProtocolVersion.cs
File metadata and controls
27 lines (20 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace DotPython.Protocol;
public readonly record struct WorkerProtocolVersion(int Major, int Minor)
: IComparable<WorkerProtocolVersion>
{
public static WorkerProtocolVersion Current { get; } = new(3, 0);
public int CompareTo(WorkerProtocolVersion other)
{
var major = Major.CompareTo(other.Major);
return major != 0 ? major : Minor.CompareTo(other.Minor);
}
public static bool operator <(WorkerProtocolVersion left, WorkerProtocolVersion right) =>
left.CompareTo(right) < 0;
public static bool operator <=(WorkerProtocolVersion left, WorkerProtocolVersion right) =>
left.CompareTo(right) <= 0;
public static bool operator >(WorkerProtocolVersion left, WorkerProtocolVersion right) =>
left.CompareTo(right) > 0;
public static bool operator >=(WorkerProtocolVersion left, WorkerProtocolVersion right) =>
left.CompareTo(right) >= 0;
public override string ToString() => $"{Major}.{Minor}";
}