mirror of
https://github.com/status-im/nim-serialization.git
synced 2025-01-12 12:54:53 +00:00
Add a helper simplifying writing a single value to a stream
This commit is contained in:
parent
6804ea2537
commit
060c8fd9bf
@ -121,3 +121,8 @@ template borrowSerialization*(Alias: distinct type,
|
|||||||
mixin readValue
|
mixin readValue
|
||||||
value = Alias reader.readValue(OriginalType)
|
value = Alias reader.readValue(OriginalType)
|
||||||
|
|
||||||
|
template appendValue*(stream: OutputStreamVar, Format: type, value: auto) =
|
||||||
|
mixin WriterType, init, writeValue
|
||||||
|
var writer = init(WriterType(Format), stream)
|
||||||
|
writeValue writer, value
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@ type
|
|||||||
SerializationError* = object of CatchableError
|
SerializationError* = object of CatchableError
|
||||||
UnexpectedEofError* = object of SerializationError
|
UnexpectedEofError* = object of SerializationError
|
||||||
|
|
||||||
method formatMsg*(err: ref SerializationError, filename: string): string {.base.} =
|
method formatMsg*(err: ref SerializationError, filename: string): string {.gcsafe, base.} =
|
||||||
"Serialisation error while processing " & filename
|
"Serialisation error while processing " & filename
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user