Skip to content

Commit 1a9d469

Browse files
authored
fix: cbor.Value custom CBOR marshaling (#1085)
Fixes #1084 Signed-off-by: Aurora Gaffney <[email protected]>
1 parent 2360994 commit 1a9d469

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cbor/value.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ type Value struct {
3232
cborData string
3333
}
3434

35+
func (v *Value) MarshalCBOR() ([]byte, error) {
36+
// Return stored CBOR
37+
// This is only a stopgap, since it doesn't allow us to build values from scratch
38+
return []byte(v.cborData), nil
39+
}
40+
3541
func (v *Value) UnmarshalCBOR(data []byte) error {
3642
// Save the original CBOR
3743
v.cborData = string(data[:])
@@ -360,6 +366,12 @@ type LazyValue struct {
360366
value *Value
361367
}
362368

369+
func (l *LazyValue) MarshalCBOR() ([]byte, error) {
370+
// Return stored CBOR
371+
// This is only a stopgap, since it doesn't allow us to build values from scratch
372+
return []byte(l.value.cborData), nil
373+
}
374+
363375
func (l *LazyValue) UnmarshalCBOR(data []byte) error {
364376
if l.value == nil {
365377
l.value = &Value{}

0 commit comments

Comments
 (0)