type {{.Node.Name}}_Server interface { {{range .Methods}} {{.Name|title}}({{$.G.RemoteNodeName .Interface $.Node}}_{{.Name}}) error {{end}} } func {{.Node.Name}}_ServerToClient(s {{.Node.Name}}_Server) {{.Node.Name}} { c, _ := s.({{.G.Imports.Server}}.Closer) return {{.Node.Name}}{Client: {{.G.Imports.Server}}.New({{.Node.Name}}_Methods(nil, s), c)} } func {{.Node.Name}}_Methods(methods []{{.G.Imports.Server}}.Method, s {{.Node.Name}}_Server) []{{.G.Imports.Server}}.Method { if cap(methods) == 0 { methods = make([]{{.G.Imports.Server}}.Method, 0, {{len .Methods}}) } {{range .Methods}} methods = append(methods, {{$.G.Imports.Server}}.Method{ Method: {{$.G.Capnp}}.Method{ {{template "_interfaceMethod" .}} }, Impl: func(c {{$.G.Imports.Context}}.Context, opts {{$.G.Capnp}}.CallOptions, p, r {{$.G.Capnp}}.Struct) error { call := {{$.G.RemoteNodeName .Interface $.Node}}_{{.Name}}{c, opts, {{$.G.RemoteNodeName .Params $.Node}}{Struct: p}, {{$.G.RemoteNodeName .Results $.Node}}{Struct: r} } return s.{{.Name|title}}(call) }, ResultsSize: {{$.G.ObjectSize .Results}}, }) {{end}} return methods } {{range .Methods -}} {{if eq .Interface.Id $.Node.Id}} // {{$.Node.Name}}_{{.Name}} holds the arguments for a server call to {{$.Node.Name}}.{{.Name}}. type {{$.Node.Name}}_{{.Name}} struct { Ctx {{$.G.Imports.Context}}.Context Options {{$.G.Capnp}}.CallOptions Params {{$.G.RemoteNodeName .Params $.Node}} Results {{$.G.RemoteNodeName .Results $.Node}} } {{end}} {{- end}}