Add a minimalistic duck typing based stream representation.
This commit is contained in:
parent
a9905ddcd9
commit
4c6f26bd00
2 changed files with 19 additions and 1 deletions
16
source/vibe/core/stream.d
Normal file
16
source/vibe/core/stream.d
Normal file
|
@ -0,0 +1,16 @@
|
|||
module vibe.core.stream;
|
||||
|
||||
enum isInputStream(T) = __traits(compiles, {
|
||||
T s;
|
||||
ubyte[] buf;
|
||||
if (!s.empty)
|
||||
s.read(buf);
|
||||
if (s.leastSize > 0)
|
||||
s.read(buf);
|
||||
});
|
||||
|
||||
enum isOutputStream(T) = __traits(compiles, {
|
||||
T s;
|
||||
const(ubyte)[] buf;
|
||||
s.write(buf);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue