some type stubs

This commit is contained in:
Bel LaPointe
2024-04-12 07:53:29 -06:00
parent 63d7454fb6
commit 8ee774240e
7 changed files with 250 additions and 0 deletions

41
message.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import "encoding/json"
type Message struct {
ID string
TS uint64
Plain string
Source string
Channel string
Thread string
EventName string
EventID string
AssetID string
}
func (m Message) Empty() bool {
return m == (Message{})
}
func (m Message) Serialize() []byte {
b, err := json.Marshal(m)
if err != nil {
panic(err)
}
return b
}
func MustDeserialize(b []byte) Message {
m, err := Deserialize(b)
if err != nil {
panic(err)
}
return m
}
func Deserialize(b []byte) (Message, error) {
var m Message
err := json.Unmarshal(b, &m)
return m, err
}