byteable-0.1.1: Type class for sequence of bytes

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | good
Safe Haskell | None
Language | Haskell98

Data.Byteable

Description

Synopsis

- class Byteable a where
  - toBytes :: a -> ByteString
  - byteableLength :: a -> Int
  - withBytePtr :: a -> (Ptr Word8 -> IO b) -> IO b
- constEqBytes :: Byteable a => a -> a -> Bool

# Documentation

class Byteable a where Source #

Class of things that can generate sequence of bytes

Minimal complete definition

toBytes

Methods

toBytes :: a -> ByteString Source #

Convert a byteable type to a bytestring

byteableLength :: a -> Int Source #

Return the size of the byteable .

withBytePtr :: a -> (Ptr Word8 -> IO b) -> IO b Source #

Provide a way to look at the data of a byteable type with a ptr.

#### Instances

Instances details

Byteable ByteString Source # |
Instance details Defined in Data.Byteable Methods toBytes :: ByteString -> ByteString Source # byteableLength :: ByteString -> Int Source # withBytePtr :: ByteString -> (Ptr Word8 -> IO b) -> IO b Source #

constEqBytes :: Byteable a => a -> a -> Bool Source #

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.