• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package flatbuffers
2
3// Codec implements gRPC-go Codec which is used to encode and decode messages.
4var Codec = "flatbuffers"
5
6type FlatbuffersCodec struct{}
7
8func (FlatbuffersCodec) Marshal(v interface{}) ([]byte, error) {
9	return v.(*Builder).FinishedBytes(), nil
10}
11
12func (FlatbuffersCodec) Unmarshal(data []byte, v interface{}) error {
13	v.(flatbuffersInit).Init(data, GetUOffsetT(data))
14	return nil
15}
16
17func (FlatbuffersCodec) String() string {
18	return Codec
19}
20
21type flatbuffersInit interface {
22	Init(data []byte, i UOffsetT)
23}
24