-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple mutable low-level buffer for IO
--
-- Simple mutable low-level buffer for IO
@package buffer
@version 0.5.0.1
module Buffer
-- | Mutable buffer.
data Buffer
-- | Create a new buffer of the specified initial capacity.
new :: Int -> IO Buffer
-- | Prepares the buffer to be filled with at maximum the specified amount
-- of bytes, then uses the pointer-action to populate it. It is your
-- responsibility to ensure that the action does not exceed the space
-- limit.
--
-- The pointer-action returns the amount of bytes it actually writes to
-- the buffer. That amount then is used to move the buffer's cursor
-- accordingly. It can also produce some result, which will then
-- be emitted by push.
--
-- It also aligns or grows the buffer if required.
push :: Buffer -> Int -> (Ptr Word8 -> IO (Int, result)) -> IO result
-- | Push a byte array into the buffer.
pushBytes :: Buffer -> ByteString -> IO ()
-- | Push a storable value into the buffer.
pushStorable :: (Storable storable) => Buffer -> storable -> IO ()
-- | Pulls the specified amount of bytes from the buffer using the provided
-- pointer-action, freeing the buffer from the pulled bytes afterwards.
--
-- In case the buffer does not contain enough bytes yet, the second
-- action is called instead, given the amount of required bytes missing.
-- You should use that action to refill the buffer accordingly and pull
-- again.
pull :: Buffer -> Int -> (Ptr Word8 -> IO result) -> (Int -> IO result) -> IO result
-- | Pulls the specified amount of bytes, converting them into
-- result, if the buffer contains that amount.
--
-- In case the buffer does not contain enough bytes yet, the second
-- action is called instead, given the amount of required bytes missing.
-- You should use that action to refill the buffer accordingly and pull
-- again.
pullBytes :: Buffer -> Int -> (ByteString -> result) -> (Int -> IO result) -> IO result
-- | Pulls a storable value, converting it into result, if the
-- buffer contains enough bytes.
--
-- In case the buffer does not contain enough bytes yet, the second
-- action is called instead, given the amount of required bytes missing.
-- You should use that action to refill the buffer accordingly and pull
-- again.
pullStorable :: (Storable storable) => Buffer -> (storable -> result) -> (Int -> IO result) -> IO result
-- | Create a bytestring representation without modifying the buffer.
getBytes :: Buffer -> IO ByteString
-- | Get how much space is occupied by the buffer's data.
getSpace :: Buffer -> IO Int