summaryrefslogtreecommitdiff
path: root/refs.marshal.go
blob: e39d97ab5806faf613caea10cda8e2b754cf730c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)
}