Description
Currently, this crate uses the builder pattern to assure a stable API i.e https://github.com/Emilgardis/twitch_api2/blob/e1ba9faff6c72b92f271a888b480a016c334b82a/src/helix/channels.rs#L82-L88
I decided to do it this way due to Twitch not guaranteeing a stable API themselves on documented items, so marking structs as #[non_exhaustive]
and using a builder seems better.
However, sometimes this makes things harder to use, as typed-builder
does not exactly make structs more accessible.
While this is done for stability, I feel like some structs don't lend themselves to the builder pattern, like the above example.
I want to solve this somehow, without sacrificing API stability.
To do that I think what needs to be done is creating methods for common usages of requests.
Example:
impl GetChannelInformationRequest {
pub fn get_channel(broadcaster: String) -> GetChannelInformationRequest {
GetChannelInformationRequest::builder().broadcaster_id(broadcaster).build()
}
}
impl GetGamesRequest {
pub fn get_game(id: types::CategoryId) -> GetGamesRequest {
GetGamesRequest::builder().id(vec![id]).build()
}
}
There is the crate derive_builder
that could help also.