2022-11-03 17:58:48 +01:00
|
|
|
when (NimMajor, NimMinor) < (1, 4):
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
else:
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
|
|
|
std/strutils,
|
|
|
|
stew/shims/net
|
|
|
|
import
|
|
|
|
../../../envvar_serialization
|
|
|
|
|
|
|
|
export
|
|
|
|
net,
|
|
|
|
envvar_serialization
|
|
|
|
|
|
|
|
proc readValue*(r: var EnvvarReader, value: var ValidIpAddress) {.raises: [SerializationError].} =
|
|
|
|
try:
|
|
|
|
value = ValidIpAddress.init(r.readValue(string))
|
2023-09-21 13:12:14 +02:00
|
|
|
except ValueError, IOError:
|
|
|
|
raise newException(SerializationError, "Invalid IP address: " & getCurrentExceptionMsg())
|
2022-11-03 17:58:48 +01:00
|
|
|
|
2023-09-21 13:12:14 +02:00
|
|
|
proc readValue*(r: var EnvvarReader, value: var Port) {.raises: [SerializationError].} =
|
2022-11-03 17:58:48 +01:00
|
|
|
try:
|
|
|
|
value = parseUInt(r.readValue(string)).Port
|
2023-09-21 13:12:14 +02:00
|
|
|
except ValueError, IOError:
|
|
|
|
raise newException(SerializationError, "Invalid Port: " & getCurrentExceptionMsg())
|