All Downloads are FREE. Search and download functionalities are using the official Maven repository.

luagen.struct.mustache Maven / Gradle / Ivy

There is a newer version: 21.5.0
Show newest version
{{#docstring}}
--[[
{{docstring}}
--]]
{{/docstring}}

-- Import this file with:
--   require '{{package}}.{{StructName}}'
-- Note: This file depends on libthrift!

{{requireStatements}}

local {{StructName}} = {
  ttype = 'struct',
  name = '{{StructName}}',
  fields = {
{{#fields}}
    [{{id}}] = { name = '{{fieldName}}', {{^optional}}required = true, {{/optional}}{{#readWriteInfo}}{{fieldType}},{{/readWriteInfo}} },
{{/fields}}  }
}

local binaryCodec = require 'libthrift'

{{StructName}}.__codec = binaryCodec.codec({{StructName}})

function {{StructName}}:read(bin)
  return self.__codec:read(bin)
end

function {{StructName}}:readTensor(bin)
  return self.__codec:readTensor(bin)
end

function {{StructName}}:write(params)
  return self.__codec:write(params)
end

function {{StructName}}:writeTensor(params)
  return self.__codec:writeTensor(params)
end

return {{StructName}}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy