From fb21b1e4f0ee0e55e9556bf1f399d00d5eae26e4 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 24 Mar 2024 14:12:27 +0100 Subject: io: derive DynStream from RootObj (not Stream) This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.) --- src/io/bufwriter.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/io/bufwriter.nim') diff --git a/src/io/bufwriter.nim b/src/io/bufwriter.nim index cbee8b5b..75da4190 100644 --- a/src/io/bufwriter.nim +++ b/src/io/bufwriter.nim @@ -1,4 +1,5 @@ -# Write data to streams. +# Write data to streams in packets. +# Each packet is prefixed with its length as a pointer-sized integer. import std/options import std/sets @@ -53,13 +54,6 @@ proc deinit*(writer: var BufferedWriter) = writer.bufSize = 0 writer.bufLen = 0 -template withWriter*(stream: DynStream; w, body: untyped) = - block: - var w = stream.initWriter() - body - w.flush() - w.deinit() - template withPacketWriter*(stream: DynStream; w, body: untyped) = block: var w = stream.initWriter(writeLen = true) -- cgit 1.4.1-2-gfad0