summaryrefslogtreecommitdiff
path: root/refs.marshal.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-26 04:34:01 -0600
committerJeff Carr <[email protected]>2024-11-26 04:34:01 -0600
commit316bc8ea81200a48b8a7259905720362b512ce2a (patch)
tree411251bf71593f7e434f92cd0124108dafe365c6 /refs.marshal.go
Day 1
Diffstat (limited to 'refs.marshal.go')
-rw-r--r--refs.marshal.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/refs.marshal.go b/refs.marshal.go
new file mode 100644
index 0000000..e39d97a
--- /dev/null
+++ b/refs.marshal.go
@@ -0,0 +1,42 @@
+package gitpb
+
+// todo: autogen this
+// functions to import and export the protobuf
+
+import (
+ "google.golang.org/protobuf/encoding/protojson"
+ "google.golang.org/protobuf/encoding/prototext"
+ "google.golang.org/protobuf/proto"
+)
+
+// human readable JSON
+func (r *Refs) FormatJSON() string {
+ return protojson.Format(r)
+}
+
+// apparently this isn't supposed to be used?
+// https://protobuf.dev/reference/go/faq/#unstable-text
+// this is a shame because this is much nicer output than JSON Format()
+func (r *Refs) FormatTEXT() string {
+ return prototext.Format(r)
+}
+
+// marshal json
+func (r *Refs) MarshalJSON() ([]byte, error) {
+ return protojson.Marshal(r)
+}
+
+// unmarshal
+func (r *Refs) UnmarshalJSON(data []byte) error {
+ return protojson.Unmarshal(data, r)
+}
+
+// marshal to wire
+func (r *Refs) Marshal() ([]byte, error) {
+ return proto.Marshal(r)
+}
+
+// unmarshal from wire
+func (r *Refs) Unmarshal(data []byte) error {
+ return proto.Unmarshal(data, r)
+}