client-api: Fix check warnings and tests with no feature enabled
This commit is contained in:
parent
dbc6bb29d0
commit
b89a18fa16
@ -84,5 +84,8 @@ pub fn expand_all(api: Api) -> syn::Result<TokenStream> {
|
|||||||
|
|
||||||
#request
|
#request
|
||||||
#response
|
#response
|
||||||
|
|
||||||
|
#[cfg(not(any(feature = "client", feature = "server")))]
|
||||||
|
type _SilenceUnusedError = #error_ty;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -69,16 +69,17 @@ impl Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, any(feature = "client", feature = "server")))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use js_int::uint;
|
use js_int::uint;
|
||||||
use ruma_api::OutgoingRequest as _;
|
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
#[test]
|
#[test]
|
||||||
fn construct_request_from_refs() {
|
fn construct_request_from_refs() {
|
||||||
|
use ruma_api::OutgoingRequest;
|
||||||
|
|
||||||
let req: http::Request<Vec<u8>> = super::Request {
|
let req: http::Request<Vec<u8>> = super::Request {
|
||||||
limit: Some(uint!(10)),
|
limit: Some(uint!(10)),
|
||||||
since: Some("hello"),
|
since: Some("hello"),
|
||||||
|
@ -131,7 +131,7 @@ pub enum Direction {
|
|||||||
Forward,
|
Forward,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, feature = "client"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use js_int::uint;
|
use js_int::uint;
|
||||||
use ruma_api::OutgoingRequest;
|
use ruma_api::OutgoingRequest;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
//! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
|
||||||
|
|
||||||
use ruma_api::{ruma_api, Metadata};
|
use ruma_api::ruma_api;
|
||||||
use ruma_events::{AnyMessageEventContent, EventContent as _};
|
use ruma_events::AnyMessageEventContent;
|
||||||
use ruma_identifiers::{EventId, RoomId};
|
use ruma_identifiers::{EventId, RoomId};
|
||||||
use ruma_serde::Outgoing;
|
use ruma_serde::Outgoing;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type IncomingResponse = Response;
|
type IncomingResponse = Response;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_into_http_request(
|
fn try_into_http_request(
|
||||||
self,
|
self,
|
||||||
@ -72,6 +72,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
) -> Result<http::Request<Vec<u8>>, ruma_api::error::IntoHttpError> {
|
) -> Result<http::Request<Vec<u8>>, ruma_api::error::IntoHttpError> {
|
||||||
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
|
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
|
||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
|
use ruma_events::EventContent;
|
||||||
|
|
||||||
let http_request = http::Request::builder()
|
let http_request = http::Request::builder()
|
||||||
.method(http::Method::PUT)
|
.method(http::Method::PUT)
|
||||||
@ -101,7 +102,7 @@ impl ruma_api::IncomingRequest for IncomingRequest {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type OutgoingResponse = Response;
|
type OutgoingResponse = Response;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_from_http_request(
|
fn try_from_http_request(
|
||||||
request: http::Request<Vec<u8>>,
|
request: http::Request<Vec<u8>>,
|
||||||
@ -109,6 +110,7 @@ impl ruma_api::IncomingRequest for IncomingRequest {
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use ruma_api::try_deserialize;
|
use ruma_api::try_deserialize;
|
||||||
|
use ruma_events::EventContent;
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
|
||||||
let path_segments: Vec<&str> = request.uri().path()[1..].split('/').collect();
|
let path_segments: Vec<&str> = request.uri().path()[1..].split('/').collect();
|
||||||
|
@ -154,12 +154,9 @@ mod user_serde;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
use ruma_api::OutgoingRequest;
|
use serde_json::{from_value as from_json_value, json};
|
||||||
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
|
|
||||||
|
|
||||||
use super::{
|
use super::{IncomingLoginInfo, IncomingUserIdentifier};
|
||||||
IncomingLoginInfo, IncomingUserIdentifier, LoginInfo, Medium, Request, UserIdentifier,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_login_type() {
|
fn deserialize_login_type() {
|
||||||
@ -202,7 +199,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature = "client")]
|
||||||
fn serialize_login_request_body() {
|
fn serialize_login_request_body() {
|
||||||
|
use ruma_api::OutgoingRequest;
|
||||||
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
|
use super::{LoginInfo, Medium, Request, UserIdentifier};
|
||||||
|
|
||||||
let req: http::Request<Vec<u8>> = Request {
|
let req: http::Request<Vec<u8>> = Request {
|
||||||
login_info: LoginInfo::Token { token: "0xdeadbeef" },
|
login_info: LoginInfo::Token { token: "0xdeadbeef" },
|
||||||
device_id: None,
|
device_id: None,
|
||||||
|
@ -44,7 +44,7 @@ impl Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, feature = "client"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ruma_api::OutgoingRequest;
|
use ruma_api::OutgoingRequest;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
||||||
|
|
||||||
use ruma_api::{ruma_api, Metadata};
|
use ruma_api::ruma_api;
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use ruma_serde::Outgoing;
|
use ruma_serde::Outgoing;
|
||||||
@ -61,7 +61,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type IncomingResponse = <Response as ruma_serde::Outgoing>::Incoming;
|
type IncomingResponse = <Response as ruma_serde::Outgoing>::Incoming;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_into_http_request(
|
fn try_into_http_request(
|
||||||
self,
|
self,
|
||||||
@ -106,7 +106,7 @@ impl ruma_api::IncomingRequest for IncomingRequest {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type OutgoingResponse = Response;
|
type OutgoingResponse = Response;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_from_http_request(
|
fn try_from_http_request(
|
||||||
request: http::Request<Vec<u8>>,
|
request: http::Request<Vec<u8>>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
//! [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
|
||||||
|
|
||||||
use ruma_api::{ruma_api, Metadata};
|
use ruma_api::ruma_api;
|
||||||
use ruma_events::{AnyStateEventContent, EventContent as _};
|
use ruma_events::AnyStateEventContent;
|
||||||
use ruma_identifiers::{EventId, RoomId};
|
use ruma_identifiers::{EventId, RoomId};
|
||||||
use ruma_serde::Outgoing;
|
use ruma_serde::Outgoing;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type IncomingResponse = Response;
|
type IncomingResponse = Response;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_into_http_request(
|
fn try_into_http_request(
|
||||||
self,
|
self,
|
||||||
@ -70,6 +70,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
|
|||||||
|
|
||||||
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
|
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
|
||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
|
use ruma_events::EventContent;
|
||||||
|
|
||||||
let mut url = format!(
|
let mut url = format!(
|
||||||
"{}/_matrix/client/r0/rooms/{}/state/{}",
|
"{}/_matrix/client/r0/rooms/{}/state/{}",
|
||||||
@ -105,7 +106,7 @@ impl ruma_api::IncomingRequest for IncomingRequest {
|
|||||||
type EndpointError = crate::Error;
|
type EndpointError = crate::Error;
|
||||||
type OutgoingResponse = Response;
|
type OutgoingResponse = Response;
|
||||||
|
|
||||||
const METADATA: Metadata = METADATA;
|
const METADATA: ruma_api::Metadata = METADATA;
|
||||||
|
|
||||||
fn try_from_http_request(
|
fn try_from_http_request(
|
||||||
request: http::Request<Vec<u8>>,
|
request: http::Request<Vec<u8>>,
|
||||||
@ -113,6 +114,7 @@ impl ruma_api::IncomingRequest for IncomingRequest {
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use ruma_api::try_deserialize;
|
use ruma_api::try_deserialize;
|
||||||
|
use ruma_events::EventContent;
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
|
|
||||||
let path_segments: Vec<&str> = request.uri().path()[1..].split('/').collect();
|
let path_segments: Vec<&str> = request.uri().path()[1..].split('/').collect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user