Various cleanup tasks

* Remove old `extern crate` stmts
* Remove rust-skeptic
* Clean up Cargo.toml
This commit is contained in:
Paul Woolcock
2020-09-25 16:44:06 -04:00
parent c30b4da57c
commit 0b4ee7bfb2
38 changed files with 64 additions and 112 deletions
+1
View File
@@ -1,5 +1,6 @@
use std::borrow::Cow;
use serde::Serialize;
use try_from::TryInto;
use crate::errors::{Error, Result};
+1
View File
@@ -1,4 +1,5 @@
use std::borrow::Cow;
use serde::{Serialize, Deserialize};
/// Raw data about mastodon app. Save `Data` using `serde` to prevent needing
/// to authenticate on every run.
+3 -2
View File
@@ -1,7 +1,8 @@
//! A module containing everything relating to a account returned from the api.
use chrono::prelude::*;
use serde::de::{self, Deserialize, Deserializer, Unexpected};
use serde::{Deserialize, Serialize};
use serde::de::{self, Unexpected};
use crate::status_builder;
use std::path::PathBuf;
@@ -79,7 +80,7 @@ pub struct Source {
fields: Option<Vec<MetadataField>>,
}
fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bool, D::Error> {
fn string_or_bool<'de, D: de::Deserializer<'de>>(val: D) -> ::std::result::Result<bool, D::Error> {
#[derive(Clone, Debug, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum BoolOrString {
+1
View File
@@ -1,4 +1,5 @@
//! Module containing everything related to media attachements.
use serde::Deserialize;
/// A struct representing a media attachment.
#[derive(Debug, Clone, Deserialize, PartialEq)]
+1
View File
@@ -1,4 +1,5 @@
//! Module representing cards of statuses.
use serde::Deserialize;
/// A card of a status.
#[derive(Debug, Clone, Deserialize, PartialEq)]
+1
View File
@@ -1,4 +1,5 @@
//! A module about contexts of statuses.
use serde::Deserialize;
use super::status::Status;
+2
View File
@@ -1,3 +1,5 @@
use serde::{Serialize, Deserialize};
/// Represents a single Filter
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Filter {
+1
View File
@@ -1,4 +1,5 @@
//! Module containing everything related to an instance.
use serde::Deserialize;
use super::account::Account;
/// A struct containing info of an instance.
+1
View File
@@ -1,3 +1,4 @@
use serde::Deserialize;
/// Used for ser/de of list resources
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct List {
+2
View File
@@ -1,3 +1,5 @@
use serde::Deserialize;
/// Data structures for ser/de of account-related resources
pub mod account;
/// Data structures for ser/de of attachment-related resources
+1
View File
@@ -1,5 +1,6 @@
//! Module containing all info about notifications.
use serde::Deserialize;
use super::{account::Account, status::Status};
use chrono::prelude::*;
+4
View File
@@ -1,3 +1,5 @@
use serde::{Deserialize, Serialize};
/// Represents the `alerts` key of the `Subscription` object
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Default)]
pub struct Alerts {
@@ -25,6 +27,7 @@ pub struct Subscription {
}
pub(crate) mod add_subscription {
use serde::Serialize;
use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
@@ -52,6 +55,7 @@ pub(crate) mod add_subscription {
}
pub(crate) mod update_data {
use serde::Serialize;
use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
+1
View File
@@ -1,5 +1,6 @@
//! module containing everything relating to a relationship with
//! another account.
use serde::Deserialize;
/// A struct containing information about a relationship with another account.
#[derive(Debug, Clone, Deserialize, PartialEq)]
+1
View File
@@ -1,4 +1,5 @@
//! module containing information about a finished report of a user.
use serde::Deserialize;
/// A struct containing info about a report.
#[derive(Debug, Clone, Deserialize, PartialEq)]
+1
View File
@@ -1,4 +1,5 @@
//! A module containing info relating to a search result.
use serde::Deserialize;
use super::{
prelude::{Account, Status},
+1
View File
@@ -4,6 +4,7 @@ use super::prelude::*;
use chrono::prelude::*;
use crate::entities::card::Card;
use crate::status_builder::Visibility;
use serde::Deserialize;
/// A status from the instance.
#[derive(Debug, Clone, Deserialize, PartialEq)]
+4 -4
View File
@@ -1,4 +1,5 @@
use std::{error, fmt, io::Error as IoError};
use serde::Deserialize;
#[cfg(feature = "env")]
use envy::Error as EnvyError;
@@ -8,9 +9,9 @@ use serde_json::Error as SerdeError;
use serde_qs::Error as SerdeQsError;
use serde_urlencoded::ser::Error as UrlEncodedError;
#[cfg(feature = "toml")]
use crate::tomlcrate::de::Error as TomlDeError;
use ::toml::de::Error as TomlDeError;
#[cfg(feature = "toml")]
use crate::tomlcrate::ser::Error as TomlSerError;
use ::toml::ser::Error as TomlSerError;
use url::ParseError as UrlError;
use tungstenite::error::Error as WebSocketError;
@@ -237,8 +238,7 @@ mod tests {
#[cfg(feature = "toml")]
#[test]
fn from_toml_de_error() {
use crate::tomlcrate;
let err: TomlDeError = tomlcrate::from_str::<()>("not valid toml").unwrap_err();
let err: TomlDeError = ::toml::from_str::<()>("not valid toml").unwrap_err();
let err: Error = Error::from(err);
assert_is!(err, Error::TomlDe(..));
}
+1 -1
View File
@@ -83,7 +83,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile};
const DOC: &'static str = indoc!(
const DOC: &'static str = indoc::indoc!(
r#"
{
"base": "https://example.com",
+5 -7
View File
@@ -4,19 +4,17 @@ use std::{
path::Path,
};
use crate::tomlcrate;
use crate::data::Data;
use crate::Result;
/// Attempts to deserialize a Data struct from a string
pub fn from_str(s: &str) -> Result<Data> {
Ok(tomlcrate::from_str(s)?)
Ok(toml::from_str(s)?)
}
/// Attempts to deserialize a Data struct from a slice of bytes
pub fn from_slice(s: &[u8]) -> Result<Data> {
Ok(tomlcrate::from_slice(s)?)
Ok(toml::from_slice(s)?)
}
/// Attempts to deserialize a Data struct from something that implements
@@ -36,12 +34,12 @@ pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Data> {
/// Attempts to serialize a Data struct to a String
pub fn to_string(data: &Data) -> Result<String> {
Ok(tomlcrate::to_string_pretty(data)?)
Ok(toml::to_string_pretty(data)?)
}
/// Attempts to serialize a Data struct to a Vec of bytes
pub fn to_vec(data: &Data) -> Result<Vec<u8>> {
Ok(tomlcrate::to_vec(data)?)
Ok(toml::to_vec(data)?)
}
/// Attempts to serialize a Data struct to something that implements the
@@ -83,7 +81,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile};
const DOC: &'static str = indoc!(
const DOC: &'static str = indoc::indoc!(
r#"
base = "https://example.com"
client_id = "adbc01234"
+4 -36
View File
@@ -69,40 +69,7 @@
unused_import_braces,
unused_qualifications
)]
#![allow(intra_doc_link_resolution_failure)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate doc_comment;
extern crate hyper_old_types;
extern crate isolang;
#[macro_use]
extern crate serde_json;
extern crate chrono;
extern crate reqwest;
extern crate serde;
extern crate serde_qs;
extern crate serde_urlencoded;
extern crate tap_reader;
extern crate try_from;
extern crate url;
extern crate tungstenite;
#[cfg(feature = "env")]
extern crate envy;
#[cfg(feature = "toml")]
extern crate toml as tomlcrate;
#[cfg(test)]
extern crate tempfile;
#[cfg(test)]
#[cfg_attr(all(test, any(feature = "toml", feature = "json")), macro_use)]
extern crate indoc;
#![allow(broken_intra_doc_links)]
use std::{
borrow::Cow,
@@ -724,6 +691,7 @@ impl<R: EventStream> EventReader<R> {
event = event_line[6..].trim().to_string();
data = lines.iter().find(|line| line.starts_with("data:")).map(|x| x[5..].trim().to_string());
} else {
use serde::Deserialize;
#[derive(Deserialize)]
struct Message {
pub event: String,
@@ -891,13 +859,13 @@ fn deserialise<T: for<'de> serde::Deserialize<'de>>(response: Response) -> Resul
match serde_json::from_reader(&mut reader) {
Ok(t) => {
debug!("{}", String::from_utf8_lossy(&reader.bytes));
log::debug!("{}", String::from_utf8_lossy(&reader.bytes));
Ok(t)
},
// If deserializing into the desired type fails try again to
// see if this is an error response.
Err(e) => {
error!("{}", String::from_utf8_lossy(&reader.bytes));
log::error!("{}", String::from_utf8_lossy(&reader.bytes));
if let Ok(error) = serde_json::from_slice(&reader.bytes) {
return Err(Error::Api(error));
}
+12 -9
View File
@@ -17,7 +17,7 @@ macro_rules! methods {
macro_rules! paged_routes {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `", stringify!($method), " /api/v1/",
$url,
@@ -55,7 +55,7 @@ macro_rules! paged_routes {
};
((get ($($(#[$m:meta])* $param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `get /api/v1/",
$url,
@@ -63,6 +63,7 @@ macro_rules! paged_routes {
),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<Page<$ret, H>> {
use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)]
struct Data<'a> {
@@ -103,7 +104,7 @@ macro_rules! paged_routes {
macro_rules! route_v2 {
((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `get /api/v2/",
$url,
@@ -111,6 +112,7 @@ macro_rules! route_v2 {
),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> {
use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)]
struct Data<'a> {
@@ -145,7 +147,7 @@ macro_rules! route_v2 {
macro_rules! route {
((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `get /api/v1/",
$url,
@@ -153,6 +155,7 @@ macro_rules! route {
),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> {
use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)]
struct Data<'a> {
@@ -182,7 +185,7 @@ macro_rules! route {
};
(($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `", stringify!($method), " /api/v1/",
$url,
@@ -190,7 +193,7 @@ macro_rules! route {
),
fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
let form_data = json!({
let form_data = serde_json::json!({
$(
stringify!($param): $param,
)*
@@ -217,7 +220,7 @@ macro_rules! route {
};
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `", stringify!($method), " /api/v1/",
$url,
@@ -255,7 +258,7 @@ macro_rules! route_id {
($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => {
$(
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `", stringify!($method), " /api/v1/",
$url,
@@ -289,7 +292,7 @@ macro_rules! route_id {
macro_rules! paged_routes_with_id {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! {
doc_comment::doc_comment! {
concat!(
"Equivalent to `", stringify!($method), " /api/v1/",
$url,
+1
View File
@@ -1,4 +1,5 @@
use std::borrow::Cow;
use serde::Serialize;
/// A builder pattern struct for constructing a media attachment.
#[derive(Debug, Default, Clone, Serialize)]
+1 -1
View File
@@ -11,7 +11,7 @@ macro_rules! pages {
($($direction:ident: $fun:ident),*) => {
$(
doc_comment!(concat!(
doc_comment::doc_comment!(concat!(
"Method to retrieve the ", stringify!($direction), " page of results"),
pub fn $fun(&mut self) -> Result<Option<Vec<T>>> {
let url = match self.$direction.take() {
+1
View File
@@ -1,6 +1,7 @@
use std::borrow::Cow;
use reqwest::{Client, RequestBuilder, Response};
use serde::Deserialize;
use try_from::TryInto;
use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};
+1
View File
@@ -1,5 +1,6 @@
use crate::entities::filter::FilterContext;
use std::time::Duration;
use serde::Serialize;
/// Form used to create a filter
///
+1
View File
@@ -1,5 +1,6 @@
use crate::entities::push::{add_subscription, update_data};
use crate::errors::Result;
use serde::Serialize;
/// Container for the key & auth strings for an AddPushRequest
///
+1
View File
@@ -1,6 +1,7 @@
use crate::errors::Error;
use serde_qs;
use std::{borrow::Cow, convert::Into};
use serde::Serialize;
mod bool_qs_serialize {
use serde::Serializer;
+2 -4
View File
@@ -6,10 +6,8 @@ use std::{
str::FromStr,
};
use serde::ser::{Serialize, Serializer};
use crate::errors::Error;
use serde::{Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, Serialize};
use serde::de::{self, Visitor};
/// Represents a set of OAuth scopes
@@ -47,7 +45,7 @@ impl FromStr for Scopes {
impl Serialize for Scopes {
fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error>
where
S: Serializer,
S: serde::ser::Serializer,
{
let repr = format!("{}", self);
serializer.serialize_str(&repr)
+1
View File
@@ -1,4 +1,5 @@
use isolang::Language;
use serde::{Deserialize, Serialize};
/// A builder pattern struct for constructing a status.
///