-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "local" types which know how to convert to and from primitive types - eg, Guid, Url #475
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
into
and try_into
into primitive types - eg, Guid, Url
FWIW, I've edited the first comment to describe a hand-wavey proposal which I'd love thoughts on and hidden earlier comments) |
So, I think this is headed in broadly a good direction, and it's a direction we should explore a bit in an iterative fashion. It seems to intersect really strongly with James' Transform Towers proposal. As a first attempt, I feel like I'd rather see the types named explicitly in the interface definition somehow, rather than being squirreled away in a config file. Maybe we could use the I wonder if something like |
FWIW, I can imagine a similar annotation being used to access types from another component, which in theory would already come with their own |
Yeah, I've been pondering this too, but then I started having images of uniffizords and had to seek therapy. |
You are going to love the next Google Doc that I'm working on... |
custom types ftw 🎉 |
In app-services, we've had to compromise on the interfaces we expose, particularly around
Guid
andUrl
. Here's my latest take on this:How about we "just" provide a way for consumers to provide a list of "external types" - a list of
[(name, raw_type)]
- eg,('Guid', String)
Doing this allows us to write in the .udl:
and then it's fairly easy to have:
fn get_guid(guid: Option<Guid>) -> Guid
(assuming that type exists and implements the uniffi traits)get_guid(None))
works and returns a string.and you can imagine (2) being optionally smarter - eg, we can probably arrange for projects to also arrange for a suitable
Guid
type to be used in the bindings.I haven't thought too much about how to spell these types, but for the sake of example, let's assume in
uniffi.toml
with something like:This would probably allow a consumer to fully implement #440 without any help from us and probably even backout timestamp/duration support.
(To be clear, I'm not saying we should exclude JSON support or back timestamps out, but we could)
FWIW, I've got my
get_guid()
example above working in a very very hacky way, including painfully hand-written implemention ofViaFfi
forGuid
- but close enough to convince me it's doable.WDYT?
┆Issue is synchronized with this Jira Task
┆Issue Number: UNIFFI-65
The text was updated successfully, but these errors were encountered: