lib/types: add port type
This commit is contained in:
parent
281d071b6a
commit
c776489cac
|
@ -120,16 +120,16 @@ rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
betweenDesc = lowest: highest:
|
betweenDesc = lowest: highest:
|
||||||
"${toString lowest} and ${toString highest} (both inclusive).";
|
"${toString lowest} and ${toString highest} (both inclusive)";
|
||||||
between = lowest: highest: assert lowest <= highest;
|
between = lowest: highest: assert lowest <= highest;
|
||||||
addCheck int (x: x >= lowest && x <= highest) // {
|
addCheck int (x: x >= lowest && x <= highest) // {
|
||||||
name = "intBetween";
|
name = "intBetween";
|
||||||
description = "Integer between ${betweenDesc lowest highest}";
|
description = "Integer between ${betweenDesc lowest highest}.";
|
||||||
};
|
};
|
||||||
ign = lowest: highest: name: docStart:
|
ign = lowest: highest: name: docStart:
|
||||||
between lowest highest // {
|
between lowest highest // {
|
||||||
inherit name;
|
inherit name;
|
||||||
description = docStart + " Between ${betweenDesc lowest highest}";
|
description = docStart + " Between ${betweenDesc lowest highest}.";
|
||||||
};
|
};
|
||||||
unsign = bit: range: ign 0 (range - 1)
|
unsign = bit: range: ign 0 (range - 1)
|
||||||
"unsignedInt${toString bit}" "${toString bit} bit unsigned integer.";
|
"unsignedInt${toString bit}" "${toString bit} bit unsigned integer.";
|
||||||
|
@ -137,7 +137,7 @@ rec {
|
||||||
"signedInt${toString bit}" "${toString bit} bit signed integer.";
|
"signedInt${toString bit}" "${toString bit} bit signed integer.";
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
/* an int with a fixed range
|
/* An int with a fixed range.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* (ints.between 0 100).check (-1)
|
* (ints.between 0 100).check (-1)
|
||||||
|
@ -167,6 +167,9 @@ rec {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A network port number */
|
||||||
|
port = ints.unsigned16;
|
||||||
|
|
||||||
str = mkOptionType {
|
str = mkOptionType {
|
||||||
name = "str";
|
name = "str";
|
||||||
description = "string";
|
description = "string";
|
||||||
|
|
Loading…
Reference in New Issue