Copyright | © 2015 Patryk Zadarnowski <pat@jantar.org> |
---|---|
License | BSD3 |
Maintainer | pat@jantar.org |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Control.Quiver.ByteString
Description
When binary data is streamed through a Quiver processor, it's often partitioned arbitrarily into packets with no semantic significance, beyond facilitation of processing in constant space. This is similar to the chunking mechanism within lazy bytestrings, and, accordingly, it's often convenient to unify the two mechanisms, by converting between processors over lazy bytestrings and processors over strict chunks of these bytestrings. This module provides efficient implementations of these conversions.
- toChunks :: Functor f => SP Lazy.ByteString ByteString.ByteString f ()
- fromChunks :: Functor f => Int64 -> Int64 -> SP ByteString.ByteString Lazy.ByteString f [ByteString.ByteString]
- fromChunks' :: Monad f => Int64 -> Int64 -> SP ByteString.ByteString Lazy.ByteString f e
- qGet :: Handle -> Int -> SProducer ByteString.ByteString IO IOException
- qPut :: Handle -> SConsumer ByteString.ByteString IO IOException
- qReadFile :: FilePath -> Int -> SProducer ByteString.ByteString IO IOException
- qWriteFile :: FilePath -> SConsumer ByteString.ByteString IO IOException
- qAppendFile :: FilePath -> SConsumer ByteString.ByteString IO IOException
Documentation
toChunks :: Functor f => SP Lazy.ByteString ByteString.ByteString f () Source
A processors that converts a stream of lazy bytestrings into a stream of their chunks.
fromChunks :: Functor f => Int64 -> Int64 -> SP ByteString.ByteString Lazy.ByteString f [ByteString.ByteString] Source
A processors that converts a stream of strict bytestring chunks into a stream of lazy bytestrings with the specified minimum and maximum size, without copying any data. If the input does not provide enough data to complete the final byte string of the minimum requested length, the stream processor will fail with the incomplete list of chunks.
fromChunks' :: Monad f => Int64 -> Int64 -> SP ByteString.ByteString Lazy.ByteString f e Source
A processors that converts a stream of strict bytestring chunks into a stream of lazy bytestrings with the specified minimum and maximum size, without copying any data. This processor always emits all of its input, so if the input does not provide enough data to complete the final byte string of the minimum requested length, the final byte string emitted by the stream will be shorter than the requested minimum.
qGet :: Handle -> Int -> SProducer ByteString.ByteString IO IOException Source
Quiver producer that reads the specified file handle in strict chunks,
each up to n
bytes in size.
qPut :: Handle -> SConsumer ByteString.ByteString IO IOException Source
Quiver consumer that writes its input to the specified file handle.
qReadFile :: FilePath -> Int -> SProducer ByteString.ByteString IO IOException Source
Quiver producer that reads the specified file in strict chunks,
each up to n
bytes in size.
qWriteFile :: FilePath -> SConsumer ByteString.ByteString IO IOException Source
Quiver consumer that writes its input to the specified file.
qAppendFile :: FilePath -> SConsumer ByteString.ByteString IO IOException Source
Quiver consumer that appends its input to the specified file.