forked from MightyPork/elefren-fork
making clippy happy
This commit is contained in:
@@ -38,7 +38,7 @@ jobs:
|
|||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: fmt
|
command: fmt
|
||||||
args: --features all --all -- --check
|
args: --verbose --all -- --check
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
|
|||||||
-42
@@ -1,42 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
language: rust
|
|
||||||
dist: trusty
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libssl-dev
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.cargo
|
|
||||||
env:
|
|
||||||
- ELEFREN_FEATURES="--features toml"
|
|
||||||
- ELEFREN_FEATURES="--features json"
|
|
||||||
- ELEFREN_FEATURES="--features all"
|
|
||||||
- ELEFREN_FEATURES=""
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
rust:
|
|
||||||
- stable
|
|
||||||
- beta
|
|
||||||
- nightly
|
|
||||||
script:
|
|
||||||
- cargo test $ELEFREN_FEATURES
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- name: "Coverage"
|
|
||||||
rust: nightly
|
|
||||||
before_cache: RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install -f cargo-tarpaulin
|
|
||||||
script: cargo build --features all
|
|
||||||
after_success: cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID --features all
|
|
||||||
|
|
||||||
- name: "rustfmt"
|
|
||||||
rust: nightly
|
|
||||||
before_script: rustup component add rustfmt-preview
|
|
||||||
script: cargo fmt --all -- --check
|
|
||||||
|
|
||||||
allow_failures:
|
|
||||||
- rust: nightly
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
on_success: never
|
|
||||||
+1
-2
@@ -10,7 +10,6 @@ keywords = ["api", "web", "social", "mastodon", "wrapper"]
|
|||||||
categories = ["web-programming", "web-programming::http-client", "api-bindings"]
|
categories = ["web-programming", "web-programming::http-client", "api-bindings"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
doc-comment = "0.3"
|
doc-comment = "0.3"
|
||||||
envy = { version = "0.4.0", optional = true }
|
envy = { version = "0.4.0", optional = true }
|
||||||
@@ -38,9 +37,9 @@ json = []
|
|||||||
env = ["envy"]
|
env = ["envy"]
|
||||||
all = ["toml", "json", "env"]
|
all = ["toml", "json", "env"]
|
||||||
rustls-tls = ["reqwest/rustls-tls"]
|
rustls-tls = ["reqwest/rustls-tls"]
|
||||||
|
nightly = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
skeptic = "0.13.3"
|
|
||||||
tempfile = "3.0.3"
|
tempfile = "3.0.3"
|
||||||
indoc = "1.0.2"
|
indoc = "1.0.2"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ impl<'a> AppBuilder<'a> {
|
|||||||
.redirect_uris
|
.redirect_uris
|
||||||
.unwrap_or_else(|| "urn:ietf:wg:oauth:2.0:oob".into())
|
.unwrap_or_else(|| "urn:ietf:wg:oauth:2.0:oob".into())
|
||||||
.into(),
|
.into(),
|
||||||
scopes: self.scopes.unwrap_or_else(|| Scopes::read_all()),
|
scopes: self.scopes.unwrap_or_else(Scopes::read_all),
|
||||||
website: self.website.map(|s| s.into()),
|
website: self.website.map(|s| s.into()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ pub(crate) struct Credentials {
|
|||||||
mod fields_attributes_ser {
|
mod fields_attributes_ser {
|
||||||
use super::*;
|
use super::*;
|
||||||
use serde::ser::{SerializeMap, Serializer};
|
use serde::ser::{SerializeMap, Serializer};
|
||||||
pub(crate) fn ser<S>(attrs: &Vec<MetadataField>, serializer: S) -> Result<S::Ok, S::Error>
|
pub(crate) fn ser<S>(attrs: &[MetadataField], serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::entities::{notification::Notification, status::Status};
|
use crate::entities::{notification::Notification, status::Status};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
/// Events that come from the /streaming/user API call
|
/// Events that come from the /streaming/user API call
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
/// Update event
|
/// Update event
|
||||||
|
|||||||
@@ -81,10 +81,8 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Iterator for ItemsIt
|
|||||||
}
|
}
|
||||||
Some(self.page.initial_items[idx].clone())
|
Some(self.page.initial_items[idx].clone())
|
||||||
} else {
|
} else {
|
||||||
if self.need_next_page() {
|
if self.need_next_page() && self.fill_next_page().is_none() {
|
||||||
if self.fill_next_page().is_none() {
|
return None;
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let idx = self.cur_idx;
|
let idx = self.cur_idx;
|
||||||
self.cur_idx += 1;
|
self.cur_idx += 1;
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use envy;
|
|
||||||
|
|
||||||
use crate::{data::Data, Result};
|
use crate::{data::Data, Result};
|
||||||
|
|
||||||
/// Attempts to deserialize a Data struct from the environment
|
/// Attempts to deserialize a Data struct from the environment
|
||||||
|
|||||||
+1
-3
@@ -4,8 +4,6 @@ use std::{
|
|||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde_json;
|
|
||||||
|
|
||||||
use crate::{data::Data, Result};
|
use crate::{data::Data, Result};
|
||||||
|
|
||||||
/// Attempts to deserialize a Data struct from a string
|
/// Attempts to deserialize a Data struct from a string
|
||||||
@@ -48,7 +46,7 @@ pub fn to_vec(data: &Data) -> Result<Vec<u8>> {
|
|||||||
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
||||||
let mut buf_writer = BufWriter::new(writer);
|
let mut buf_writer = BufWriter::new(writer);
|
||||||
let vec = to_vec(data)?;
|
let vec = to_vec(data)?;
|
||||||
buf_writer.write(&vec)?;
|
buf_writer.write_all(&vec)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ pub fn to_vec(data: &Data) -> Result<Vec<u8>> {
|
|||||||
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
pub fn to_writer<W: Write>(data: &Data, writer: W) -> Result<()> {
|
||||||
let mut buf_writer = BufWriter::new(writer);
|
let mut buf_writer = BufWriter::new(writer);
|
||||||
let vec = to_vec(data)?;
|
let vec = to_vec(data)?;
|
||||||
buf_writer.write(&vec)?;
|
buf_writer.write_all(&vec)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -69,7 +69,7 @@
|
|||||||
unused_import_braces,
|
unused_import_braces,
|
||||||
unused_qualifications
|
unused_qualifications
|
||||||
)]
|
)]
|
||||||
#![allow(broken_intra_doc_links)]
|
#![cfg_attr(feature = "nightly", allow(broken_intra_doc_links))]
|
||||||
|
|
||||||
use std::{borrow::Cow, io::BufRead, ops};
|
use std::{borrow::Cow, io::BufRead, ops};
|
||||||
|
|
||||||
@@ -254,9 +254,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
|
||||||
if status.is_client_error() {
|
if status.is_client_error() {
|
||||||
return Err(Error::Client(status.clone()));
|
return Err(Error::Client(status));
|
||||||
} else if status.is_server_error() {
|
} else if status.is_server_error() {
|
||||||
return Err(Error::Server(status.clone()));
|
return Err(Error::Server(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialise(response)
|
deserialise(response)
|
||||||
@@ -270,9 +270,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
|
||||||
if status.is_client_error() {
|
if status.is_client_error() {
|
||||||
return Err(Error::Client(status.clone()));
|
return Err(Error::Client(status));
|
||||||
} else if status.is_server_error() {
|
} else if status.is_server_error() {
|
||||||
return Err(Error::Server(status.clone()));
|
return Err(Error::Server(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialise(response)
|
deserialise(response)
|
||||||
@@ -286,9 +286,9 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
|
||||||
if status.is_client_error() {
|
if status.is_client_error() {
|
||||||
return Err(Error::Client(status.clone()));
|
return Err(Error::Client(status));
|
||||||
} else if status.is_server_error() {
|
} else if status.is_server_error() {
|
||||||
return Err(Error::Server(status.clone()));
|
return Err(Error::Server(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialise(response)
|
deserialise(response)
|
||||||
@@ -627,7 +627,7 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
.multipart(form_data),
|
.multipart(form_data),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let status = response.status().clone();
|
let status = response.status();
|
||||||
|
|
||||||
if status.is_client_error() {
|
if status.is_client_error() {
|
||||||
return Err(Error::Client(status));
|
return Err(Error::Client(status));
|
||||||
@@ -675,7 +675,7 @@ impl<R: EventStream> Iterator for EventReader<R> {
|
|||||||
loop {
|
loop {
|
||||||
if let Ok(line) = self.0.read_message() {
|
if let Ok(line) = self.0.read_message() {
|
||||||
let line = line.trim().to_string();
|
let line = line.trim().to_string();
|
||||||
if line.starts_with(":") || line.is_empty() {
|
if line.starts_with(':') || line.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
@@ -773,7 +773,7 @@ impl<H: HttpSend> MastodonBuilder<H> {
|
|||||||
pub fn build(self) -> Result<Mastodon<H>> {
|
pub fn build(self) -> Result<Mastodon<H>> {
|
||||||
Ok(if let Some(data) = self.data {
|
Ok(if let Some(data) = self.data {
|
||||||
Mastodon {
|
Mastodon {
|
||||||
client: self.client.unwrap_or_else(|| Client::new()),
|
client: self.client.unwrap_or_else(Client::new),
|
||||||
http_sender: self.http_sender,
|
http_sender: self.http_sender,
|
||||||
data,
|
data,
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -79,7 +79,7 @@ macro_rules! paged_routes {
|
|||||||
|
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param,
|
||||||
)*
|
)*
|
||||||
_marker: ::std::marker::PhantomData,
|
_marker: ::std::marker::PhantomData,
|
||||||
};
|
};
|
||||||
@@ -125,7 +125,7 @@ macro_rules! route_v2 {
|
|||||||
|
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param,
|
||||||
)*
|
)*
|
||||||
_marker: ::std::marker::PhantomData,
|
_marker: ::std::marker::PhantomData,
|
||||||
};
|
};
|
||||||
@@ -168,7 +168,7 @@ macro_rules! route {
|
|||||||
|
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param,
|
||||||
)*
|
)*
|
||||||
_marker: ::std::marker::PhantomData,
|
_marker: ::std::marker::PhantomData,
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -59,7 +59,7 @@ macro_rules! pages {
|
|||||||
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
||||||
/// }
|
/// }
|
||||||
/// let client = Mastodon::from(data);
|
/// let client = Mastodon::from(data);
|
||||||
/// let home = client.get_home_timeline()?.to_owned();
|
/// let home = client.get_home_timeline()?.into_owned();
|
||||||
/// let tl = HomeTimeline {
|
/// let tl = HomeTimeline {
|
||||||
/// client,
|
/// client,
|
||||||
/// page: RefCell::new(Some(home)),
|
/// page: RefCell::new(Some(home)),
|
||||||
@@ -148,7 +148,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Page<'a, T, H> {
|
|||||||
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
/// page: RefCell<Option<OwnedPage<Status, HttpSender>>>,
|
||||||
/// }
|
/// }
|
||||||
/// let client = Mastodon::from(data);
|
/// let client = Mastodon::from(data);
|
||||||
/// let home = client.get_home_timeline()?.to_owned();
|
/// let home = client.get_home_timeline()?.into_owned();
|
||||||
/// let tl = HomeTimeline {
|
/// let tl = HomeTimeline {
|
||||||
/// client,
|
/// client,
|
||||||
/// page: RefCell::new(Some(home)),
|
/// page: RefCell::new(Some(home)),
|
||||||
@@ -156,7 +156,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>, H: HttpSend> Page<'a, T, H> {
|
|||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn to_owned(self) -> OwnedPage<T, H> {
|
pub fn into_owned(self) -> OwnedPage<T, H> {
|
||||||
OwnedPage::from(self)
|
OwnedPage::from(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_REDIRECT_URI: &'static str = "urn:ietf:wg:oauth:2.0:oob";
|
const DEFAULT_REDIRECT_URI: &str = "urn:ietf:wg:oauth:2.0:oob";
|
||||||
|
|
||||||
/// Handles registering your mastodon app to your instance. It is recommended
|
/// Handles registering your mastodon app to your instance. It is recommended
|
||||||
/// you cache your data struct to avoid registering on every run.
|
/// you cache your data struct to avoid registering on every run.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::errors::Error;
|
use crate::errors::Error;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_qs;
|
|
||||||
use std::{borrow::Cow, convert::Into};
|
use std::{borrow::Cow, convert::Into};
|
||||||
|
|
||||||
mod bool_qs_serialize {
|
mod bool_qs_serialize {
|
||||||
@@ -59,7 +58,7 @@ impl<'a> Into<Option<StatusesRequest<'a>>> for &'a mut StatusesRequest<'a> {
|
|||||||
pinned: self.pinned,
|
pinned: self.pinned,
|
||||||
max_id: self.max_id.clone(),
|
max_id: self.max_id.clone(),
|
||||||
since_id: self.since_id.clone(),
|
since_id: self.since_id.clone(),
|
||||||
limit: self.limit.clone(),
|
limit: self.limit,
|
||||||
min_id: self.min_id.clone(),
|
min_id: self.min_id.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ impl UpdateCredsRequest {
|
|||||||
avatar: self.avatar.clone(),
|
avatar: self.avatar.clone(),
|
||||||
header: self.avatar.clone(),
|
header: self.avatar.clone(),
|
||||||
source: Some(UpdateSource {
|
source: Some(UpdateSource {
|
||||||
privacy: self.privacy.clone(),
|
privacy: self.privacy,
|
||||||
sensitive: self.sensitive.clone(),
|
sensitive: self.sensitive,
|
||||||
}),
|
}),
|
||||||
fields_attributes: self.field_attributes.clone(),
|
fields_attributes: self.field_attributes.clone(),
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-2
@@ -217,8 +217,7 @@ impl Scopes {
|
|||||||
let newset: HashSet<_> = self
|
let newset: HashSet<_> = self
|
||||||
.scopes
|
.scopes
|
||||||
.union(&other.scopes)
|
.union(&other.scopes)
|
||||||
.into_iter()
|
.copied()
|
||||||
.map(|s| *s)
|
|
||||||
.collect();
|
.collect();
|
||||||
Scopes {
|
Scopes {
|
||||||
scopes: newset,
|
scopes: newset,
|
||||||
|
|||||||
@@ -242,10 +242,10 @@ impl StatusBuilder {
|
|||||||
status: self.status.clone(),
|
status: self.status.clone(),
|
||||||
in_reply_to_id: self.in_reply_to_id.clone(),
|
in_reply_to_id: self.in_reply_to_id.clone(),
|
||||||
media_ids: self.media_ids.clone(),
|
media_ids: self.media_ids.clone(),
|
||||||
sensitive: self.sensitive.clone(),
|
sensitive: self.sensitive,
|
||||||
spoiler_text: self.spoiler_text.clone(),
|
spoiler_text: self.spoiler_text.clone(),
|
||||||
visibility: self.visibility.clone(),
|
visibility: self.visibility,
|
||||||
language: self.language.clone(),
|
language: self.language,
|
||||||
content_type: self.content_type.clone(),
|
content_type: self.content_type.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user