summaryrefslogtreecommitdiff
path: root/stack.go
diff options
context:
space:
mode:
authoranon5 <anon5clam@protonmail.com>2021-06-21 18:47:26 +0000
committeranon5 <anon5clam@protonmail.com>2021-06-21 18:47:26 +0000
commit425da65ed46061303604610bb539d6495b2b1f3f (patch)
tree10ae3e665132c369ce0207676321cef870679923 /stack.go
parent9f239d341ef46b656dda759020da87bdd0606344 (diff)
Add high-level protocol (de)serialization
Diffstat (limited to 'stack.go')
-rw-r--r--stack.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/stack.go b/stack.go
index 4e7cc18..d930604 100644
--- a/stack.go
+++ b/stack.go
@@ -1,5 +1,8 @@
-// In this file, JSON refers to WTF-JSON, a variant of JSON used by Minetest
+// In this file, JSON refers to WTF-JSON.
+//
+// BUG(mt): Itemstrings use variant of JSON called WTF-JSON
// where \u00XX escapes in string literals act like Go's \xXX escapes.
+// This should not be fixed because it would break existing items.
package mt
@@ -22,6 +25,10 @@ type Item struct {
ItemMeta
}
+// String returns the Stack's itemstring.
+//
+// BUG(mt): The term itemstring is somewhat misleading, because
+// an itemstring represents a stack of items, not a single item.
func (s Stack) String() string {
if s.Count == 0 {
return ""
@@ -83,6 +90,7 @@ func jsonStr(s string) string {
return b.String()
}
+// Scan scans an itemstring, implementing the fmt.Scanner interface.
func (stk *Stack) Scan(state fmt.ScanState, verb rune) (err error) {
*stk = Stack{}