From 7c48f80fd8d81ec7c0b9e504174b05892248380a Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 24 Nov 2018 01:02:53 +0100 Subject: Add last streamblock flag accessor --- src/streamblock.nim | 3 +++ tests/tstreamblock.nim | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/streamblock.nim b/src/streamblock.nim index 49c3dcd..403687e 100644 --- a/src/streamblock.nim +++ b/src/streamblock.nim @@ -34,6 +34,9 @@ type StreamBlock* = object else: discard +proc isLast*(streamBlock: StreamBlock): bool = + streamBlock.last + proc readSerialised*(bitReader: BitReader): StreamBlock = result.last = bitReader.readBool() result.kind = bitReader.readBits(2, uint8).BlockKind diff --git a/tests/tstreamblock.nim b/tests/tstreamblock.nim index f1be559..89f69e0 100644 --- a/tests/tstreamblock.nim +++ b/tests/tstreamblock.nim @@ -25,6 +25,7 @@ suite "streamblock": rawStream.setPosition(0) let rawBitReader = rawStream.bitReader() let streamBlock = readRaw(rawBitReader, uncompressed) + check streamBlock.isLast() let outputStream = newStringStream() defer: outputStream.close() @@ -58,6 +59,7 @@ suite "streamblock": let outputStream = newStringStream() defer: outputStream.close() let outputBitWriter = outputStream.bitWriter() + check streamBlock.isLast() streamBlock.writeRawTo(outputBitWriter) outputBitWriter.flush() -- cgit v1.2.3