Go: NBT and the key-value database¶
Functions¶
SnbtToBinary¶
| Go | |
|---|---|
SnbtToBinary encodes SNBT as binary NBT in format 0, the little-endian disk layout, or format 1, the network layout.
- Parameters:
- snbt :
string - format :
int32
- snbt :
- Return type:
([]byte, error) - Slots:
nbt_snbt_to_binary
OpenKvDb¶
| Go | |
|---|---|
OpenKvDb opens the store at path, creating it when createIfMissing is set.
- Parameters:
- path :
string - createIfMissing :
bool
- path :
- Return type:
(*KvDb, error) - Slots:
kvdb_open
KvDb¶
KvDb is an open key-value store, kept by the host under the mod's data directory.
KvDb.Path¶
| Go | |
|---|---|
Path is where the store was opened.
- Return type:
string
KvDb.Get¶
| Go | |
|---|---|
Get reads one key; found is false for a key that does not exist. A store the host closed on its own, at an unload, also reads as not found: the ABI answers both alike.
- Parameters:
- key :
string
- key :
- Return type:
(value string, found bool, err error) - Slots:
kvdb_get
KvDb.Set¶
| Go | |
|---|---|
Set writes one key.
- Parameters:
- key :
string - value :
string
- key :
- Return type:
error - Slots:
kvdb_set
KvDb.Delete¶
| Go | |
|---|---|
Delete removes one key.
- Parameters:
- key :
string
- key :
- Return type:
error - Slots:
kvdb_del
KvDb.Has¶
| Go | |
|---|---|
Has reports whether a key exists.
- Parameters:
- key :
string
- key :
- Return type:
(bool, error) - Slots:
kvdb_has
KvDb.IsEmpty¶
| Go | |
|---|---|
IsEmpty reports whether the store holds no key.
- Return type:
(bool, error) - Slots:
kvdb_is_empty
KvDb.Iter¶
| Go | |
|---|---|
Iter lists every entry.
- Return type:
([]KeyValue, error) - Slots:
kvdb_iter
KvDb.Close¶
| Go | |
|---|---|
Close closes the store; using it afterwards fails.
- Return type:
error - Slots:
kvdb_close
KvDbHandle¶
KvDbHandle is an open key-value store; the zero value is no store.
KvDbHandle.IsZero¶
| Go | |
|---|---|
IsZero reports whether the handle names nothing.
- Return type:
bool
KeyValue¶
KeyValue is one entry of a key-value store.