Add clippy lints.
This commit is contained in:
parent
97b42c9d10
commit
71e1df7063
14
src/error.rs
14
src/error.rs
@ -1,3 +1,5 @@
|
||||
//! Error conditions.
|
||||
|
||||
use http::uri::InvalidUri;
|
||||
use hyper::error::Error as HyperError;
|
||||
use ruma_api::Error as RumaApiError;
|
||||
@ -25,37 +27,37 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl From<HyperError> for Error {
|
||||
fn from(error: HyperError) -> Error {
|
||||
fn from(error: HyperError) -> Self {
|
||||
Error::Hyper(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InvalidUri> for Error {
|
||||
fn from(error: InvalidUri) -> Error {
|
||||
fn from(error: InvalidUri) -> Self {
|
||||
Error::Uri(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseError> for Error {
|
||||
fn from(error: ParseError) -> Error {
|
||||
fn from(error: ParseError) -> Self {
|
||||
Error::Url(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RumaApiError> for Error {
|
||||
fn from(error: RumaApiError) -> Error {
|
||||
fn from(error: RumaApiError) -> Self {
|
||||
Error::RumaApi(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SerdeJsonError> for Error {
|
||||
fn from(error: SerdeJsonError) -> Error {
|
||||
fn from(error: SerdeJsonError) -> Self {
|
||||
Error::SerdeJson(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SerdeUrlEncodedSerializeError> for Error {
|
||||
fn from(error: SerdeUrlEncodedSerializeError) -> Error {
|
||||
fn from(error: SerdeUrlEncodedSerializeError) -> Self {
|
||||
Error::SerdeUrlEncodedSerialize(error)
|
||||
}
|
||||
}
|
||||
|
39
src/lib.rs
39
src/lib.rs
@ -1,7 +1,29 @@
|
||||
//! Crate `ruma_client` is a [Matrix](https://matrix.org/) client library.
|
||||
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![deny(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::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
|
||||
)]
|
||||
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
@ -41,15 +63,18 @@ struct ClientData<C>
|
||||
where
|
||||
C: Connect,
|
||||
{
|
||||
/// The URL of the homeserver to connect to.
|
||||
homeserver_url: Url,
|
||||
/// The underlying HTTP client.
|
||||
hyper: HyperClient<C>,
|
||||
/// User session data.
|
||||
session: Mutex<Option<Session>>,
|
||||
}
|
||||
|
||||
impl Client<HttpConnector> {
|
||||
/// Creates a new client for making HTTP requests to the given homeserver.
|
||||
pub fn new(homeserver_url: Url, session: Option<Session>) -> Self {
|
||||
Client(Arc::new(ClientData {
|
||||
Self(Arc::new(ClientData {
|
||||
homeserver_url,
|
||||
hyper: HyperClient::builder().keep_alive(true).build_http(),
|
||||
session: Mutex::new(session),
|
||||
@ -63,7 +88,7 @@ impl Client<HttpsConnector<HttpConnector>> {
|
||||
pub fn https(homeserver_url: Url, session: Option<Session>) -> Result<Self, NativeTlsError> {
|
||||
let connector = HttpsConnector::new(4)?;
|
||||
|
||||
Ok(Client(Arc::new(ClientData {
|
||||
Ok(Self(Arc::new(ClientData {
|
||||
homeserver_url,
|
||||
hyper: { HyperClient::builder().keep_alive(true).build(connector) },
|
||||
session: Mutex::new(session),
|
||||
@ -83,7 +108,7 @@ where
|
||||
homeserver_url: Url,
|
||||
session: Option<Session>,
|
||||
) -> Self {
|
||||
Client(Arc::new(ClientData {
|
||||
Self(Arc::new(ClientData {
|
||||
homeserver_url,
|
||||
hyper: hyper_client,
|
||||
session: Mutex::new(session),
|
||||
@ -290,7 +315,7 @@ where
|
||||
}
|
||||
|
||||
impl<C: Connect> Clone for Client<C> {
|
||||
fn clone(&self) -> Client<C> {
|
||||
Client(self.0.clone())
|
||||
fn clone(&self) -> Self {
|
||||
Self(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! User sessions.
|
||||
|
||||
use ruma_identifiers::UserId;
|
||||
|
||||
/// A user session, containing an access token and information about the associated user account.
|
||||
@ -15,7 +17,7 @@ impl Session {
|
||||
/// Create a new user session from an access token and a user ID.
|
||||
#[deprecated]
|
||||
pub fn new(access_token: String, user_id: UserId, device_id: String) -> Self {
|
||||
Session {
|
||||
Self {
|
||||
access_token,
|
||||
user_id,
|
||||
device_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user