diff options
author | anon5 <anon5clam@protonmail.com> | 2021-06-21 18:47:26 +0000 |
---|---|---|
committer | anon5 <anon5clam@protonmail.com> | 2021-06-21 18:47:26 +0000 |
commit | 425da65ed46061303604610bb539d6495b2b1f3f (patch) | |
tree | 10ae3e665132c369ce0207676321cef870679923 /stack.go | |
parent | 9f239d341ef46b656dda759020da87bdd0606344 (diff) |
Add high-level protocol (de)serialization
Diffstat (limited to 'stack.go')
-rw-r--r-- | stack.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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{} |