Skip to content
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

Make many HTTP functions constant #1010

Merged
merged 3 commits into from
Jul 20, 2021
Merged

Make many HTTP functions constant #1010

merged 3 commits into from
Jul 20, 2021

Conversation

zeylahellyer
Copy link
Member

@zeylahellyer zeylahellyer commented Jul 3, 2021

Make many request and client methods constant by primarily removing Default implementation usage on fields and removing Option::replace usage.

Blocks on #1009. #1009 has been merged.

@zeylahellyer zeylahellyer added c-http Affects the http crate t-enhancement labels Jul 3, 2021
@zeylahellyer zeylahellyer marked this pull request as draft July 13, 2021 23:24
Make many request and client methods constant by primarily removing
`Default` implementation usage on fields and removing `Option::replace`
usage.

Signed-off-by: Zeyla Hellyer <zeyla@hellyer.dev>
@zeylahellyer zeylahellyer marked this pull request as ready for review July 17, 2021 01:22
@zeylahellyer zeylahellyer marked this pull request as draft July 17, 2021 01:23
Signed-off-by: Zeyla Hellyer <zeyla@hellyer.dev>
@zeylahellyer zeylahellyer marked this pull request as ready for review July 17, 2021 19:21
@zeylahellyer
Copy link
Member Author

Ready for review now.

http/src/response/mod.rs Show resolved Hide resolved
http/src/request/guild/create_guild/builder.rs Outdated Show resolved Hide resolved
http/src/request/guild/create_guild/builder.rs Outdated Show resolved Hide resolved
Signed-off-by: Zeyla Hellyer <zeyla@hellyer.dev>
@zeylahellyer
Copy link
Member Author

Comments addressed. The Create Guild request module has been largely untouched from this PR due to requiring a complete rework.

@7596ff 7596ff merged commit 79a325b into twilight-rs:next Jul 20, 2021
@zeylahellyer zeylahellyer deleted the enhancement/http/const branch July 21, 2021 01:56
7596ff pushed a commit to 7596ff/twilight that referenced this pull request Jul 25, 2021
Make many request and client methods constant by primarily removing
`Default` implementation usage on fields and removing `Option::replace`
usage.
7596ff pushed a commit to 7596ff/twilight that referenced this pull request Jul 25, 2021
Make many request and client methods constant by primarily removing
`Default` implementation usage on fields and removing `Option::replace`
usage.
7596ff pushed a commit to 7596ff/twilight that referenced this pull request Jul 31, 2021
Make many request and client methods constant by primarily removing
`Default` implementation usage on fields and removing `Option::replace`
usage.
7596ff added a commit that referenced this pull request Jul 31, 2021
Enhancements

Many functions have been made constant ([#1010] - [@zeylahellyer]).

Changes

There are significant changes to how users make HTTP requests. When
users make a request, they must pass borrowed types instead of owned
types. To execute the request, users must call `exec` on the request
builder. Once the request has completed execution, users may use the
`ResponseFuture` struct methods to access the status code of the
request. To access a returned model, if there is one, users must call
`model` on the response.

A call to `Client::create_message` like this:

```rust
client.create_message(ChannelId(1))
    .content("some content")?
    .embed(Embed {})?
    .await?;
```

is now written like this:

```rust
client.create_message(ChannelId(1))
    .content(&"some conntent")?
    .embeds(&[&Embed {}])?
    .exec()
    .await?
    .model()
    .await?;
```

For more information on the motivation behind these changes, see the PR
descriptions of [#923], [#1008], and [#1009]. These changes were
authored by [@zeylahellyer].

Rename `ErrorCode::UnallowedWordsForPublicStage` variant to
`UnallowedWords` ([#956] - [@7596ff])

`CreateGlobalCommand`, `CreateGuildCommand`, `SetGlobalCommands`, and
`SetGuildCommands` now return command(s) ([#1037] - [@vilgotf]).

A few spelling errors have been fixed by adding the `codespell` Action
([#1041] - [@Gelbpunkt].

[#923]: #923
[#956]: #956
[#1008]: #1008
[#1009]: #1009
[#1010]: #1010
[#1037]: #1037
[#1041]: #1041

[@7596ff]: https://github.com/7596ff
[@Gelbpunkt]: https://github.com/Gelbpunkt
[@vilgotf]: https://github.com/vilgotf
[@zeylahellyer]: https://github.com/zeylahellyer
Erk- pushed a commit to Erk-/twilight that referenced this pull request Aug 9, 2021
Make many request and client methods constant by primarily removing
`Default` implementation usage on fields and removing `Option::replace`
usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-http Affects the http crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants