-
Notifications
You must be signed in to change notification settings - Fork 123
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
Endpoints with lists of Ids don't accept multiple of them #203
Comments
The design for IDs is a bit wrong now that I've tried to actually use it... The thing is that you don't always know at compile-time what kind of ID is being used. So for example, this is impossible to do right now: let id = match x {
Track(t) => TrackId::from_uri(&t.uri).unwrap(),
Episode(t) => EpisodeId::from_uri(&t.uri).unwrap(),
};
client.start_uris_playback(id, /* ... */).await.unwrap(); Because the arms of the Any opinions, @kstep ? Sorry for bringing this up so late :( |
Here's my reasoning behind all of this, step by step so that anyone else can understand it as well. If I'm wrong at any point please let me know! So we currently have an
Sorry for the long text lol. Just brainstorming. I'll try to implement my favorite solutions in PRs and showcase how they work. |
Ugh. Unfortunately literally none of these ideas work. This is what happens when trying to implement
So in that case the user would have to do: let id1 = ArtistId::from_uri("...").unwrap();
let id2 = UnknownId::from_id(id1.id()).unwrap(); Which is way uglier and has more overhead than: let id1 = ArtistId::from_uri("...").unwrap();
let id2: UnknownId = id1.into(); |
It turns out that the zero cost abstractions isn't that easy to reach out, it comes with unexpected obstacles :) |
Yeah, it's very hard to mix both compile time and runtime. I'm trying a new approach that consists of mixing two of the ideas I explained here. I'll try to have multiple types for I'll explain more if I get it right, though it still has a couple drawbacks. |
Describe the bug
I just realized that Ids don't really work in lists. We'd have to use
Box
, I think, to support for example items of both episodes and tracks. Otherwise, with a snippet like this:You get:
This is also relatively dangerous because if the user tries to initialize the Ids with
Id::from_uri
instead of the specificEpisodeId:.from_uri
orTrackId::from_uri
, they will all be converted to the type of the first one in the list and fail at theunwrap
.The text was updated successfully, but these errors were encountered: