cardano-ledger-core-0.1.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe Haskell None
Language Haskell2010

Cardano.Ledger.Serialization

Synopsis

Documentation

newtype CborSeq a Source #

Constructors

CborSeq

runByteBuilder :: Int -> Builder -> ByteString Source #

Run a ByteString Builder using a strategy aimed at making smaller things efficiently.

It takes a size hint and produces a strict ByteString . This will be fast when the size hint is the same or slightly bigger than the true size.

data Sized a Source #

A CBOR deserialized value together with its size. When deserializing use either sizedDecoder or its FromCBOR instance.

Use mkSized to construct such value.

Constructors

Sized

Fields

  • sizedValue :: !a
  • sizedSize :: Int64

    Overhead in bytes. The field is lazy on purpose, because it might not be needed, but it can be expensive to compute.

Instances

Instances details
Eq a => Eq ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

Show a => Show ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

Generic ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

Associated Types

type Rep ( Sized a) :: Type -> Type Source #

ToCBOR a => ToCBOR ( Sized a) Source #

Discards the size.

Instance details

Defined in Cardano.Ledger.Serialization

FromCBOR a => FromCBOR ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

NoThunks a => NoThunks ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

type Rep ( Sized a) Source #
Instance details

Defined in Cardano.Ledger.Serialization

type Rep ( Sized a) = D1 (' MetaData "Sized" "Cardano.Ledger.Serialization" "cardano-ledger-core-0.1.0.0-3EJt5rxsPizAWHDEqGPh9V" ' False ) ( C1 (' MetaCons "Sized" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "sizedValue") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 a) :*: S1 (' MetaSel (' Just "sizedSize") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Int64 )))

mkSized :: ToCBOR a => a -> Sized a Source #

Construct a Sized value by serializing it first and recording the amount of bytes it requires. Note, however, CBOR serialization is not canonical, therefore it is *NOT* a requirement that this property holds:

sizedSize (mkSized a) === sizedSize (unsafeDeserialize (serialize a) :: a)