76 Commits

Author SHA1 Message Date
Jonas Platte
12ec0fb168
api: Rename SendAccessToken methods to be clearer
Co-authored-by: Johannes Becker <j.becker@famedly.com>
2021-04-23 15:01:57 +02:00
Jonas Platte
1e005f576e
api: Slightly optimize OutgoingRequest implementations 2021-04-23 13:37:13 +02:00
Jonas Platte
f818b53ca1
Make conversions from Ruma types to http types generic
So users can select the Body type that makes the most sense for them.
2021-04-23 13:26:10 +02:00
Jonas Platte
ae26be88c5
api-macros: Refactor access token sending logic 2021-04-23 13:22:20 +02:00
Johannes Becker
0ca5785ead api: Replace access_token Option with SendAccessToken enum 2021-04-23 10:56:04 +02:00
Jonas Platte
c816630058
client-api: Allow testing sync_events structs for exhaustiveness
… even without `unstable-exhaustive-types`.
2021-04-19 01:37:32 +02:00
Jonas Platte
c1693569f1
api: Replace bytes::Buf by AsRef<u8> for reading
This allows us to switch back to serde_json::from_slice instead of
serde_json::from_reader, because the latter is significantly slower.

See https://github.com/serde-rs/json/issues/160
2021-04-13 22:12:16 +02:00
Jonas Platte
e4ae2a40ee
Qualify more paths in macro-generated code 2021-04-13 21:50:01 +02:00
Jonas Platte
96aa55e3b9
api-macros: Silence warning about unknown clippy lint for older clippy versions 2021-04-13 15:08:33 +02:00
Jonas Platte
6585aeb628
api: Make OutgoingResponse a supertrait of EndpointError 2021-04-13 13:15:57 +02:00
Devin Ragotzy
f2286f8ae5 Fix confusing variable naming in ruma-api-macros 2021-04-13 01:17:46 +02:00
Jonas Platte
15d92728ca
api-macros: Silence clippy::inconsistent_struct_constructor in generated code 2021-04-12 20:38:23 +02:00
Jonas Platte
15433a9751
api-macros: Fix a typo 2021-04-12 20:38:23 +02:00
Jonas Platte
e7a31f1fd1
api-macros: Split response code generation into more files 2021-04-12 20:38:23 +02:00
Jonas Platte
59d47227a6
api-macros: Split request code generation into more files 2021-04-12 20:38:23 +02:00
Jonas Platte
0e197aae0b
api: Update try_from_http_request to be generic like try_from_http_response 2021-04-12 20:38:22 +02:00
Jonas Platte
23ba0bc164
api-macros: Refactor request code generation 2021-04-12 20:38:22 +02:00
Jonas Platte
a20f03894e
api-macros: Inline request codegen methods 2021-04-12 20:38:22 +02:00
Jonas Platte
2e2609b752
api-macros: Fix a typo 2021-04-12 20:38:22 +02:00
Jonas Platte
b122dcc135
api: Introduce OutgoingResponse trait 2021-04-12 20:38:22 +02:00
Jonas Platte
6f5c1ee953
api: Stop storing the http::Request in RequestDeserializationError 2021-04-12 20:38:22 +02:00
Jonas Platte
2ac020173b
api: Introduce IncomingResponse trait 2021-04-12 20:38:22 +02:00
Jonas Platte
effb53444d
api: Stop storing the http::Response in ResponseDeserializationError 2021-04-12 20:38:22 +02:00
Jonas Platte
a68b854734
api: Refactor macro code and improve error handling
* Inline lots of methods that were only used once
* Create a separate error case for missing headers
2021-04-10 14:50:01 +02:00
Jonas Platte
20124cb215
api-macros: Small formatting fixes 2021-04-09 19:34:03 +02:00
Abhik Jain
455eb31c74
api-macros: Turn request codegen helper functions into methods 2021-04-09 19:28:33 +02:00
Akshay
06a2a27a99
api: Check http method in try_from_http_request 2021-04-09 17:21:05 +02:00
Jonas Platte
afec9f0fbf
api-macros: Generate cleaner code 2021-04-05 22:16:46 +02:00
Jonas Platte
345d0cf990
api-macros: Allow ruma_api! invocation without request / response 2021-04-05 14:49:40 +02:00
Jonas Platte
95fef0b0ec
api-macros: Make helper functions private 2021-04-05 14:13:49 +02:00
Jonas Platte
7cb7e6a211
api-macros: Move most parts of api and util into more specific modules 2021-04-05 14:05:43 +02:00
Jonas Platte
1878e8aae0
Replace some turbofishes with type annotations 2021-04-05 13:13:28 +02:00
Jonas Platte
536a8aea1b
api-macros: Replace ToTokens implementations with inherent methods 2021-04-05 12:57:50 +02:00
Jonas Platte
2e0f787ccd
api-macros: Refactor parsing logic 2021-04-05 12:39:22 +02:00
Jonas Platte
e8e0ceb17d
api-macros: Move some helper functions from util to api::parse 2021-04-05 12:18:54 +02:00
Jonas Platte
1dd6a3870a
Use mem::take instead of mem::replace where applicable 2021-04-05 12:08:29 +02:00
Jonas Platte
679508f831
api-macros: Move parsing logic into a separate module 2021-04-05 12:07:34 +02:00
Jonas Platte
4ced423612
Fix new clippy warnings 2021-03-01 18:38:41 +01:00
Akshay
1c0dab5a47
api: Allow cfg attributes on rate_limited and authentication metadata fields 2021-02-05 12:47:43 +01:00
Akshay
b087cf75b7
Set the default Content-Type for requests to application/json 2021-01-22 17:39:06 +01:00
Jonas Platte
ae6595339c
Stop stripping serde attributes
To still prevent 'unknown attribute' errors, the attribute is registered
using a dummy derive macro where needed.
2020-12-13 11:54:39 +01:00
Jonas Platte
5562a23aaa
Move Raw, Outgoing and all macro code from ruma-common to ruma-serde 2020-11-28 03:45:39 +01:00
Jonas Platte
5175d3d622
api_macros: Improve readability, fix lines >100 chars 2020-11-27 23:06:31 +01:00
Jonas Platte
a6ff054ba3
api-macros: Refactor metadata parsing
* duplicate field assignment will now raise an error
* parsing should now be faster (though it probably doesn't matter)
* the code is now split into more independent parts
2020-11-27 21:44:59 +01:00
Jonas Platte
4d9fdeb61d
api-macros: Remove RawResponse 2020-11-27 21:15:37 +01:00
Jonas Platte
05249c6cdb
api-macros: Remove RawRequest 2020-11-27 21:15:37 +01:00
Jonas Platte
00ae067bce
api-macros: Remove RawMetadata 2020-11-27 21:15:37 +01:00
Devin Ragotzy
c15382ca41
api-macros: Make Response header fields override any defaults 2020-11-01 14:04:34 +01:00
Jonas Platte
e1975c2035
Be more consistent about whitespace 2020-10-24 00:44:01 +02:00
Jonas Platte
fdd326edf7
Move Outgoing from ruma-api to ruma-common
The derive macro moves from ruma-api-macros to a new ruma-common-macros
crate likewise.
2020-09-22 21:35:10 +02:00