Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Ledger.Serialization
Synopsis
-
class
Typeable
a =>
ToCBORGroup
a
where
- toCBORGroup :: a -> Encoding
- encodedGroupSizeExpr :: ( forall x. ToCBOR x => Proxy x -> Size ) -> Proxy a -> Size
- listLen :: a -> Word
- listLenBound :: Proxy a -> Word
-
class
Typeable
a =>
FromCBORGroup
a
where
- fromCBORGroup :: Decoder s a
-
newtype
CBORGroup
a =
CBORGroup
{
- unCBORGroup :: a
-
newtype
CborSeq
a =
CborSeq
{
- unwrapCborSeq :: Seq a
- decodeList :: Decoder s a -> Decoder s [a]
- decodeSeq :: Decoder s a -> Decoder s ( Seq a)
- decodeStrictSeq :: Decoder s a -> Decoder s ( StrictSeq a)
- decodeSet :: Ord a => Decoder s a -> Decoder s ( Set a)
- decodeMap :: Ord a => Decoder s a -> Decoder s b -> Decoder s ( Map a b)
- decodeMapContents :: Decoder s a -> Decoder s [a]
- decodeMapTraverse :: ( Ord a, Applicative t) => Decoder s (t a) -> Decoder s (t b) -> Decoder s (t ( Map a b))
- decodeMaybe :: Decoder s a -> Decoder s ( Maybe a)
- decodeRecordNamed :: Text -> (a -> Int ) -> Decoder s a -> Decoder s a
- decodeRecordNamedT :: ( MonadTrans m, Monad (m ( Decoder s))) => Text -> (a -> Int ) -> m ( Decoder s) a -> m ( Decoder s) a
- decodeRecordSum :: String -> ( Word -> Decoder s ( Int , a)) -> Decoder s a
- decodeNullMaybe :: Decoder s a -> Decoder s ( Maybe a)
- encodeFoldable :: ( ToCBOR a, Foldable f) => f a -> Encoding
- encodeFoldableEncoder :: Foldable f => (a -> Encoding ) -> f a -> Encoding
- encodeFoldableMapEncoder :: Foldable f => ( Word -> a -> Maybe Encoding ) -> f a -> Encoding
- encodeNullMaybe :: (a -> Encoding ) -> Maybe a -> Encoding
- encodeMap :: (a -> Encoding ) -> (b -> Encoding ) -> Map a b -> Encoding
- groupRecord :: forall a s. ( ToCBORGroup a, FromCBORGroup a) => Decoder s a
- ratioToCBOR :: ToCBOR a => Ratio a -> Encoding
- ratioFromCBOR :: ( Bounded a, Integral a, FromCBOR a) => Decoder s ( Ratio a)
- mapToCBOR :: ( ToCBOR a, ToCBOR b) => Map a b -> Encoding
- mapFromCBOR :: ( Ord a, FromCBOR a, FromCBOR b) => Decoder s ( Map a b)
- translateViaCBORAnn :: ( ToCBOR a, FromCBOR ( Annotator b)) => Text -> a -> Except DecoderError b
- ipv4ToBytes :: IPv4 -> ByteString
- ipv4FromBytes :: ByteString -> Either String IPv4
- ipv4ToCBOR :: IPv4 -> Encoding
- ipv4FromCBOR :: Decoder s IPv4
- ipv6ToBytes :: IPv6 -> ByteString
- ipv6FromBytes :: ByteString -> Either String IPv6
- ipv6ToCBOR :: IPv6 -> Encoding
- ipv6FromCBOR :: Decoder s IPv6
- listLenInt :: ToCBORGroup a => a -> Int
- runByteBuilder :: Int -> Builder -> ByteString
- utcTimeToCBOR :: UTCTime -> Encoding
- utcTimeFromCBOR :: Decoder s UTCTime
-
data
Sized
a =
Sized
{
- sizedValue :: !a
- sizedSize :: Int64
- mkSized :: ToCBOR a => a -> Sized a
- sizedDecoder :: Decoder s a -> Decoder s ( Sized a)
Documentation
class Typeable a => ToCBORGroup a where Source #
Methods
toCBORGroup :: a -> Encoding Source #
encodedGroupSizeExpr :: ( forall x. ToCBOR x => Proxy x -> Size ) -> Proxy a -> Size Source #
listLenBound :: Proxy a -> Word Source #
Instances
class Typeable a => FromCBORGroup a where Source #
Methods
fromCBORGroup :: Decoder s a Source #
Instances
FromCBORGroup ProtVer Source # | |
Defined in Cardano.Ledger.BaseTypes Methods fromCBORGroup :: Decoder s ProtVer Source # |
|
FromCBORGroup Ptr Source # | |
Defined in Cardano.Ledger.Credential Methods fromCBORGroup :: Decoder s Ptr Source # |
Constructors
CBORGroup | |
Fields
|
Instances
ToCBORGroup a => ToCBOR ( CBORGroup a) Source # | |
( FromCBORGroup a, ToCBORGroup a) => FromCBOR ( CBORGroup a) Source # | |
Constructors
CborSeq | |
Fields
|
Instances
Foldable CborSeq Source # | |
Defined in Cardano.Ledger.Serialization Methods fold :: Monoid m => CborSeq m -> m Source # foldMap :: Monoid m => (a -> m) -> CborSeq a -> m Source # foldMap' :: Monoid m => (a -> m) -> CborSeq a -> m Source # foldr :: (a -> b -> b) -> b -> CborSeq a -> b Source # foldr' :: (a -> b -> b) -> b -> CborSeq a -> b Source # foldl :: (b -> a -> b) -> b -> CborSeq a -> b Source # foldl' :: (b -> a -> b) -> b -> CborSeq a -> b Source # foldr1 :: (a -> a -> a) -> CborSeq a -> a Source # foldl1 :: (a -> a -> a) -> CborSeq a -> a Source # toList :: CborSeq a -> [a] Source # null :: CborSeq a -> Bool Source # length :: CborSeq a -> Int Source # elem :: Eq a => a -> CborSeq a -> Bool Source # maximum :: Ord a => CborSeq a -> a Source # minimum :: Ord a => CborSeq a -> a Source # |
|
ToCBOR a => ToCBOR ( CborSeq a) Source # | |
FromCBOR a => FromCBOR ( CborSeq a) Source # | |
decodeList :: Decoder s a -> Decoder s [a] Source #
decodeMapContents :: Decoder s a -> Decoder s [a] Source #
decodeMapTraverse :: ( Ord a, Applicative t) => Decoder s (t a) -> Decoder s (t b) -> Decoder s (t ( Map a b)) Source #
decodeRecordNamedT :: ( MonadTrans m, Monad (m ( Decoder s))) => Text -> (a -> Int ) -> m ( Decoder s) a -> m ( Decoder s) a Source #
encodeFoldableMapEncoder :: Foldable f => ( Word -> a -> Maybe Encoding ) -> f a -> Encoding Source #
groupRecord :: forall a s. ( ToCBORGroup a, FromCBORGroup a) => Decoder s a Source #
translateViaCBORAnn :: ( ToCBOR a, FromCBOR ( Annotator b)) => Text -> a -> Except DecoderError b Source #
ipv4ToBytes :: IPv4 -> ByteString Source #
ipv4FromBytes :: ByteString -> Either String IPv4 Source #
ipv4ToCBOR :: IPv4 -> Encoding Source #
ipv4FromCBOR :: Decoder s IPv4 Source #
ipv6ToBytes :: IPv6 -> ByteString Source #
ipv6FromBytes :: ByteString -> Either String IPv6 Source #
ipv6ToCBOR :: IPv6 -> Encoding Source #
ipv6FromCBOR :: Decoder s IPv6 Source #
listLenInt :: ToCBORGroup a => a -> Int Source #
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.
utcTimeToCBOR :: UTCTime -> Encoding Source #
utcTimeFromCBOR :: Decoder s UTCTime 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
|
Instances
Eq a => Eq ( Sized a) Source # | |
Show a => Show ( Sized a) Source # | |
Generic ( Sized a) Source # | |
ToCBOR a => ToCBOR ( Sized a) Source # |
Discards the size. |
FromCBOR a => FromCBOR ( Sized a) Source # | |
NoThunks a => NoThunks ( Sized a) Source # | |
type Rep ( Sized a) Source # | |
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)