HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduleouroboros-consensus-4.2.1.0

Ouroboros.Consensus.Util.IndexedMemPack

  • 2 classes
  • 5 values
classclass MemPack a where
#

Efficient serialization interface that operates directly on memory buffers.

Methods

  • typeName :: String

    Name of the type that is being deserialized for error reporting. Default implementation relies on Typeable.

  • packedByteCount :: a -> Int

    Report the exact size in number of bytes that packed version of this type will occupy. It is very important to get this right, otherwise packM will result in a runtime exception. Another words this is the expected property that it should hold:

    Property
    packedByteCount a == bufferByteCount (pack a)
  • packM :: a -> Pack s ()

    Write binary representation of a type into the MutableByteArray which can be accessed with ask, whenever direct operations on it are necessary.

  • unpackM :: Buffer b => Unpack s b a

    Read binary representation of the type directly from the buffer, which can be accessed with ask when necessary.

    Warning - Direct reads from the buffer should be preceded with advancing the buffer offset within MonadState by the exact number of bytes that gets consumed from that buffer.

    ⚠ - Violation of the above rule will lead to segfaults.

Instances60MemPack, …
classclass IndexedMemPack (l :: Type -> (Type -> Type -> Type) -> Type) blk a where
#

Methods

Instances2IndexedMemPack