/
core.clj
52 lines (38 loc) · 1.09 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(ns clj-cbor.data.core
"Type definitions and keyword identifiers for CBOR data types."
(:require
[clj-cbor.data.simple :as simple]
[clj-cbor.data.tagged :as tagged])
(:import
(clj_cbor.data.simple
SimpleValue)
(clj_cbor.data.tagged
TaggedValue)))
;; ## Simple Values
(def undefined
"Base singleton undefined value."
(simple/->Undefined nil))
(defn simple-value
"Constructs a simple type for the given number."
[n]
(when (or (neg? n) (< 255 n))
(throw (IllegalArgumentException.
"Simple value codes must be between 0 and 255")))
(simple/->SimpleValue n nil))
(defn simple-value?
"Predicate which tests whether `x` is a simple CBOR value."
[x]
(instance? SimpleValue x))
;; ## Tagged Values
(defn tagged-value
"Constructs a tagged value."
[tag value]
(tagged/->TaggedValue tag value nil))
(defn tagged-value?
"Predicate which tests whether `x` is a CBOR tagged value."
[x]
(instance? TaggedValue x))
(def set-tag
"Tag code used to identify sets of unique values. Hard-coded here to support
canonical encoding."
258)