Skip to content

Commit d4e402c

Browse files
Merge pull request #43 from ZenGround0/feat/set-raw-cbor
Feat/set raw cbor
2 parents 99b8553 + 3c79c72 commit d4e402c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

hamt.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ func (n *Node) Find(ctx context.Context, k string, out interface{}) error {
8686
})
8787
}
8888

89+
func (n *Node) FindRaw(ctx context.Context, k string) ([]byte, error) {
90+
var ret []byte
91+
err := n.getValue(ctx, &hashBits{b: hash(k)}, k, func(kv *KV) error {
92+
ret = kv.Value.Raw
93+
return nil
94+
})
95+
return ret, err
96+
}
97+
8998
func (n *Node) Delete(ctx context.Context, k string) error {
9099
return n.modifyValue(ctx, &hashBits{b: hash(k)}, k, nil)
91100
}
@@ -203,6 +212,12 @@ func (n *Node) Flush(ctx context.Context) error {
203212
return nil
204213
}
205214

215+
// SetRaw sets key k to cbor bytes raw
216+
func (n *Node) SetRaw(ctx context.Context, k string, raw []byte) error {
217+
d := &cbg.Deferred{Raw: raw}
218+
return n.modifyValue(ctx, &hashBits{b: hash(k)}, k, d)
219+
}
220+
206221
func (n *Node) Set(ctx context.Context, k string, v interface{}) error {
207222
var d *cbg.Deferred
208223

0 commit comments

Comments
 (0)