Safe Haskell | None |
---|---|
Language | Haskell98 |
Module define byte sources.
- class ByteSource src where
- fill :: (LengthUnit len, ByteSource src) => len -> src -> Pointer -> IO (FillResult src)
- processChunks :: (MonadIO m, LengthUnit chunkSize, ByteSource src) => m a -> (BYTES Int -> m b) -> src -> chunkSize -> Pointer -> m b
- class InfiniteSource src where
- slurp :: (LengthUnit len, InfiniteSource src) => len -> src -> Pointer -> IO src
- class ByteSource src => PureByteSource src
- data FillResult a
- withFillResult :: (a -> b) -> (BYTES Int -> b) -> FillResult a -> b
Documentation
class ByteSource src where Source #
Abstract byte sources. A bytesource is something that you can use to fill a buffer.
fillBytes :: BYTES Int -> src -> Pointer -> IO (FillResult src) Source #
Fills a buffer from the source.
fillBytes :: InfiniteSource src => BYTES Int -> src -> Pointer -> IO (FillResult src) Source #
Fills a buffer from the source.
ByteSource Handle Source # | |
ByteSource ByteString Source # | |
ByteSource ByteString Source # | |
ByteSource src => ByteSource [src] Source # | |
ByteSource src => ByteSource (Maybe src) Source # | |
fill :: (LengthUnit len, ByteSource src) => len -> src -> Pointer -> IO (FillResult src) Source #
A version of fillBytes that takes type safe lengths as input.
processChunks :: (MonadIO m, LengthUnit chunkSize, ByteSource src) => m a -> (BYTES Int -> m b) -> src -> chunkSize -> Pointer -> m b Source #
Process data from a source in chunks of a particular size.
class InfiniteSource src where Source #
Never ending stream of bytes. The reads to the stream might get delayed but it will always return the number of bytes that were asked for.
slurp :: (LengthUnit len, InfiniteSource src) => len -> src -> Pointer -> IO src Source #
class ByteSource src => PureByteSource src Source #
A byte source src is pure if filling from it does not have any
other side effect on the state of the byte source. Formally, two
different fills form the same source should fill the buffer with
the same bytes. This additional constraint on the source helps to
purify certain crypto computations like computing the hash or mac
of the source. Usualy sources like ByteString
etc are pure byte
sources. A file handle is a byte source that is not a pure
source.
PureByteSource ByteString Source # | |
PureByteSource ByteString Source # | |
PureByteSource src => PureByteSource [src] Source # | |
PureByteSource src => PureByteSource (Maybe src) Source # | |
data FillResult a Source #
This type captures the result of a fill operation.
:: (a -> b) | stuff to do when filled |
-> (BYTES Int -> b) | stuff to do when exhausted |
-> FillResult a | the fill result to process |
-> b |
Combinator to handle a fill result.