From 3aa8a902657e0b976c94dc1555fd4cdfea13bcd8 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 8 Feb 2019 14:29:30 +0100 Subject: [PATCH] Add size to BlobStream, cancel to IngestStream --- src/blobsets.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/blobsets.nim b/src/blobsets.nim index 52d2a94..8bd316b 100644 --- a/src/blobsets.nim +++ b/src/blobsets.nim @@ -403,11 +403,13 @@ type BlobStream* = ref BlobStreamObj BlobStreamObj* = object of RootObj closeImpl*: proc (s: BlobStream) {.nimcall, gcsafe.} + sizeImpl*: proc (s: BlobStream): BiggestInt {.nimcall, gcsafe.} setPosImpl*: proc (s: BlobStream; pos: BiggestInt) {.nimcall, gcsafe.} getPosImpl*: proc (s: BlobStream): BiggestInt {.nimcall, gcsafe.} readImpl*: proc (s: BlobStream; buffer: pointer; bufLen: int): int {.nimcall, gcsafe.} IngestStream* = ref IngestStreamObj IngestStreamObj* = object of RootObj + cancelImpl*: proc (s: IngestStream) {.nimcall, gcsafe.} finishImpl*: proc (s: IngestStream): tuple[id: BlobId, size: BiggestInt] {.nimcall, gcsafe.} ingestImpl*: proc (s: IngestStream; buf: pointer; size: int) {.nimcall, gcsafe.} @@ -415,6 +417,10 @@ proc close*(s: BlobStream) = assert(not s.closeImpl.isNil) s.closeImpl(s) +proc size*(s: BlobStream): BiggestInt = + assert(not s.sizeImpl.isNil) + s.sizeImpl(s) + proc `pos=`*(s: BlobStream; pos: BiggestInt) = assert(not s.setPosImpl.isNil) s.setPosImpl(s, pos) @@ -427,6 +433,11 @@ proc read*(s: BlobStream; buf: pointer; len: Natural): int = assert(not s.readImpl.isNil) result = s.readImpl(s, buf, len) +proc cancle*(s: IngestStream): tuple[id: BlobId, size: BiggestInt] = + ## Cancel and close ingest stream + assert(not s.cancelImpl.isNil) + s.cancelImpl(s) + proc finish*(s: IngestStream): tuple[id: BlobId, size: BiggestInt] = ## Finish ingest stream assert(not s.finishImpl.isNil)