tubes
tubes copied to clipboard
Add fountToBytes, bytesToFount
Add fountToBytes, bytesToFount functions:
def fountToBytes(fount):
# type: (IFount) -> Deferred[bytes]
def collect(chunks):
# type: (Iterable[bytes]) -> bytes
return b"".join(chunks)
d = fountToDeferred(fount)
d.addCallback(collect)
return d
def bytesToFount(data):
# type: (bytes) -> IFount
…
These are at least useful in testing, so that one can create a fount with some data that can can be fed into a tube, or get out the data pouring out of a tube.