logos-messaging-nim/tools/confutils/envvar_serialization.nim
fryorcraken bc8acf7611
feat: Waku API create node (#3580)
* introduce createNode

# Conflicts:
#	apps/wakunode2/cli_args.nim

* remove confutils dependency on the library

* test: remove websocket in default test config

* update to latest specs

* test: cli_args

* align to spec changes (sovereign, message conf, entrypoints

* accept enr, entree and multiaddr as entry points

* post rebase

* format

* change from "sovereign" to "core"

* add example

* get example to continue running

* nitpicks

* idiomatic constructors

* fix enum naming

* replace procs with consts

* remove messageConfirmation

* use pure enum

* rename example file
2025-10-01 16:31:34 +10:00

50 lines
1.3 KiB
Nim

{.push raises: [].}
import stew/shims/macros, serialization
import ./envvar_serialization/reader, ./envvar_serialization/writer
export serialization, reader, writer
serializationFormat Envvar
Envvar.setReader EnvvarReader
Envvar.setWriter EnvvarWriter, PreferredOutput = void
template supports*(_: type Envvar, T: type): bool =
# The Envvar format should support every type
true
template decode*(
_: type Envvar, prefix: string, RecordType: distinct type, params: varargs[untyped]
): auto =
mixin init, ReaderType
{.noSideEffect.}:
var reader = unpackArgs(init, [EnvvarReader, prefix, params])
reader.readValue(RecordType)
template encode*(
_: type Envvar, prefix: string, value: auto, params: varargs[untyped]
) =
mixin init, WriterType, writeValue
{.noSideEffect.}:
var writer = unpackArgs(init, [EnvvarWriter, prefix, params])
writeValue writer, value
template loadFile*(
_: type Envvar, prefix: string, RecordType: distinct type, params: varargs[untyped]
): auto =
mixin init, ReaderType, readValue
var reader = unpackArgs(init, [EnvvarReader, prefix, params])
reader.readValue(RecordType)
template saveFile*(
_: type Envvar, prefix: string, value: auto, params: varargs[untyped]
) =
mixin init, WriterType, writeValue
var writer = unpackArgs(init, [EnvvarWriter, prefix, params])
writer.writeValue(value)