| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
IPLD.DagCBOR.Decoder.Arguments
Contents
- Type class for resolving argument types.
- Implements Argument for Integer types
- Stores read CBOR integers
- Implements Arguments for special items (Booleans, Floats, etc)
- Stores read CBOR simple types
- Implements Argument for Collections (Arrays, Maps, Strings, etc)
- Implements Arguments for CID tags.
- DecoderMethod utilities
- Extracts major identifiers and major parameters from raw bytes.
Description
Synopsis
- class Argument a where
- data Ints
- intsSizeOf :: Ints -> Int
- type IntData = Word64
- downcastIntData :: forall a. (Integral a, Bounded a) => IntData -> Okay a
- data Simple
- data SimpleData
- simpleSizeOf :: Simple -> Int
- data Collection
- data Tag = Tag
- extractByte :: BinaryTranscoder bxc => DecoderMethod Word8 bxc
- extractBytes :: BinaryTranscoder bxc => Int -> DecoderMethod bxc bxc
- extractIntData :: BinaryTranscoder bxc => Ints -> DecoderMethod IntData bxc
- dropBytes :: BinaryTranscoder bxc => IntData -> DecoderRoutine bxc
- removeOctet :: BinaryTranscoder bxc => Octet -> DecoderRoutine bxc
- maskMajorID :: Word8 -> Word8
- maskMajorArg :: Word8 -> Word8
Type class for resolving argument types.
class Argument a where Source #
Type-class for parsing argument types.
Instances
| Argument Collection Source # | Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3-3.8 |
Defined in IPLD.DagCBOR.Decoder.Arguments | |
| Argument Ints Source # | Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3-2 |
| Argument Simple Source # | Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3.3 And the constraints from: https://ipld.io/specs/codecs/dag-cbor/spec/#strictness |
| Argument Tag Source # | Implements tags for DAG-CBOR, see: https://ipld.io/specs/codecs/dag-cbor/spec/#strictness |
| Argument MajorType Source # | Parses the major-type from a byte. |
Implements Argument for Integer types
Represents the possible 5-bits following the 3-bit major for an integer value (signed or unsigned). Encodes how to interpret the following bytes or the current argument.
Constructors
| Ints5Bits Word8 | For values < 24 we can store in the lower 5 bits of the byte |
| Ints8Bits | For 8-bit values >= 24, we use the next byte following the idenitfier. |
| Ints16Bits | For 16-bit values we use the next 2 bytes following the identifier. |
| Ints32Bits | For 32-bit values we use the next 4 bytes following the identifier. |
| Ints64Bits | For 64-bit values we use the next 8 bytes following the identifier. |
Instances
| Show Ints Source # | |
| Eq Ints Source # | |
| Argument Ints Source # | Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3-2 |
| BinaryTranscoder bxc => Supplemental Ints IntData bxc Source # | Implements reading a Number after an Ints argument. All numbers get stored in a 64-bit integer for performance. |
Defined in IPLD.DagCBOR.Decoder.Supplemental | |
Stores read CBOR integers
Implements Arguments for special items (Booleans, Floats, etc)
Represents the possible arguments following a "simple" (here, special) major type. Used to store floats and some familiar JSON primatives.
Constructors
| SimpleBool Bool | Represents true + false. |
| SimpleNull | Represents JSON style null. |
| SimpleUndefined | Represents JSON style undefined. |
| FloatHalf | For 16-bit half floats in the next 2 bytes. |
| FloatSingle | For 32-bit single floats in the next 4 bytes. |
| FloatDouble | For 64-bit double floats in the next 8 bytes. |
| StopCollection | Marks the end of an indefinite grouping. Unsupported in DAG-CBOR. |
Instances
| Show Simple Source # | |
| Eq Simple Source # | |
| Argument Simple Source # | Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3.3 And the constraints from: https://ipld.io/specs/codecs/dag-cbor/spec/#strictness |
| BinaryTranscoder bxc => Supplemental Simple SimpleData bxc Source # | Reads simple values. For floating points, it does: 1. Takes n number bytes from the ByteString 2. Validates bytes taken to matches the FloatData type size. 3. Copy those bytes to a corresponding sized Word type 4. Check if they are a valid IPLD Float (Not -∞, ∞, or NaN) 5. Updates the bytes to remove the floating point bytes. Otherwise, it packages the simple value and leaves the bytes unmodified. |
Defined in IPLD.DagCBOR.Decoder.Supplemental Methods decodeSup :: Simple -> Okay (DecoderMethod SimpleData bxc) Source # | |
Stores read CBOR simple types
data SimpleData Source #
Stores values from Special arguments.
Instances
| Show SimpleData Source # | |
Defined in IPLD.DagCBOR.Decoder.Arguments Methods showsPrec :: Int -> SimpleData -> ShowS # show :: SimpleData -> String # showList :: [SimpleData] -> ShowS # | |
| Eq SimpleData Source # | |
Defined in IPLD.DagCBOR.Decoder.Arguments | |
| BinaryTranscoder bxc => Supplemental Simple SimpleData bxc Source # | Reads simple values. For floating points, it does: 1. Takes n number bytes from the ByteString 2. Validates bytes taken to matches the FloatData type size. 3. Copy those bytes to a corresponding sized Word type 4. Check if they are a valid IPLD Float (Not -∞, ∞, or NaN) 5. Updates the bytes to remove the floating point bytes. Otherwise, it packages the simple value and leaves the bytes unmodified. |
Defined in IPLD.DagCBOR.Decoder.Supplemental Methods decodeSup :: Simple -> Okay (DecoderMethod SimpleData bxc) Source # | |
Implements Argument for Collections (Arrays, Maps, Strings, etc)
data Collection Source #
Represents the possible 5-bits following the 3-bit major for byte strings, text, arrays and mappings.
Constructors
| CollectionsLength Ints | Provides the length for some grouping of data within the same format as integers' arguments. |
| CollectionsIndefinite | Indefinite length groupings. Unsupported in DAG-CBOR. |
Instances
Implements Arguments for CID tags.
Represents a tag for marking special data. DAG-CBOR only supports tagging for CID data.
Constructors
| Tag |
Instances
| Show Tag Source # | |
| Eq Tag Source # | |
| Argument Tag Source # | Implements tags for DAG-CBOR, see: https://ipld.io/specs/codecs/dag-cbor/spec/#strictness |
| BinaryTranscoder bxc => Supplemental Tag CID bxc Source # | Implements reading a Supplemental CID from the matching tag, see: https://github.com/ipld/cid-cbor/ https://ipld.io/specs/codecs/dag-cbor/spec/#links |
Defined in IPLD.DagCBOR.Decoder.Supplemental | |
DecoderMethod utilities
extractByte :: BinaryTranscoder bxc => DecoderMethod Word8 bxc Source #
Extracts a single byte from the transcoder data.
extractBytes :: BinaryTranscoder bxc => Int -> DecoderMethod bxc bxc Source #
Extracts multiple bytes from a transcoder.
extractIntData :: BinaryTranscoder bxc => Ints -> DecoderMethod IntData bxc Source #
Extracts an Integer value given the rule.
dropBytes :: BinaryTranscoder bxc => IntData -> DecoderRoutine bxc Source #
Extracts some number of bytes from the transcoder data.
removeOctet :: BinaryTranscoder bxc => Octet -> DecoderRoutine bxc Source #
Removes some value and only suceeds when it matches its first octet in the transcoder.
Extracts major identifiers and major parameters from raw bytes.
maskMajorID :: Word8 -> Word8 Source #
maskMajorArg :: Word8 -> Word8 Source #