License | BSD-Style |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Copyright : Copyright © 2014 Nicolas DI PRIMA
Maintainer : Nicolas DI PRIMA nicolas@di-prima.fr Stability : experimental Portability : unknown
- data Packer a
- data Result a
- = PackerMore a Cache
- | PackerFail String
- pack :: Packer a -> Int -> Either String ByteString
- putStorable :: Storable storable => storable -> Packer ()
- putByteString :: ByteString -> Packer ()
- fillList :: Storable storable => [storable] -> Packer ()
- fillUpWith :: Storable storable => storable -> Packer ()
- skip :: Int -> Packer ()
- skipStorable :: Storable storable => storable -> Packer ()
Documentation
Packing result:
- PackerOK a -> means the bytestring has been filled with the given data
- PackerMore a cache -> a temporary
PackerMore a Cache | |
PackerFail String |
pack :: Packer a -> Int -> Either String ByteString Source
pack the given packer into the given bytestring
Operations
put
putStorable :: Storable storable => storable -> Packer () Source
put a storable from the current position in the stream
putByteString :: ByteString -> Packer () Source
put a Bytestring from the current position in the stream
If the ByteString ins null, then do nothing
fillList :: Storable storable => [storable] -> Packer () Source
Will put the given storable list from the current position in the stream to the end.
This function will fail with not enough storage if the given storable can't be written (not enough space)
example: > pack (fillList $ [1..] :: Word8) 9 ==> "123456789" > pack (fillList $ [1..] :: Word32) 4 ==> "1000" > pack (fillList $ [1..] :: Word32) 64 -- will work > pack (fillList $ [1..] :: Word32) 1 -- will fail (not enough space) > pack (fillList $ [1..] :: Word32) 131 -- will fail (not enough space)
fillUpWith :: Storable storable => storable -> Packer () Source
fill up from the current position in the stream to the end
it is basically: > fillUpWith s == fillList (repeat s)
skip
skipStorable :: Storable storable => storable -> Packer () Source
skip the size of a storable from the current position in the stream