mirror of
https://github.com/status-im/nim-serialization.git
synced 2025-01-14 13:55:46 +00:00
Add stream.readValue
This commit is contained in:
parent
dccba1e22b
commit
5ecae14972
@ -124,8 +124,19 @@ template borrowSerialization*(Alias: distinct type,
|
|||||||
mixin readValue
|
mixin readValue
|
||||||
value = Alias reader.readValue(OriginalType)
|
value = Alias reader.readValue(OriginalType)
|
||||||
|
|
||||||
template writeValue*(stream: OutputStream, Format: type, value: auto) =
|
template readValue*(stream: InputStream,
|
||||||
|
Format: type,
|
||||||
|
ValueType: type,
|
||||||
|
params: varargs[untyped]): untyped =
|
||||||
|
mixin ReaderType, init, readValue
|
||||||
|
var reader = unpackArgs(init, [ReaderType(Format), stream, params])
|
||||||
|
readValue reader, ValueType
|
||||||
|
|
||||||
|
template writeValue*(stream: OutputStream,
|
||||||
|
Format: type,
|
||||||
|
value: auto,
|
||||||
|
params: varargs[untyped]) =
|
||||||
mixin WriterType, init, writeValue
|
mixin WriterType, init, writeValue
|
||||||
var writer = init(WriterType(Format), stream)
|
var writer = unpackArgs(init, [WriterType(Format), stream])
|
||||||
writeValue writer, value
|
writeValue writer, value
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user