|
|
@ -2,6 +2,12 @@ |
|
|
|
// of a cluster
|
|
|
|
// of a cluster
|
|
|
|
package rings |
|
|
|
package rings |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
|
|
"syscall" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"darvaza.org/core" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
// RegionMax indicates the highest number that can be used for a [RegionID].
|
|
|
|
// RegionMax indicates the highest number that can be used for a [RegionID].
|
|
|
|
RegionMax = (1 << 4) - 1 |
|
|
|
RegionMax = (1 << 4) - 1 |
|
|
@ -35,3 +41,9 @@ func (n NodeID) Valid() bool { return n > 0 && n <= NodeMax } |
|
|
|
|
|
|
|
|
|
|
|
// ValidZero tells a [NodeID] is within the valid range for a gateway.
|
|
|
|
// ValidZero tells a [NodeID] is within the valid range for a gateway.
|
|
|
|
func (n NodeID) ValidZero() bool { return n > 0 && n <= NodeZeroMax } |
|
|
|
func (n NodeID) ValidZero() bool { return n > 0 && n <= NodeZeroMax } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ErrOutOfRange is an error indicating the value of a field
|
|
|
|
|
|
|
|
// is out of range.
|
|
|
|
|
|
|
|
func ErrOutOfRange[T ~int | ~uint32](value T, field string) error { |
|
|
|
|
|
|
|
return core.Wrap(syscall.EINVAL, "%s out of range (%v)", field, value) |
|
|
|
|
|
|
|
} |
|
|
|