{{ template "_typeid" .Node }} func New{{.Node.Name}}(s *{{.G.Capnp}}.Segment) ({{.Node.Name}}, error) { st, err := {{$.G.Capnp}}.NewStruct(s, {{.G.ObjectSize .Node}}) return {{.Node.Name}}{st}, err } func NewRoot{{.Node.Name}}(s *{{.G.Capnp}}.Segment) ({{.Node.Name}}, error) { st, err := {{.G.Capnp}}.NewRootStruct(s, {{.G.ObjectSize .Node}}) return {{.Node.Name}}{st}, err } func ReadRoot{{.Node.Name}}(msg *{{.G.Capnp}}.Message) ({{.Node.Name}}, error) { root, err := msg.RootPtr() return {{.Node.Name}}{root.Struct()}, err } {{if .StringMethod}} func (s {{.Node.Name}}) String() string { str, _ := {{.G.Imports.Text}}.Marshal({{.Node.Id|printf "%#x"}}, s.Struct) return str } {{end}}