Copyright | (c) 2013, Stijn van Drongelen |
---|---|
License | MIT |
Maintainer | rhymoid@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- toByteString :: UUID -> ByteString
- fromByteString :: ByteString -> Maybe UUID
- toWords :: UUID -> (Word32, Word32, Word32, Word32)
- fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
- data UUID :: *
- toString :: UUID -> String
- fromString :: String -> Maybe UUID
- toASCIIBytes :: UUID -> ByteString
- fromASCIIBytes :: ByteString -> Maybe UUID
- toLazyASCIIBytes :: UUID -> ByteString
- fromLazyASCIIBytes :: ByteString -> Maybe UUID
- null :: UUID -> Bool
- nil :: UUID
- swapTupleEndianity :: (Word32, Word32, Word32, Word32) -> (Word32, Word32, Word32, Word32)
- swapListEndianity :: [Word8] -> [Word8]
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.
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 :: *
Convert a UUID into a hypenated string using lower-case letters. Example:
toString <$> fromString "550e8400-e29b-41d4-a716-446655440000"
fromString :: String -> Maybe UUID
toASCIIBytes :: UUID -> ByteString
Convert a UUID into a hyphentated string using lower-case letters, packed
as ASCII bytes into ByteString
.
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
.
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.