diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-12 20:51:07 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-12 20:51:20 +0100 |
commit | 2909766056d5c8663f228205f902f3c77cbc6eeb (patch) | |
tree | 50f2cd8e54a87130c4e4bc0e2f5c9a8203aa2c1b /src | |
parent | a2155217494ef652bbd5fedf3f1e5441e991cd43 (diff) | |
download | chawan-2909766056d5c8663f228205f902f3c77cbc6eeb.tar.gz |
io: remove multistream, teestream
unused (hopefully forever)
Diffstat (limited to 'src')
-rw-r--r-- | src/io/multistream.nim | 27 | ||||
-rw-r--r-- | src/io/teestream.nim | 47 |
2 files changed, 0 insertions, 74 deletions
diff --git a/src/io/multistream.nim b/src/io/multistream.nim deleted file mode 100644 index cf6814ab..00000000 --- a/src/io/multistream.nim +++ /dev/null @@ -1,27 +0,0 @@ -# MultiStream: write to several streams at once when writing to a single -# stream. -# See TeeStream for a pull version. - -import std/streams - -type MultiStream = ref object of Stream - s1: Stream - s2: Stream - -proc tsClose(s: Stream) = - let s = cast[MultiStream](s) - s.s1.close() - s.s2.close() - -proc msWriteData(s: Stream, buffer: pointer, bufLen: int) = - let s = cast[MultiStream](s) - s.s1.writeData(buffer, bufLen) - s.s2.writeData(buffer, bufLen) - -proc newMultiStream*(s1, s2: Stream, closedest = true): MultiStream = - return MultiStream( - s1: s1, - s2: s2, - closeImpl: tsClose, - writeDataImpl: msWriteData - ) diff --git a/src/io/teestream.nim b/src/io/teestream.nim deleted file mode 100644 index f70d8c4f..00000000 --- a/src/io/teestream.nim +++ /dev/null @@ -1,47 +0,0 @@ -# TeeStream: write to another stream when reading from one stream. -# See MultiStream for a push version. - -import std/streams - -type TeeStream = ref object of Stream - source: Stream - dest: Stream - closedest: bool - -proc tsClose(s: Stream) = - let s = cast[TeeStream](s) - s.source.close() - if s.closedest: - s.dest.close() - -proc tsReadData(s: Stream, buffer: pointer, bufLen: int): int = - let s = cast[TeeStream](s) - result = s.source.readData(buffer, bufLen) - s.dest.writeData(buffer, result) - -proc tsReadDataStr(s: Stream, buffer: var string, slice: Slice[int]): int = - let s = cast[TeeStream](s) - result = s.source.readDataStr(buffer, slice) - if result <= 0: return - s.dest.writeData(addr buffer[0], result) - -proc tsAtEnd(s: Stream): bool = - let s = cast[TeeStream](s) - return s.source.atEnd - -proc newTeeStream*(source, dest: Stream, closedest = true): TeeStream = - return TeeStream( - source: source, - dest: dest, - closedest: closedest, - closeImpl: tsClose, - readDataImpl: - cast[proc(s: Stream, buffer: pointer, len: int): int - {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.} - ](tsReadData), - readDataStrImpl: - cast[proc(s: Stream, buffer: var string, slice: Slice[int]): int - {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.} - ](tsReadDataStr), - atEndImpl: tsAtEnd - ) |