Add rustfmt and clippy to CI and address clippy warnings.
This commit is contained in:
parent
21c2288d51
commit
4a4c2dd025
@ -1 +0,0 @@
|
||||
merge_imports = true
|
@ -1,4 +1,12 @@
|
||||
language: "rust"
|
||||
before_script:
|
||||
- "rustup component add rustfmt"
|
||||
- "rustup component add clippy"
|
||||
script:
|
||||
- "cargo fmt --all -- --check"
|
||||
- "cargo clippy --all-targets --all-features -- -D warnings"
|
||||
- "cargo build --verbose"
|
||||
- "cargo test --verbose"
|
||||
notifications:
|
||||
email: false
|
||||
irc:
|
||||
|
26
src/lib.rs
26
src/lib.rs
@ -2,7 +2,31 @@
|
||||
//! endpoint in the [Matrix](https://matrix.org/) client API specification. These types can be
|
||||
//! shared by client and server code.
|
||||
|
||||
#![deny(missing_debug_implementations, missing_docs)]
|
||||
#![deny(
|
||||
missing_copy_implementations,
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
warnings
|
||||
)]
|
||||
#![warn(
|
||||
clippy::empty_line_after_outer_attr,
|
||||
clippy::expl_impl_clone_on_copy,
|
||||
clippy::if_not_else,
|
||||
clippy::items_after_statements,
|
||||
clippy::match_same_arms,
|
||||
clippy::mem_forget,
|
||||
clippy::missing_docs_in_private_items,
|
||||
clippy::multiple_inherent_impl,
|
||||
clippy::mut_mut,
|
||||
clippy::needless_borrow,
|
||||
clippy::needless_continue,
|
||||
clippy::single_match_else,
|
||||
clippy::unicode_not_nfc,
|
||||
clippy::use_self,
|
||||
clippy::used_underscore_binding,
|
||||
clippy::wrong_pub_self_convention,
|
||||
clippy::wrong_self_convention
|
||||
)]
|
||||
|
||||
pub mod r0;
|
||||
pub mod unversioned;
|
||||
|
@ -53,7 +53,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
/// Extra options to be added to the `m.room.create` event.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct CreationContent {
|
||||
/// Whether users on other servers can join this room.
|
||||
///
|
||||
|
@ -72,7 +72,7 @@ pub struct Criteria {
|
||||
}
|
||||
|
||||
/// Configures whether any context for the events returned are included in the response.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct EventContext {
|
||||
/// How many events after the result are returned.
|
||||
pub after_limit: u64,
|
||||
@ -103,7 +103,7 @@ pub struct EventContextResult {
|
||||
}
|
||||
|
||||
/// A grouping for partioning the result set.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct Grouping {
|
||||
/// The key within events to use for this grouping.
|
||||
pub key: GroupingKey,
|
||||
|
@ -53,7 +53,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
/// The medium of a third party identifier.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum Medium {
|
||||
/// An email address.
|
||||
#[serde(rename = "email")]
|
||||
@ -61,7 +61,7 @@ pub enum Medium {
|
||||
}
|
||||
|
||||
/// The authentication mechanism.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum LoginType {
|
||||
/// A password is supplied to authenticate.
|
||||
#[serde(rename = "m.login.password")]
|
||||
|
@ -52,7 +52,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
/// The direction to return events from.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum Direction {
|
||||
/// Return events backwards in time from the requested `from` token.
|
||||
#[serde(rename = "b")]
|
||||
|
@ -57,7 +57,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
/// Whether to set presence or not during sync.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum SetPresence {
|
||||
/// Do not set the presence of the user calling this API.
|
||||
#[serde(rename = "offline")]
|
||||
@ -80,16 +80,18 @@ pub enum Filter {
|
||||
// (there are probably some corner cases like leading whitespace)
|
||||
#[serde(with = "filter_def_serde")]
|
||||
/// A complete filter definition serialized to JSON.
|
||||
FilterDefinition(FilterDefinition),
|
||||
FilterDefinition(Box<FilterDefinition>),
|
||||
/// The ID of a filter saved on the server.
|
||||
FilterId(String),
|
||||
}
|
||||
|
||||
/// Serialization and deserialization logic for filter definitions.
|
||||
mod filter_def_serde {
|
||||
use serde::{de::Error as _, ser::Error as _, Deserialize, Deserializer, Serializer};
|
||||
|
||||
use crate::r0::filter::FilterDefinition;
|
||||
|
||||
/// Serialization logic for filter definitions.
|
||||
pub fn serialize<S>(filter_def: &FilterDefinition, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
@ -98,12 +100,15 @@ mod filter_def_serde {
|
||||
serializer.serialize_str(&string)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<FilterDefinition, D::Error>
|
||||
/// Deserialization logic for filter definitions.
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Box<FilterDefinition>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let filter_str = <&str>::deserialize(deserializer)?;
|
||||
serde_json::from_str(filter_str).map_err(D::Error::custom)
|
||||
serde_json::from_str(filter_str)
|
||||
.map(Box::new)
|
||||
.map_err(D::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +152,7 @@ pub struct JoinedRoom {
|
||||
}
|
||||
|
||||
/// unread notifications count
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct UnreadNotificationsCount {
|
||||
/// The number of unread notifications for this room with the highlight flag set.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! Endpoints that cannot change with new versions of the Matrix specification.
|
||||
|
||||
pub mod get_supported_versions;
|
||||
pub mod discover_homeserver;
|
||||
pub mod get_supported_versions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user