-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_request.go
44 lines (35 loc) · 1.05 KB
/
device_request.go
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
package mdoc
import "github.com/fxamacker/cbor/v2"
type DeviceRequest struct {
Version string `cbor:"version"`
DocRequests []DocRequest `cbor:"docRequests"`
}
func NewDeviceRequest(docRequests []DocRequest) *DeviceRequest {
return &DeviceRequest{
"1.0",
docRequests,
}
}
type DocRequest struct {
ItemsRequestBytes TaggedEncodedCBOR `cbor:"itemsRequest"`
ReaderAuth ReaderAuth `cbor:"readerAuth"`
}
func (dr *DocRequest) ItemsRequest() (*ItemsRequest, error) {
itemsRequest := new(ItemsRequest)
if err := cbor.Unmarshal(dr.ItemsRequestBytes.UntaggedValue, itemsRequest); err != nil {
return nil, err
}
return itemsRequest, nil
}
type ItemsRequest struct {
DocType DocType `cbor:"docType"`
NameSpaces NameSpaces `cbor:"nameSpaces"`
RequestInfo map[string]any `cbor:"requestInfo"`
}
type NameSpaces map[NameSpace]DataElements
type DataElements map[DataElementIdentifier]IntentToRetain
type IntentToRetain bool
type DocType string
type NameSpace string
type DataElementIdentifier string
type DataElementValue any