cardano-ledger-binary-1.3.2.0: Binary serialization library used throughout ledger
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Binary.Encoding.Encoder

Synopsis

Decoders

data Tokens Source #

A flattened representation of a term, which is independent of any underlying binary representation, but which we later serialise into CBOR format.

Since: cborg-0.2.0.0

Instances

Instances details
Show Tokens 
Instance details

Defined in Codec.CBOR.Encoding

Eq Tokens 
Instance details

Defined in Codec.CBOR.Encoding

Methods

(==)TokensTokensBool Source #

(/=)TokensTokensBool Source #

ToCBOR (TokensTokens) 
Instance details

Defined in Cardano.Binary.ToCBOR

Methods

toCBOR ∷ (TokensTokens) → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (TokensTokens) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [TokensTokens] → Size Source #

EncCBOR (TokensTokens) Source # 
Instance details

Defined in Cardano.Ledger.Binary.Encoding.EncCBOR

Methods

encCBOR ∷ (TokensTokens) → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (TokensTokens) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [TokensTokens] → Size Source #

withCurrentEncodingVersion ∷ (VersionEncoding) → Encoding Source #

Get access to the current version being used in the encoder

enforceEncodingVersionVersionEncodingEncoding Source #

Ignore the current version of the encoder and enforce the supplied one instead.

ifEncodingVersionAtLeast Source #

Arguments

Version 
Encoding

Use this encoder if current encoder version is larger or equal to the supplied Version

Encoding

Use this encoder if current encoder version is lower than the supplied Version

Encoding 

Conditionoly choose the encoder newer or older deceder, depending on the current version. Supplied version acts as a pivot.

Example

Custom

encodeMaybe ∷ (a → Encoding) → Maybe a → Encoding Source #

encodeNullMaybe ∷ (a → Encoding) → Maybe a → Encoding Source #

Alternative way to encode a Maybe type.

Note - this is not the default method for encoding Maybe, use encodeMaybe instead

encodeNullStrictMaybe ∷ (a → Encoding) → StrictMaybe a → Encoding Source #

Alternative way to encode a Maybe type.

Note - this is not the default method for encoding StrictMaybe, use encodeStrictMaybe instead

encodePair ∷ (a → Encoding) → (b → Encoding) → (a, b) → Encoding Source #

Deprecated: In favor of encodeTuple

encodeTuple ∷ (a → Encoding) → (b → Encoding) → (a, b) → Encoding Source #

encodeRatio ∷ (t → Encoding) → Ratio t → Encoding Source #

encodeEnumEnum a ⇒ a → Encoding Source #

Containers

encodeList ∷ (a → Encoding) → [a] → Encoding Source #

Encode a list. Versions variance:

  • [>= 2] - Variable length encoding for lists longer than 23 elements, otherwise exact length encoding
  • [< 2] - Variable length encoding

encodeSeq ∷ (a → Encoding) → Seq a → Encoding Source #

Encode a Seq. Variable length encoding for Sequences larger than 23 elements, otherwise exact length encoding

encodeSet ∷ (a → Encoding) → Set a → Encoding Source #

Encode a Set. Versions variance:

  • [>= 9] - Variable length encoding for Sets larger than 23 elements, otherwise exact length encoding. Prefixes with a special 258 setTag.
  • [>= 2] - Variable length encoding for Sets larger than 23 elements, otherwise exact length encoding
  • [< 2] - Variable length encoding. Prefixes with a special 258 setTag.

encodeMap ∷ (k → Encoding) → (v → Encoding) → Map k v → Encoding Source #

Encode a Map. Versions variance:

  • [>= 2] - Variable length encoding for Maps larger than 23 key value pairs, otherwise exact length encoding
  • [< 2] - Variable length encoding.

encodeVMap ∷ (Vector kv k, Vector vv v) ⇒ (k → Encoding) → (v → Encoding) → VMap kv vv k v → Encoding Source #

Mimics Map encoder encodeMap identically.

encodeVectorVector v a ⇒ (a → Encoding) → v a → Encoding Source #

Generic encoder for vectors. Its intended use is to allow easy definition of EncCBOR instances for custom vector

variableListLenEncoding Source #

Arguments

Int

Number of elements in the encoded data structure.

Encoding

Encoding for the actual data structure

Encoding 

Conditionally use variable length encoding for list like structures with length larger than 23, otherwise use exact list length encoding.

Helpers

encodeFoldableEncoderFoldable f ⇒ (a → Encoding) → f a → Encoding Source #

Encode any Foldable with the variable list length encoding, which will use indefinite encoding over 23 elements and definite otherwise.

encodeFoldableAsIndefLenListFoldable f ⇒ (a → Encoding) → f a → Encoding Source #

Encode any Foldable with indefinite list length encoding

encodeFoldableMapEncoder Source #

Arguments

Foldable f 
⇒ (Word → a → Maybe Encoding)

A function that accepts an index of the value in the foldable data strucure, the actual value and optionally produces the encoding of the value and an index if that value should be encoded.

→ f a 
Encoding 

Encode a data structure as a Map with the 0-based index for a Key to a value. Uses variable map length encoding, which means an indefinite encoding for maps with over 23 elements and definite otherwise.

lengthThresholdInt Source #

This is the optimal maximum number for encoding exact length. Above that threashold using variable length encoding will result in less bytes on the wire.

Time

Network

Original