diff --git a/machine.marshal.go b/machine.marshal.go new file mode 100644 index 0000000..00959cb --- /dev/null +++ b/machine.marshal.go @@ -0,0 +1,39 @@ +package zoopb + +// todo: autogen this + +import ( + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/encoding/prototext" + "google.golang.org/protobuf/proto" +) + +// marshal to wire +func (m *Machine) Marshal() ([]byte, error) { + return proto.Marshal(m) +} + +// marshal to TEXT +func (m *Machine) MarshalTEXT() ([]byte, error) { + return prototext.Marshal(m) +} + +// marshal to JSON +func (m *Machine) MarshalJSON() ([]byte, error) { + return protojson.Marshal(m) +} + +// unmarshal from wire +func (m *Machine) Unmarshal(data []byte) error { + return proto.Unmarshal(data, m) +} + +// marshal to wire +func (m *Machines) Marshal() ([]byte, error) { + return proto.Marshal(m) +} + +// unmarshal from wire +func (m *Machines) Unmarshal(data []byte) error { + return proto.Unmarshal(data, m) +} diff --git a/machines.go b/machine.sort.go similarity index 100% rename from machines.go rename to machine.sort.go diff --git a/helpers.go b/package.marshal.go similarity index 66% rename from helpers.go rename to package.marshal.go index 390da5c..2c8a4e7 100644 --- a/helpers.go +++ b/package.marshal.go @@ -1,13 +1,12 @@ package zoopb +// todo: autogen this // functions to import and export the protobuf -// data to and from config files import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" - // "google.golang.org/protobuf/proto" ) // human readable JSON @@ -41,23 +40,3 @@ func (p *Packages) Marshal() ([]byte, error) { func (p *Packages) Unmarshal(data []byte) error { return proto.Unmarshal(data, p) } - -// marshal to wire -func (m *Machine) Marshal() ([]byte, error) { - return proto.Marshal(m) -} - -// unmarshal from wire -func (m *Machine) Unmarshal(data []byte) error { - return proto.Unmarshal(data, m) -} - -// marshal to wire -func (m *Machines) Marshal() ([]byte, error) { - return proto.Marshal(m) -} - -// unmarshal from wire -func (m *Machines) Unmarshal(data []byte) error { - return proto.Unmarshal(data, m) -} diff --git a/packages.go b/package.sort.go similarity index 100% rename from packages.go rename to package.sort.go