uuid-le-0.2014.1: Universally Unique Identifiers with little-endian-ish encoding tools

Copyright(c) 2013, Stijn van Drongelen
LicenseMIT
Maintainerrhymoid@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.UUID.LittleEndian

Contents

Description

 

Synopsis

Codec functions

toByteString :: UUID -> ByteString Source

Encode a UUID into a ByteString in little-endian-ish byte order.

fromByteString :: ByteString -> Maybe UUID Source

Extract a UUID from a ByteString in little-endian-ish byte order. The argument must be 16 bytes long, otherwise Nothing is returned.

toWords :: UUID -> (Word32, Word32, Word32, Word32) Source

Covert a UUID into a sequence of Word32 values. When stored in network byte order, this tuple encodes the UUID in little-endian-ish byte order.

fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID Source

Create a UUID from a sequence of Word32 values. The opposite of toWords.

Re-exported entities from uuid

Nota bene: the Storable and Binary instances of UUID use the encoding specified in RFC 4122, rather than the little-endian-ish encoding.

data UUID :: *

The UUID type. A Random instance is provided which produces version 4 UUIDs as specified in RFC 4122. The Storable and Binary instances are compatible with RFC 4122, storing the fields in network order as 16 bytes.

toString :: UUID -> String

Convert a UUID into a hypenated string using lower-case letters. Example:

 toString <$> fromString "550e8400-e29b-41d4-a716-446655440000"

fromString :: String -> Maybe UUID

If the passed in String can be parsed as a UUID, it will be. The hyphens may not be omitted. Example:

 fromString "c2cc10e1-57d6-4b6f-9899-38d972112d8c"

Hex digits may be upper or lower-case.

toASCIIBytes :: UUID -> ByteString

Convert a UUID into a hyphentated string using lower-case letters, packed as ASCII bytes into ByteString.

This should be equivalent to toString with pack.

fromASCIIBytes :: ByteString -> Maybe UUID

If the passed in ByteString can be parsed as an ASCII representation of a UUID, it will be. The hyphens may not be omitted.

This should be equivalent to fromString with unpack.

toLazyASCIIBytes :: UUID -> ByteString

Similar to toASCIIBytes except we produce a lazy ByteString.

fromLazyASCIIBytes :: ByteString -> Maybe UUID

Similar to fromASCIIBytes except parses from a lazy ByteString.

null :: UUID -> Bool

Returns true if the passed-in UUID is the nil UUID.

nil :: UUID

The nil UUID, as defined in RFC 4122. It is a UUID of all zeros. null u iff u == nil.

Endianity tools

swapTupleEndianity :: (Word32, Word32, Word32, Word32) -> (Word32, Word32, Word32, Word32) Source

Swaps the endianity of a UUID Word32 tuple.

swapListEndianity :: [Word8] -> [Word8] Source

Swaps the endianity of a UUID byte list, if the list is at least eight bytes long. Otherwise, it returns the original list.