From 425da65ed46061303604610bb539d6495b2b1f3f Mon Sep 17 00:00:00 2001 From: anon5 Date: Mon, 21 Jun 2021 18:47:26 +0000 Subject: Add high-level protocol (de)serialization --- stack.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'stack.go') 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{} -- cgit v1.2.3