diff --git a/serialization.nim b/serialization.nim index d86b8de..c5fbe81 100644 --- a/serialization.nim +++ b/serialization.nim @@ -121,3 +121,8 @@ template borrowSerialization*(Alias: distinct type, mixin readValue 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 + diff --git a/serialization/errors.nim b/serialization/errors.nim index 42cf615..2c5cf04 100644 --- a/serialization/errors.nim +++ b/serialization/errors.nim @@ -2,6 +2,6 @@ type SerializationError* = object of CatchableError 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