tubes icon indicating copy to clipboard operation
tubes copied to clipboard

Add fountToBytes, bytesToFount

Open wsanchez opened this issue 8 years ago • 0 comments

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.

wsanchez avatar May 31 '17 17:05 wsanchez