Various cleanup tasks

* Remove old `extern crate` stmts
* Remove rust-skeptic
* Clean up Cargo.toml
master
Paul Woolcock 4 years ago
parent c30b4da57c
commit 0b4ee7bfb2
  1. 15
      Cargo.toml
  2. 20
      build.rs
  3. 3
      examples/follow_profile.rs
  4. 3
      examples/follows_me.rs
  5. 3
      examples/home_timeline.rs
  6. 3
      examples/print_your_profile.rs
  7. 3
      examples/search.rs
  8. 3
      examples/upload_photo.rs
  9. 1
      src/apps.rs
  10. 1
      src/data.rs
  11. 5
      src/entities/account.rs
  12. 1
      src/entities/attachment.rs
  13. 1
      src/entities/card.rs
  14. 1
      src/entities/context.rs
  15. 2
      src/entities/filter.rs
  16. 1
      src/entities/instance.rs
  17. 1
      src/entities/list.rs
  18. 2
      src/entities/mod.rs
  19. 1
      src/entities/notification.rs
  20. 4
      src/entities/push.rs
  21. 1
      src/entities/relationship.rs
  22. 1
      src/entities/report.rs
  23. 1
      src/entities/search_result.rs
  24. 1
      src/entities/status.rs
  25. 8
      src/errors.rs
  26. 2
      src/helpers/json.rs
  27. 12
      src/helpers/toml.rs
  28. 40
      src/lib.rs
  29. 21
      src/macros.rs
  30. 1
      src/media_builder.rs
  31. 2
      src/page.rs
  32. 1
      src/registration.rs
  33. 1
      src/requests/filter.rs
  34. 1
      src/requests/push.rs
  35. 1
      src/requests/statuses.rs
  36. 6
      src/scopes.rs
  37. 1
      src/status_builder.rs
  38. 1
      tests/skeptic.rs

@ -10,22 +10,22 @@ 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 }
hyper-old-types = "0.11.0"
isolang = { version = "1.0", features = ["serde_serialize"] } isolang = { version = "1.0", features = ["serde_serialize"] }
log = "0.4.6"
reqwest = { version = "0.9", default-features = false } reqwest = { version = "0.9", default-features = false }
serde = "1" serde = { version = "1", features = ["derive"] }
serde_derive = "1"
serde_json = "1" serde_json = "1"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
serde_qs = "0.6.0" serde_qs = "0.6.0"
url = "1" url = "1"
tap-reader = "1" tap-reader = "1"
try_from = "0.3.2"
toml = { version = "0.5.0", optional = true } toml = { version = "0.5.0", optional = true }
hyper-old-types = "0.11.0" try_from = "0.3.2"
envy = { version = "0.4.0", optional = true }
log = "0.4.6"
tungstenite = "0.10.1" tungstenite = "0.10.1"
[dependencies.chrono] [dependencies.chrono]
@ -39,9 +39,6 @@ env = ["envy"]
all = ["toml", "json", "env"] all = ["toml", "json", "env"]
rustls-tls = ["reqwest/rustls-tls"] rustls-tls = ["reqwest/rustls-tls"]
[build-dependencies]
skeptic = "0.13.3"
[dev-dependencies] [dev-dependencies]
skeptic = "0.13.3" skeptic = "0.13.3"
tempfile = "3.0.3" tempfile = "3.0.3"

@ -1,20 +0,0 @@
#[cfg(feature = "toml")]
extern crate skeptic;
#[cfg(feature = "toml")]
fn main() {
skeptic::generate_doc_tests(&["README.md"]);
}
#[cfg(not(feature = "toml"))]
fn main() {
// tests/skeptic.rs still expects a file to be at OUT_DIR/skeptic-tests.rs, so
// make a dummy one
use std::{env, fs::OpenOptions, path::Path};
let out_dir = Path::new(&env::var("OUT_DIR").expect("no out_dir set")).join("skeptic-tests.rs");
OpenOptions::new()
.create(true)
.write(true)
.open(out_dir)
.expect("couldn't write to file");
}

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,8 +1,5 @@
#![cfg_attr(not(feature = "toml"), allow(dead_code))] #![cfg_attr(not(feature = "toml"), allow(dead_code))]
#![cfg_attr(not(feature = "toml"), allow(unused_imports))] #![cfg_attr(not(feature = "toml"), allow(unused_imports))]
#[macro_use]
extern crate pretty_env_logger;
extern crate elefren;
mod register; mod register;
use crate::register::MastodonClient; use crate::register::MastodonClient;

@ -1,5 +1,6 @@
use std::borrow::Cow; use std::borrow::Cow;
use serde::Serialize;
use try_from::TryInto; use try_from::TryInto;
use crate::errors::{Error, Result}; use crate::errors::{Error, Result};

@ -1,4 +1,5 @@
use std::borrow::Cow; use std::borrow::Cow;
use serde::{Serialize, Deserialize};
/// Raw data about mastodon app. Save `Data` using `serde` to prevent needing /// Raw data about mastodon app. Save `Data` using `serde` to prevent needing
/// to authenticate on every run. /// to authenticate on every run.

@ -1,7 +1,8 @@
//! A module containing everything relating to a account returned from the api. //! A module containing everything relating to a account returned from the api.
use chrono::prelude::*; use chrono::prelude::*;
use serde::de::{self, Deserialize, Deserializer, Unexpected}; use serde::{Deserialize, Serialize};
use serde::de::{self, Unexpected};
use crate::status_builder; use crate::status_builder;
use std::path::PathBuf; use std::path::PathBuf;
@ -79,7 +80,7 @@ pub struct Source {
fields: Option<Vec<MetadataField>>, 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)] #[derive(Clone, Debug, Deserialize, PartialEq)]
#[serde(untagged)] #[serde(untagged)]
pub enum BoolOrString { pub enum BoolOrString {

@ -1,4 +1,5 @@
//! Module containing everything related to media attachements. //! Module containing everything related to media attachements.
use serde::Deserialize;
/// A struct representing a media attachment. /// A struct representing a media attachment.
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]

@ -1,4 +1,5 @@
//! Module representing cards of statuses. //! Module representing cards of statuses.
use serde::Deserialize;
/// A card of a status. /// A card of a status.
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]

@ -1,4 +1,5 @@
//! A module about contexts of statuses. //! A module about contexts of statuses.
use serde::Deserialize;
use super::status::Status; use super::status::Status;

@ -1,3 +1,5 @@
use serde::{Serialize, Deserialize};
/// Represents a single Filter /// Represents a single Filter
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Filter { pub struct Filter {

@ -1,4 +1,5 @@
//! Module containing everything related to an instance. //! Module containing everything related to an instance.
use serde::Deserialize;
use super::account::Account; use super::account::Account;
/// A struct containing info of an instance. /// A struct containing info of an instance.

@ -1,3 +1,4 @@
use serde::Deserialize;
/// Used for ser/de of list resources /// Used for ser/de of list resources
#[derive(Clone, Debug, Deserialize, PartialEq)] #[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct List { pub struct List {

@ -1,3 +1,5 @@
use serde::Deserialize;
/// Data structures for ser/de of account-related resources /// Data structures for ser/de of account-related resources
pub mod account; pub mod account;
/// Data structures for ser/de of attachment-related resources /// Data structures for ser/de of attachment-related resources

@ -1,5 +1,6 @@
//! Module containing all info about notifications. //! Module containing all info about notifications.
use serde::Deserialize;
use super::{account::Account, status::Status}; use super::{account::Account, status::Status};
use chrono::prelude::*; use chrono::prelude::*;

@ -1,3 +1,5 @@
use serde::{Deserialize, Serialize};
/// Represents the `alerts` key of the `Subscription` object /// Represents the `alerts` key of the `Subscription` object
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Default)] #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Default)]
pub struct Alerts { pub struct Alerts {
@ -25,6 +27,7 @@ pub struct Subscription {
} }
pub(crate) mod add_subscription { pub(crate) mod add_subscription {
use serde::Serialize;
use super::Alerts; use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)] #[derive(Debug, Clone, PartialEq, Serialize, Default)]
@ -52,6 +55,7 @@ pub(crate) mod add_subscription {
} }
pub(crate) mod update_data { pub(crate) mod update_data {
use serde::Serialize;
use super::Alerts; use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)] #[derive(Debug, Clone, PartialEq, Serialize, Default)]

@ -1,5 +1,6 @@
//! module containing everything relating to a relationship with //! module containing everything relating to a relationship with
//! another account. //! another account.
use serde::Deserialize;
/// A struct containing information about a relationship with another account. /// A struct containing information about a relationship with another account.
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]

@ -1,4 +1,5 @@
//! module containing information about a finished report of a user. //! module containing information about a finished report of a user.
use serde::Deserialize;
/// A struct containing info about a report. /// A struct containing info about a report.
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]

@ -1,4 +1,5 @@
//! A module containing info relating to a search result. //! A module containing info relating to a search result.
use serde::Deserialize;
use super::{ use super::{
prelude::{Account, Status}, prelude::{Account, Status},

@ -4,6 +4,7 @@ use super::prelude::*;
use chrono::prelude::*; use chrono::prelude::*;
use crate::entities::card::Card; use crate::entities::card::Card;
use crate::status_builder::Visibility; use crate::status_builder::Visibility;
use serde::Deserialize;
/// A status from the instance. /// A status from the instance.
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]

@ -1,4 +1,5 @@
use std::{error, fmt, io::Error as IoError}; use std::{error, fmt, io::Error as IoError};
use serde::Deserialize;
#[cfg(feature = "env")] #[cfg(feature = "env")]
use envy::Error as EnvyError; use envy::Error as EnvyError;
@ -8,9 +9,9 @@ use serde_json::Error as SerdeError;
use serde_qs::Error as SerdeQsError; use serde_qs::Error as SerdeQsError;
use serde_urlencoded::ser::Error as UrlEncodedError; use serde_urlencoded::ser::Error as UrlEncodedError;
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
use crate::tomlcrate::de::Error as TomlDeError; use ::toml::de::Error as TomlDeError;
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
use crate::tomlcrate::ser::Error as TomlSerError; use ::toml::ser::Error as TomlSerError;
use url::ParseError as UrlError; use url::ParseError as UrlError;
use tungstenite::error::Error as WebSocketError; use tungstenite::error::Error as WebSocketError;
@ -237,8 +238,7 @@ mod tests {
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[test] #[test]
fn from_toml_de_error() { fn from_toml_de_error() {
use crate::tomlcrate; let err: TomlDeError = ::toml::from_str::<()>("not valid toml").unwrap_err();
let err: TomlDeError = tomlcrate::from_str::<()>("not valid toml").unwrap_err();
let err: Error = Error::from(err); let err: Error = Error::from(err);
assert_is!(err, Error::TomlDe(..)); assert_is!(err, Error::TomlDe(..));
} }

@ -83,7 +83,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor}; use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile}; use tempfile::{tempdir, NamedTempFile};
const DOC: &'static str = indoc!( const DOC: &'static str = indoc::indoc!(
r#" r#"
{ {
"base": "https://example.com", "base": "https://example.com",

@ -4,19 +4,17 @@ use std::{
path::Path, path::Path,
}; };
use crate::tomlcrate;
use crate::data::Data; use crate::data::Data;
use crate::Result; use crate::Result;
/// Attempts to deserialize a Data struct from a string /// Attempts to deserialize a Data struct from a string
pub fn from_str(s: &str) -> Result<Data> { 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 /// Attempts to deserialize a Data struct from a slice of bytes
pub fn from_slice(s: &[u8]) -> Result<Data> { 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 /// 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 /// Attempts to serialize a Data struct to a String
pub fn to_string(data: &Data) -> Result<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 /// Attempts to serialize a Data struct to a Vec of bytes
pub fn to_vec(data: &Data) -> Result<Vec<u8>> { 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 /// Attempts to serialize a Data struct to something that implements the
@ -83,7 +81,7 @@ mod tests {
use std::{fs::OpenOptions, io::Cursor}; use std::{fs::OpenOptions, io::Cursor};
use tempfile::{tempdir, NamedTempFile}; use tempfile::{tempdir, NamedTempFile};
const DOC: &'static str = indoc!( const DOC: &'static str = indoc::indoc!(
r#" r#"
base = "https://example.com" base = "https://example.com"
client_id = "adbc01234" client_id = "adbc01234"

@ -69,40 +69,7 @@
unused_import_braces, unused_import_braces,
unused_qualifications unused_qualifications
)] )]
#![allow(intra_doc_link_resolution_failure)] #![allow(broken_intra_doc_links)]
#[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;
use std::{ use std::{
borrow::Cow, borrow::Cow,
@ -724,6 +691,7 @@ impl<R: EventStream> EventReader<R> {
event = event_line[6..].trim().to_string(); event = event_line[6..].trim().to_string();
data = lines.iter().find(|line| line.starts_with("data:")).map(|x| x[5..].trim().to_string()); data = lines.iter().find(|line| line.starts_with("data:")).map(|x| x[5..].trim().to_string());
} else { } else {
use serde::Deserialize;
#[derive(Deserialize)] #[derive(Deserialize)]
struct Message { struct Message {
pub event: String, 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) { match serde_json::from_reader(&mut reader) {
Ok(t) => { Ok(t) => {
debug!("{}", String::from_utf8_lossy(&reader.bytes)); log::debug!("{}", String::from_utf8_lossy(&reader.bytes));
Ok(t) Ok(t)
}, },
// If deserializing into the desired type fails try again to // If deserializing into the desired type fails try again to
// see if this is an error response. // see if this is an error response.
Err(e) => { 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) { if let Ok(error) = serde_json::from_slice(&reader.bytes) {
return Err(Error::Api(error)); return Err(Error::Api(error));
} }

@ -17,7 +17,7 @@ macro_rules! methods {
macro_rules! paged_routes { macro_rules! paged_routes {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { (($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `", stringify!($method), " /api/v1/", "Equivalent to `", stringify!($method), " /api/v1/",
$url, $url,
@ -55,7 +55,7 @@ macro_rules! paged_routes {
}; };
((get ($($(#[$m:meta])* $param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { ((get ($($(#[$m:meta])* $param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `get /api/v1/", "Equivalent to `get /api/v1/",
$url, $url,
@ -63,6 +63,7 @@ macro_rules! paged_routes {
), ),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<Page<$ret, H>> { fn $name<'a>(&self, $($param: $typ,)*) -> Result<Page<$ret, H>> {
use serde_urlencoded; use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)] #[derive(Serialize)]
struct Data<'a> { struct Data<'a> {
@ -103,7 +104,7 @@ macro_rules! paged_routes {
macro_rules! route_v2 { macro_rules! route_v2 {
((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { ((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `get /api/v2/", "Equivalent to `get /api/v2/",
$url, $url,
@ -111,6 +112,7 @@ macro_rules! route_v2 {
), ),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> { fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> {
use serde_urlencoded; use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)] #[derive(Serialize)]
struct Data<'a> { struct Data<'a> {
@ -145,7 +147,7 @@ macro_rules! route_v2 {
macro_rules! route { macro_rules! route {
((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { ((get ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `get /api/v1/", "Equivalent to `get /api/v1/",
$url, $url,
@ -153,6 +155,7 @@ macro_rules! route {
), ),
fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> { fn $name<'a>(&self, $($param: $typ,)*) -> Result<$ret> {
use serde_urlencoded; use serde_urlencoded;
use serde::Serialize;
#[derive(Serialize)] #[derive(Serialize)]
struct Data<'a> { struct Data<'a> {
@ -182,7 +185,7 @@ macro_rules! route {
}; };
(($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { (($method:ident ($($param:ident: $typ:ty,)*)) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `", stringify!($method), " /api/v1/", "Equivalent to `", stringify!($method), " /api/v1/",
$url, $url,
@ -190,7 +193,7 @@ macro_rules! route {
), ),
fn $name(&self, $($param: $typ,)*) -> Result<$ret> { fn $name(&self, $($param: $typ,)*) -> Result<$ret> {
let form_data = json!({ let form_data = serde_json::json!({
$( $(
stringify!($param): $param, stringify!($param): $param,
)* )*
@ -217,7 +220,7 @@ macro_rules! route {
}; };
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { (($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `", stringify!($method), " /api/v1/", "Equivalent to `", stringify!($method), " /api/v1/",
$url, $url,
@ -255,7 +258,7 @@ macro_rules! route_id {
($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => { ($(($method:ident) $name:ident: $url:expr => $ret:ty,)*) => {
$( $(
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `", stringify!($method), " /api/v1/", "Equivalent to `", stringify!($method), " /api/v1/",
$url, $url,
@ -289,7 +292,7 @@ macro_rules! route_id {
macro_rules! paged_routes_with_id { macro_rules! paged_routes_with_id {
(($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => { (($method:ident) $name:ident: $url:expr => $ret:ty, $($rest:tt)*) => {
doc_comment! { doc_comment::doc_comment! {
concat!( concat!(
"Equivalent to `", stringify!($method), " /api/v1/", "Equivalent to `", stringify!($method), " /api/v1/",
$url, $url,

@ -1,4 +1,5 @@
use std::borrow::Cow; use std::borrow::Cow;
use serde::Serialize;
/// A builder pattern struct for constructing a media attachment. /// A builder pattern struct for constructing a media attachment.
#[derive(Debug, Default, Clone, Serialize)] #[derive(Debug, Default, Clone, Serialize)]

@ -11,7 +11,7 @@ macro_rules! pages {
($($direction:ident: $fun:ident),*) => { ($($direction:ident: $fun:ident),*) => {
$( $(
doc_comment!(concat!( doc_comment::doc_comment!(concat!(
"Method to retrieve the ", stringify!($direction), " page of results"), "Method to retrieve the ", stringify!($direction), " page of results"),
pub fn $fun(&mut self) -> Result<Option<Vec<T>>> { pub fn $fun(&mut self) -> Result<Option<Vec<T>>> {
let url = match self.$direction.take() { let url = match self.$direction.take() {

@ -1,6 +1,7 @@
use std::borrow::Cow; use std::borrow::Cow;
use reqwest::{Client, RequestBuilder, Response}; use reqwest::{Client, RequestBuilder, Response};
use serde::Deserialize;
use try_from::TryInto; use try_from::TryInto;
use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; use url::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};

@ -1,5 +1,6 @@
use crate::entities::filter::FilterContext; use crate::entities::filter::FilterContext;
use std::time::Duration; use std::time::Duration;
use serde::Serialize;
/// Form used to create a filter /// Form used to create a filter
/// ///

@ -1,5 +1,6 @@
use crate::entities::push::{add_subscription, update_data}; use crate::entities::push::{add_subscription, update_data};
use crate::errors::Result; use crate::errors::Result;
use serde::Serialize;
/// Container for the key & auth strings for an AddPushRequest /// Container for the key & auth strings for an AddPushRequest
/// ///

@ -1,6 +1,7 @@
use crate::errors::Error; use crate::errors::Error;
use serde_qs; use serde_qs;
use std::{borrow::Cow, convert::Into}; use std::{borrow::Cow, convert::Into};
use serde::Serialize;
mod bool_qs_serialize { mod bool_qs_serialize {
use serde::Serializer; use serde::Serializer;

@ -6,10 +6,8 @@ use std::{
str::FromStr, str::FromStr,
}; };
use serde::ser::{Serialize, Serializer};
use crate::errors::Error; use crate::errors::Error;
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer, Serialize};
use serde::de::{self, Visitor}; use serde::de::{self, Visitor};
/// Represents a set of OAuth scopes /// Represents a set of OAuth scopes
@ -47,7 +45,7 @@ impl FromStr for Scopes {
impl Serialize for Scopes { impl Serialize for Scopes {
fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> ::std::result::Result<S::Ok, S::Error>
where where
S: Serializer, S: serde::ser::Serializer,
{ {
let repr = format!("{}", self); let repr = format!("{}", self);
serializer.serialize_str(&repr) serializer.serialize_str(&repr)

@ -1,4 +1,5 @@
use isolang::Language; use isolang::Language;
use serde::{Deserialize, Serialize};
/// A builder pattern struct for constructing a status. /// A builder pattern struct for constructing a status.
/// ///

@ -1 +0,0 @@
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));
Loading…
Cancel
Save