go-capnp icon indicating copy to clipboard operation
go-capnp copied to clipboard

Add typed wrapper for `List[Client]`.

Open lthibault opened this issue 2 years ago • 5 comments

Now that we have support for mapping :Capability types to capnp.Client, it might make sense to add a List[Client] wrapper, along the same lines as #247. Thoughts?

lthibault avatar May 22 '22 16:05 lthibault

Makes sense to me.

zenhack avatar May 22 '22 21:05 zenhack

Half-baked thought: what if we changed things so that instead of defining interface types as type Foo struct { Client }, we just did type Foo Client? Then, CapList could have its constraint set to ~Client, and it would work for both Client itself and the typed wrappers.

We could probably extend this to other cases as well.

We would probably have to go back to generating some extra methods though, but that's maybe ok.

zenhack avatar Jul 30 '22 23:07 zenhack

What does this get us? Can we not set the constraint to ~struct{ Client }?

Note that I don't dislike this. There are a lot of (nested) embedded structs in the library, and flattening that out ought to help with readability.

lthibault avatar Jul 30 '22 23:07 lthibault

That's what we have now, but it means CapList can't be used for base Client, only the generated interface types that wrap it. This would allow it to be used for both.

zenhack avatar Jul 30 '22 23:07 zenhack

Makes sense. Go for it 👍

lthibault avatar Aug 01 '22 12:08 lthibault

This is done, closing.

zenhack avatar Aug 27 '22 04:08 zenhack