cbor_serialization/types

Source   Edit  

Types

CborBytes = distinct seq[byte]
A seqbyte containing valid CBOR. Used to preserve and pass on parts of CBOR to another parser or layer without interpreting it further Source   Edit  
CborError = object of SerializationError
Source   Edit  
CborMajor {.pure.} = enum
  Unsigned = 0, Negative = 1, Bytes = 2, Text = 3, Array = 4, Map = 5, Tag = 6,
  SimpleOrFloat = 7
Source   Edit  
CborNumber = object
  sign*: CborSign
  integer*: uint64
Source   Edit  
CborObjectType = OrderedTable[string, CborValueRef]
Source   Edit  
CborReaderConf = object
  nestedDepthLimit*: int
  arrayElementsLimit*: int
  objectFieldsLimit*: int
  stringLengthLimit*: int
  byteStringLengthLimit*: int
  bigNumBytesLimit*: int
Source   Edit  
CborSign {.pure.} = enum
  None, Neg
Source   Edit  
CborSimpleValue = distinct uint8
Source   Edit  
CborTag[T] = object
  tag*: uint64
  val*: T
Source   Edit  
CborValue = object
  case kind*: CborValueKind
  of CborValueKind.Bytes:
    bytesVal*: seq[byte]
  of CborValueKind.String:
    strVal*: string
  of CborValueKind.Unsigned, CborValueKind.Negative:
    numVal*: CborNumber
  of CborValueKind.Float:
    floatVal*: float64
  of CborValueKind.Object:
    objVal*: CborObjectType
  of CborValueKind.Array:
    arrayVal*: seq[CborValueRef]
  of CborValueKind.Tag:
    tagVal*: CborTag[CborValueRef]
  of CborValueKind.Simple:
    simpleVal*: CborSimpleValue
  of CborValueKind.Bool:
    boolVal*: bool
  of CborValueKind.Null, CborValueKind.Undefined:
    nil
Source   Edit  
CborValueKind {.pure.} = enum
  Bytes, String, Unsigned, Negative, Float, Object, Array, Tag, Simple, Bool,
  Null, Undefined
Source   Edit  
CborVoid = object
Marker used for skipping a CBOR value during parsing Source   Edit  

Consts

cborBreakStopCode = 255
Source   Edit  
cborFalse = 20'u
Source   Edit  
cborMinorIndef = 31'u8
Source   Edit  
cborMinorLen0 = {0'u8..23'u8}
Source   Edit  
cborMinorLen1 = 24'u8
Source   Edit  
cborMinorLen2 = 25'u8
Source   Edit  
cborMinorLen4 = 26'u8
Source   Edit  
cborMinorLen8 = 27'u8
Source   Edit  
cborMinorLens = {0'u8..27'u8}
Source   Edit  
cborNull = 22'u
Source   Edit  
cborTrue = 21'u
Source   Edit  
cborUndefined = 23'u
Source   Edit  
defaultCborReaderConf = (nestedDepthLimit: 512, arrayElementsLimit: 0,
                         objectFieldsLimit: 0, stringLengthLimit: 0,
                         byteStringLengthLimit: 0, bigNumBytesLimit: 64)
Source   Edit  

Procs

func `$`(v: CborSimpleValue): string {....raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: CborBytes): bool {.borrow, ...raises: [], gcsafe, tags: [],
                                   forbids: [].}
Source   Edit  
func `==`(a, b: CborSimpleValue): bool {.borrow, ...raises: [], gcsafe, tags: [],
    forbids: [].}
Source   Edit  
proc `==`(a: CborBytes; b: seq[byte]): bool {.borrow, ...raises: [], gcsafe,
    tags: [], forbids: [].}
Source   Edit  
proc `==`(a: seq[byte]; b: CborBytes): bool {.borrow, ...raises: [], gcsafe,
    tags: [], forbids: [].}
Source   Edit  
func `==`(lhs, rhs: CborValueRef): bool {....raises: [], gcsafe,
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc add(a: var CborBytes; b: byte) {.borrow, ...raises: [], gcsafe, tags: [],
                                      forbids: [].}
Source   Edit  
func contains(x: set[uint8]; y: CborSimpleValue): bool {.borrow, ...raises: [],
    gcsafe, tags: [], forbids: [].}
Source   Edit  
func isFalse(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
    forbids: [].}
Source   Edit  
func isFalsy(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
    forbids: [].}
Source   Edit  
func isNull(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
                                        forbids: [].}
Source   Edit  
func isNullish(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
    forbids: [].}
Source   Edit  
func isTrue(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
                                        forbids: [].}
Source   Edit  
func isUndefined(v: CborSimpleValue): bool {....raises: [], gcsafe, tags: [],
    forbids: [].}
Source   Edit  
func toInt(sign: CborSign): int {....raises: [], gcsafe, tags: [], forbids: [].}
Source   Edit  
proc toInt(val: CborNumber; T: type SomeSignedInt): Opt[T] {....raises: [], gcsafe.}
Converts a CborNumber to a signed integer, if it fits in T. Source   Edit  
proc toInt(val: CborNumber; T: type SomeUnsignedInt): Opt[T] {....raises: [],
    gcsafe.}
Converts a CborNumber to a unsigned integer, if it fits in T. Source   Edit  

Templates

template toBytes(val: CborBytes): untyped {..}
Source   Edit