Skip to content

api: Rename query_map attribute of request macro to query_all and remove bound#1848

Merged
zecakeh merged 1 commit intomainfrom
zecakeh/api-query-type
Jun 21, 2024
Merged

api: Rename query_map attribute of request macro to query_all and remove bound#1848
zecakeh merged 1 commit intomainfrom
zecakeh/api-query-type

Conversation

@zecakeh
Copy link
Contributor

@zecakeh zecakeh commented Jun 19, 2024

Allows to represent the query fields as a single struct or enum.

This was requested with a valid use case of representing the query strings as an enum at: https://matrix.to/#/!veagCdDBjKrMsOCzrq:privacytools.io/$eNLiLj5-OXZCOyGu8fVIYlCzfZbm-EAnNw6GfT-r34E?via=matrix.org&via=envs.net&via=mozilla.org

@zecakeh
Copy link
Contributor Author

zecakeh commented Jun 19, 2024

One could argue that we don't need both query_map and query_type since they are the same, except that query_map checks for an IntoIterator<Item=(String,String)> bound.

@jplatte
Copy link
Member

jplatte commented Jun 21, 2024

Yeah I would say we should only have the more general one. I wonder if another name would be more intuitive, too. But everything I've come up with so far seems awkward... query_all and query_flatten both seem suboptimal.

@zecakeh
Copy link
Contributor Author

zecakeh commented Jun 21, 2024

I agree that the name is not ideal. I got query_full or query_wrapper

@jplatte
Copy link
Member

jplatte commented Jun 21, 2024

Hm, I guess query_all and query_full are least likely to be interpreted to mean sth. else? I'd be okay with either given we have nothing better.

@zecakeh zecakeh force-pushed the zecakeh/api-query-type branch from 32c5695 to 84e2698 Compare June 21, 2024 16:36
@zecakeh
Copy link
Contributor Author

zecakeh commented Jun 21, 2024

Alright, I chose query_all

@toger5
Copy link
Contributor

toger5 commented Jun 21, 2024

I might be a bit too late.
What I would think could also work and match the behaviour of: #[ruma_api(body)]
is to rename #[ruma_api(query)] to #[ruma_api(query_parameter)] and make #[ruma_api(query)] behave like query_full

But I guess this is too much of a breaking change.

query_object would also make sense imo

@zecakeh zecakeh changed the title api: Add query_type attribute for request macro api: Rename query_map attribute of request macro to query_all and remove bound Jun 21, 2024
@jplatte
Copy link
Member

jplatte commented Jun 21, 2024

query_object also seems better than query_type, but I think it's less self-explanatory than query_all.

Remove its IntoIterator bound to allow to represent
the query fields as a single struct or enum.
@zecakeh zecakeh force-pushed the zecakeh/api-query-type branch from 84e2698 to 19a13fb Compare June 21, 2024 17:11
@zecakeh zecakeh merged commit 968c52b into main Jun 21, 2024
@zecakeh zecakeh deleted the zecakeh/api-query-type branch June 21, 2024 17:16
@toger5
Copy link
Contributor

toger5 commented Jun 23, 2024

Thank you two for getting this merged so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants