Add size to BlobStream, cancel to IngestStream

This commit is contained in:
Ehmry - 2019-02-08 14:29:30 +01:00
parent 52c1879630
commit 3aa8a90265
1 changed files with 11 additions and 0 deletions

View File

@ -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)