-- Auto-generated protocol definition
-- DO NOT EDIT - This file is generated by Morel
local Protocol = {}
Protocol.name = "txse_rake_udp"
Protocol.description = "txse_rake_udp"
-- Enum definitions
Protocol.enums = {}
Protocol.enums.RakeUdpPacketType = {
  [0] = "SEQUENCED_DATA",
  [1] = "HEARTBEAT",
  [2] = "START_OF_SESSION",
  [3] = "END_OF_SESSION",
  [4] = "GAP_FILL_REQUEST",
  [5] = "GAP_FILL_RESPONSE",
}
-- Field definitions
-- Returns a function that creates Fields table given TXSE lib
Protocol.createFields = function(TXSE)
  local Fields = {}
  local Enums = Protocol.enums
  Fields["length"] = {
    length = 2,
    abbr = "txse_rake_udp.length",
    name = "length",
    ftype = ftypes.INT16,
    encoding = ENC_LITTLE_ENDIAN,
    kotlin_type = "kotlin.Short",
  }
  Fields["messageCount"] = {
    length = 2,
    abbr = "txse_rake_udp.messageCount",
    name = "messageCount",
    ftype = ftypes.INT16,
    encoding = ENC_LITTLE_ENDIAN,
    kotlin_type = "kotlin.Short",
  }
  Fields["rakeUdpPacketType"] = {
    length = 1,
    abbr = "txse_rake_udp.rakeUdpPacketType",
    name = "rakeUdpPacketType",
    ftype = ftypes.INT8,
    encoding = ENC_NA,
    kotlin_type = "com.txse.foundation.protocols.rake.morel.define.RakeUdpPacketType",
    value_map = Enums.RakeUdpPacketType,
  }
  Fields["sequence"] = {
    length = 8,
    abbr = "txse_rake_udp.sequence",
    name = "sequence",
    ftype = ftypes.INT64,
    encoding = ENC_LITTLE_ENDIAN,
    kotlin_type = "kotlin.Long",
  }
  Fields["session"] = {
    length = 8,
    abbr = "txse_rake_udp.session",
    name = "session",
    ftype = ftypes.INT64,
    encoding = ENC_LITTLE_ENDIAN,
    kotlin_type = "com.txse.avail.Session",
  }
  Fields["streamId"] = {
    length = 1,
    abbr = "txse_rake_udp.streamId",
    name = "streamId",
    ftype = ftypes.INT8,
    encoding = ENC_NA,
    kotlin_type = "com.txse.avail.StreamId",
  }
  return Fields
end
-- Message definitions
Protocol.messages = {
  {
    name = "UdpHeader",
    type = nil,
    fields = {
      "session",
      "sequence",
      "messageCount",
      "rakeUdpPacketType",
    },
  },
  {
    name = "UdpSequencedMessage",
    type = nil,
    fields = {
      "length",
      "streamId",
    },
    trailing_payload = "binary",
  },
}
-- SIMPLE_STRUCT setup - exposes individual struct parsers
-- opts.payload_decoder: optional function(buffer, pinfo, tree_item) for trailing payload
Protocol.register = function(opts)
  local TXSE = require("txse-lib")
  return TXSE.Proto.new(TXSE.createSpec(Protocol, opts))
end
return Protocol
