ipldm
Safe HaskellSafe-Inferred
LanguageGHC2021

IPLD.DagCBOR.Decoder.Arguments

Description

 
Synopsis

Type class for resolving argument types.

class Argument a where Source #

Type-class for parsing argument types.

Methods

decodeArg :: Word8 -> Okay a Source #

Decodes type a from parameter id.

Implements Argument for Integer types

data Ints Source #

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

Instances details
Show Ints Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Methods

showsPrec :: Int -> Ints -> ShowS #

show :: Ints -> String #

showList :: [Ints] -> ShowS #

Eq Ints Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Methods

(==) :: Ints -> Ints -> Bool #

(/=) :: Ints -> Ints -> Bool #

Argument Ints Source #

Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3-2

Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

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.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

intsSizeOf :: Ints -> Int Source #

Returns the #bytes a Ints type occupies after its argument.

Stores read CBOR integers

type IntData = Word64 Source #

Type-alias for Word64 for CBOR integer data.

downcastIntData :: forall a. (Integral a, Bounded a) => IntData -> Okay a Source #

For converting IntData into smaller types such as Int.

Implements Arguments for special items (Booleans, Floats, etc)

data Simple Source #

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

Instances details
Show Simple Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Eq Simple Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Methods

(==) :: Simple -> Simple -> Bool #

(/=) :: Simple -> Simple -> Bool #

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

Instance details

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.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

Stores read CBOR simple types

data SimpleData Source #

Stores values from Special arguments.

Instances

Instances details
Show SimpleData Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Eq SimpleData Source # 
Instance details

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.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

simpleSizeOf :: Simple -> Int Source #

Returns the #bytes a Simple type occupies after its argument.

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

Instances details
Show Collection Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Eq Collection Source # 
Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

Argument Collection Source #

Implements the section from: https://datatracker.ietf.org/doc/html/rfc8949#section-3-3.8

Instance details

Defined in IPLD.DagCBOR.Decoder.Arguments

BinaryTranscoder b => Supplemental Collection BytesData b Source #

Implements reading a Supplemental CBOR bytestring data.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

BinaryTranscoder bxc => Supplemental Collection ListData bxc Source #

Implements reading list objects from CBOR.

Instance details

Defined in IPLD.DagCBOR.Decoder.Objects

BinaryTranscoder bxc => Supplemental Collection MapData bxc Source #

Implements reading map objects from CBOR.

Instance details

Defined in IPLD.DagCBOR.Decoder.Objects

BinaryTranscoder bxc => Supplemental Collection Text bxc Source #

Implements reading a Supplemental collection of UTF-8 text.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

BinaryTranscoder b => Supplemental Collection b b Source #

Implements reading a Supplemental collection of binary transcoder data.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

BinaryTranscoder b => Supplemental Collection (ListObj b) b Source #

Chunks DAG-CBOR Lists into list of encoded binary CBOR objects.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

BinaryTranscoder b => Supplemental Collection (MapObj b) b Source #

Chunks DAG-CBOR Map into list of encoded binary CBOR key-value pairs.

Instance details

Defined in IPLD.DagCBOR.Decoder.Supplemental

Implements Arguments for CID tags.

data Tag Source #

Represents a tag for marking special data. DAG-CBOR only supports tagging for CID data.

Constructors

Tag 

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.