package wire

import (
	"google.golang.org/protobuf/proto"

	proto_socket "git.toki-labs.com/toki/proto-socket/go"
	iop "iop/proto/gen/iop"
)

// EdgeParserMap returns the proto-socket parser set for the Control Plane-Edge
// native TCP wire contract.
func EdgeParserMap() proto_socket.ParserMap {
	return proto_socket.ParserMap{
		proto_socket.TypeNameOf(&iop.EdgeHelloRequest{}): func(b []byte) (proto.Message, error) {
			req := &iop.EdgeHelloRequest{}
			return req, proto.Unmarshal(b, req)
		},
		proto_socket.TypeNameOf(&iop.EdgeHelloResponse{}): func(b []byte) (proto.Message, error) {
			res := &iop.EdgeHelloResponse{}
			return res, proto.Unmarshal(b, res)
		},
		proto_socket.TypeNameOf(&iop.EdgeStatusRequest{}): func(b []byte) (proto.Message, error) {
			req := &iop.EdgeStatusRequest{}
			return req, proto.Unmarshal(b, req)
		},
		proto_socket.TypeNameOf(&iop.EdgeStatusResponse{}): func(b []byte) (proto.Message, error) {
			res := &iop.EdgeStatusResponse{}
			return res, proto.Unmarshal(b, res)
		},
		proto_socket.TypeNameOf(&iop.EdgeNodeEvent{}): func(b []byte) (proto.Message, error) {
			event := &iop.EdgeNodeEvent{}
			return event, proto.Unmarshal(b, event)
		},
		proto_socket.TypeNameOf(&iop.EdgeCommandRequest{}): func(b []byte) (proto.Message, error) {
			req := &iop.EdgeCommandRequest{}
			return req, proto.Unmarshal(b, req)
		},
		proto_socket.TypeNameOf(&iop.EdgeCommandResponse{}): func(b []byte) (proto.Message, error) {
			res := &iop.EdgeCommandResponse{}
			return res, proto.Unmarshal(b, res)
		},
		proto_socket.TypeNameOf(&iop.EdgeCommandEvent{}): func(b []byte) (proto.Message, error) {
			event := &iop.EdgeCommandEvent{}
			return event, proto.Unmarshal(b, event)
		},
		proto_socket.TypeNameOf(&iop.AcquireLeaseRequest{}): func(b []byte) (proto.Message, error) {
			req := &iop.AcquireLeaseRequest{}
			return req, proto.Unmarshal(b, req)
		},
		proto_socket.TypeNameOf(&iop.PrincipalProjectionApplyResponse{}): func(b []byte) (proto.Message, error) {
			res := &iop.PrincipalProjectionApplyResponse{}
			return res, proto.Unmarshal(b, res)
		},
	}
}
