mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 00:38:10 +02:00
Nicer string repr for operations
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
|||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/zeebo/xxh3"
|
"github.com/zeebo/xxh3"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
@@ -76,6 +77,21 @@ type Operation struct {
|
|||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self Operation) String() string {
|
||||||
|
ans := "{" + self.Type.String() + " "
|
||||||
|
switch self.Type {
|
||||||
|
case OpBlock:
|
||||||
|
ans += strconv.FormatUint(self.BlockIndex, 10)
|
||||||
|
case OpBlockRange:
|
||||||
|
ans += strconv.FormatUint(self.BlockIndex, 10) + " to " + strconv.FormatUint(self.BlockIndexEnd, 10)
|
||||||
|
case OpData:
|
||||||
|
ans += strconv.Itoa(len(self.Data))
|
||||||
|
case OpHash:
|
||||||
|
ans += hex.EncodeToString(self.Data)
|
||||||
|
}
|
||||||
|
return ans + "}"
|
||||||
|
}
|
||||||
|
|
||||||
var bin = binary.LittleEndian
|
var bin = binary.LittleEndian
|
||||||
|
|
||||||
func (self Operation) SerializeSize() int {
|
func (self Operation) SerializeSize() int {
|
||||||
|
|||||||
Reference in New Issue
Block a user