diff --git a/capnpc-go/capnpc-go.go b/capnpc-go/capnpc-go.go index 48de47d8..e2910197 100644 --- a/capnpc-go/capnpc-go.go +++ b/capnpc-go/capnpc-go.go @@ -30,10 +30,11 @@ import ( // Non-stdlib import paths. const ( - capnpImport = "capnproto.org/go/capnp/v3" - textImport = capnpImport + "/encoding/text" - schemasImport = capnpImport + "/schemas" - serverImport = capnpImport + "/server" + capnpImport = "capnproto.org/go/capnp/v3" + textImport = capnpImport + "/encoding/text" + schemasImport = capnpImport + "/schemas" + serverImport = capnpImport + "/server" + flowcontrolImport = capnpImport + "/flowcontrol" ) // genoptions are parameters that control code generation. diff --git a/capnpc-go/fileparts.go b/capnpc-go/fileparts.go index 3a8dcb81..f83a9759 100644 --- a/capnpc-go/fileparts.go +++ b/capnpc-go/fileparts.go @@ -67,7 +67,9 @@ func (i *imports) init() { i.reserve(importSpec{path: schemasImport, name: "schemas"}) i.reserve(importSpec{path: serverImport, name: "server"}) i.reserve(importSpec{path: textImport, name: "text"}) + i.reserve(importSpec{path: flowcontrolImport, name: "fc"}) + i.reserve(importSpec{path: "fmt", name: "fmt"}) i.reserve(importSpec{path: "context", name: "context"}) i.reserve(importSpec{path: "math", name: "math"}) i.reserve(importSpec{path: "strconv", name: "strconv"}) @@ -89,6 +91,14 @@ func (i *imports) Text() string { return i.add(importSpec{path: textImport, name: "text"}) } +func (i *imports) FlowControl() string { + return i.add(importSpec{path: flowcontrolImport, name: "fc"}) +} + +func (i *imports) Fmt() string { + return i.add(importSpec{path: "fmt", name: "fmt"}) +} + func (i *imports) Context() string { return i.add(importSpec{path: "context", name: "context"}) } diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index aa39eec5..8d419958 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -21,14 +21,36 @@ func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, pa } {{end}} +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c {{$.Node.Name}}) String() string { + return {{$.G.Imports.Fmt}}.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c {{$.Node.Name}}) AddRef() {{$.Node.Name}} { return {{$.Node.Name}}(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c {{$.Node.Name}}) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c {{$.Node.Name}}) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c {{$.Node.Name}}) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -37,6 +59,31 @@ func ({{$.Node.Name}}) DecodeFromPtr(p capnp.Ptr) {{$.Node.Name}} { return {{$.Node.Name}}(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c {{$.Node.Name}}) IsValid() bool { return capnp.Client(c).IsValid() } + +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c {{$.Node.Name}}) IsSame(other {{$.Node.Name}}) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c {{$.Node.Name}}) SetFlowLimiter(lim {{.G.Imports.FlowControl}}.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c {{$.Node.Name}}) GetFlowLimiter() {{.G.Imports.FlowControl}}.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} \ No newline at end of file diff --git a/internal/aircraftlib/aircraft.capnp.go b/internal/aircraftlib/aircraft.capnp.go index 648893a2..8492494c 100644 --- a/internal/aircraftlib/aircraft.capnp.go +++ b/internal/aircraftlib/aircraft.capnp.go @@ -5,9 +5,11 @@ package aircraftlib import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" + fmt "fmt" math "math" strconv "strconv" ) @@ -5125,14 +5127,36 @@ func (c Echo) Echo(ctx context.Context, params func(Echo_echo_Params) error) (Ec return Echo_echo_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Echo) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Echo) AddRef() Echo { return Echo(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Echo) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Echo) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Echo) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -5141,11 +5165,34 @@ func (Echo) DecodeFromPtr(p capnp.Ptr) Echo { return Echo(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Echo) IsValid() bool { return capnp.Client(c).IsValid() } -// A Echo_Server is a Echo with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Echo) IsSame(other Echo) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Echo) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Echo) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Echo_Server is a Echo with a local implementation. type Echo_Server interface { Echo(context.Context, Echo_echo) error } @@ -5870,14 +5917,36 @@ func (c CallSequence) GetNumber(ctx context.Context, params func(CallSequence_ge return CallSequence_getNumber_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c CallSequence) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c CallSequence) AddRef() CallSequence { return CallSequence(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c CallSequence) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c CallSequence) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c CallSequence) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -5886,11 +5955,34 @@ func (CallSequence) DecodeFromPtr(p capnp.Ptr) CallSequence { return CallSequence(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c CallSequence) IsValid() bool { return capnp.Client(c).IsValid() } -// A CallSequence_Server is a CallSequence with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c CallSequence) IsSame(other CallSequence) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c CallSequence) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c CallSequence) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A CallSequence_Server is a CallSequence with a local implementation. type CallSequence_Server interface { GetNumber(context.Context, CallSequence_getNumber) error } @@ -6130,14 +6222,36 @@ func (c Pipeliner) GetNumber(ctx context.Context, params func(CallSequence_getNu return CallSequence_getNumber_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Pipeliner) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Pipeliner) AddRef() Pipeliner { return Pipeliner(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Pipeliner) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Pipeliner) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Pipeliner) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -6146,11 +6260,34 @@ func (Pipeliner) DecodeFromPtr(p capnp.Ptr) Pipeliner { return Pipeliner(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Pipeliner) IsValid() bool { return capnp.Client(c).IsValid() } -// A Pipeliner_Server is a Pipeliner with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Pipeliner) IsSame(other Pipeliner) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Pipeliner) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Pipeliner) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Pipeliner_Server is a Pipeliner with a local implementation. type Pipeliner_Server interface { NewPipeliner(context.Context, Pipeliner_newPipeliner) error diff --git a/rpc/internal/testcapnp/test.capnp.go b/rpc/internal/testcapnp/test.capnp.go index d4aa6b12..665dc5c9 100644 --- a/rpc/internal/testcapnp/test.capnp.go +++ b/rpc/internal/testcapnp/test.capnp.go @@ -5,10 +5,12 @@ package testcapnp import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" stream "capnproto.org/go/capnp/v3/std/capnp/stream" context "context" + fmt "fmt" ) type PingPong capnp.Client @@ -33,14 +35,36 @@ func (c PingPong) EchoNum(ctx context.Context, params func(PingPong_echoNum_Para return PingPong_echoNum_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c PingPong) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c PingPong) AddRef() PingPong { return PingPong(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c PingPong) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c PingPong) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c PingPong) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -49,11 +73,34 @@ func (PingPong) DecodeFromPtr(p capnp.Ptr) PingPong { return PingPong(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c PingPong) IsValid() bool { return capnp.Client(c).IsValid() } -// A PingPong_Server is a PingPong with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c PingPong) IsSame(other PingPong) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c PingPong) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c PingPong) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A PingPong_Server is a PingPong with a local implementation. type PingPong_Server interface { EchoNum(context.Context, PingPong_echoNum) error } @@ -284,14 +331,36 @@ func (c StreamTest) Push(ctx context.Context, params func(StreamTest_push_Params return stream.StreamResult_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c StreamTest) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c StreamTest) AddRef() StreamTest { return StreamTest(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c StreamTest) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c StreamTest) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c StreamTest) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -300,11 +369,34 @@ func (StreamTest) DecodeFromPtr(p capnp.Ptr) StreamTest { return StreamTest(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c StreamTest) IsValid() bool { return capnp.Client(c).IsValid() } -// A StreamTest_Server is a StreamTest with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c StreamTest) IsSame(other StreamTest) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c StreamTest) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c StreamTest) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A StreamTest_Server is a StreamTest with a local implementation. type StreamTest_Server interface { Push(context.Context, StreamTest_push) error } @@ -484,14 +576,36 @@ func (c CapArgsTest) Self(ctx context.Context, params func(CapArgsTest_self_Para return CapArgsTest_self_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c CapArgsTest) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c CapArgsTest) AddRef() CapArgsTest { return CapArgsTest(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c CapArgsTest) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c CapArgsTest) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c CapArgsTest) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -500,11 +614,34 @@ func (CapArgsTest) DecodeFromPtr(p capnp.Ptr) CapArgsTest { return CapArgsTest(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c CapArgsTest) IsValid() bool { return capnp.Client(c).IsValid() } -// A CapArgsTest_Server is a CapArgsTest with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c CapArgsTest) IsSame(other CapArgsTest) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c CapArgsTest) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c CapArgsTest) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A CapArgsTest_Server is a CapArgsTest with a local implementation. type CapArgsTest_Server interface { Call(context.Context, CapArgsTest_call) error diff --git a/std/capnp/persistent/persistent.capnp.go b/std/capnp/persistent/persistent.capnp.go index daabe9ad..59468ab3 100644 --- a/std/capnp/persistent/persistent.capnp.go +++ b/std/capnp/persistent/persistent.capnp.go @@ -5,9 +5,11 @@ package persistent import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" + fmt "fmt" ) const PersistentAnnotation = uint64(0xf622595091cafb67) @@ -34,14 +36,36 @@ func (c Persistent) Save(ctx context.Context, params func(Persistent_SaveParams) return Persistent_SaveResults_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Persistent) String() string { + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Persistent) AddRef() Persistent { return Persistent(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Persistent) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Persistent) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Persistent) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -50,11 +74,34 @@ func (Persistent) DecodeFromPtr(p capnp.Ptr) Persistent { return Persistent(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Persistent) IsValid() bool { return capnp.Client(c).IsValid() } -// A Persistent_Server is a Persistent with a local implementation. +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Persistent) IsSame(other Persistent) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Persistent) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Persistent) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Persistent_Server is a Persistent with a local implementation. type Persistent_Server interface { Save(context.Context, Persistent_save) error }