-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type class for sequence of bytes
--   
--   Abstract class to manipulate sequence of bytes
--   
--   The use case of this class is abstracting manipulation of types that
--   are just wrapping a bytestring with stronger and more meaniful name.
--   
--   Usual definition of those types are of the form: newtype MyType =
--   MyType ByteString
@package byteable
@version 0.1.1


module Data.Byteable

-- | Class of things that can generate sequence of bytes
class Byteable a

-- | Convert a byteable type to a bytestring
toBytes :: Byteable a => a -> ByteString

-- | Return the size of the byteable .
byteableLength :: Byteable a => a -> Int

-- | Provide a way to look at the data of a byteable type with a ptr.
withBytePtr :: Byteable a => a -> (Ptr Word8 -> IO b) -> IO b

-- | A constant time equality test for 2 byteable objects.
--   
--   If objects are of 2 different sizes, the function will abort early
--   without comparing any bytes.
--   
--   compared to == , this function will go over all the bytes present
--   before yielding a result even when knowing the overall result early in
--   the processing.
constEqBytes :: Byteable a => a -> a -> Bool
instance Data.Byteable.Byteable Data.ByteString.Internal.Type.ByteString
