Copyright | (c) The University of Glasgow 2001-2009 (c) Giovanni Campagna <[email protected]> 2015 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | [email protected] |
Stability | unstable |
Portability | non-portable (GHC Extensions) |
Safe Haskell | None |
Language | Haskell2010 |
This module contains support for serializing a Compact for network transmission and on-disk storage.
Since: 1.0.0
Synopsis
- data SerializedCompact a = SerializedCompact {
- serializedCompactBlockList :: [(Ptr a, Word)]
- serializedCompactRoot :: Ptr a
- withSerializedCompact :: Compact a -> (SerializedCompact a -> IO c) -> IO c
- importCompact :: SerializedCompact a -> (Ptr b -> Word -> IO ()) -> IO (Maybe (Compact a))
- importCompactByteStrings :: SerializedCompact a -> [ByteString] -> IO (Maybe (Compact a))
Documentation
data SerializedCompact a Source #
A serialized version of the Compact
metadata (each block with
address and size and the address of the root). This structure is
meant to be sent alongside the actual Compact
data. It can be
sent out of band in advance if the data is to be sent over RDMA
(which requires both sender and receiver to have pinned buffers).
SerializedCompact | |
|
withSerializedCompact :: Compact a -> (SerializedCompact a -> IO c) -> IO c Source #
Serialize the Compact
, and call the provided function with
with the Compact
serialized representation. It is not safe
to return the pointer from the action and use it after
the action completes: all uses must be inside this bracket,
since we cannot guarantee that the compact region will stay
live from the Ptr
object. For example, it would be
unsound to use unsafeInterleaveIO
to lazily construct
a lazy bytestring from the Ptr
.
importCompact :: SerializedCompact a -> (Ptr b -> Word -> IO ()) -> IO (Maybe (Compact a)) Source #
Deserialize a SerializedCompact
into a in-memory Compact
. The
provided function will be called with the address and size of each
newly allocated block in succession, and should fill the memory
from the external source (eg. by reading from a socket or from disk)
importCompact
can return Nothing if the Compact
was corrupt
or it had pointers that could not be adjusted.
importCompactByteStrings :: SerializedCompact a -> [ByteString] -> IO (Maybe (Compact a)) Source #
Convenience function for importing a compact region that is represented
by a list of strict ByteString
s.