Cargo-fmt pass
This commit is contained in:
+4
-2
@@ -3,8 +3,10 @@ use std::borrow::Cow;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use try_from::TryInto;
|
use try_from::TryInto;
|
||||||
|
|
||||||
use crate::errors::{Error, Result};
|
use crate::{
|
||||||
use crate::scopes::Scopes;
|
errors::{Error, Result},
|
||||||
|
scopes::Scopes,
|
||||||
|
};
|
||||||
|
|
||||||
/// Represents an application that can be registered with a mastodon instance
|
/// Represents an application that can be registered with a mastodon instance
|
||||||
#[derive(Clone, Debug, Default, Serialize, PartialEq)]
|
#[derive(Clone, Debug, Default, Serialize, PartialEq)]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
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,9 +1,12 @@
|
|||||||
//! 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 serde::{Deserialize, Serialize};
|
|
||||||
use serde::de::{self, Unexpected};
|
|
||||||
use crate::status_builder;
|
use crate::status_builder;
|
||||||
|
use chrono::prelude::*;
|
||||||
|
use serde::{
|
||||||
|
de::{self, Unexpected},
|
||||||
|
Deserialize,
|
||||||
|
Serialize,
|
||||||
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// A struct representing an Account.
|
/// A struct representing an Account.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents a single Filter
|
/// Represents a single Filter
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! 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;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
/// A struct containing info of an instance.
|
/// A struct containing info of an instance.
|
||||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use crate::http_send::HttpSend;
|
use crate::{http_send::HttpSend, page::Page};
|
||||||
use crate::page::Page;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
/// Abstracts away the `next_page` logic into a single stream of items
|
/// Abstracts away the `next_page` logic into a single stream of items
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! 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::*;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
/// A struct containing info about a notification.
|
/// A struct containing info about a notification.
|
||||||
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, PartialEq)]
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ pub struct Subscription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod add_subscription {
|
pub(crate) mod add_subscription {
|
||||||
use serde::Serialize;
|
|
||||||
use super::Alerts;
|
use super::Alerts;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||||
pub(crate) struct Form {
|
pub(crate) struct Form {
|
||||||
@@ -55,8 +55,8 @@ pub(crate) mod add_subscription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod update_data {
|
pub(crate) mod update_data {
|
||||||
use serde::Serialize;
|
|
||||||
use super::Alerts;
|
use super::Alerts;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
||||||
pub(crate) struct Data {
|
pub(crate) struct Data {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
//! Module containing all info relating to a status.
|
//! Module containing all info relating to a status.
|
||||||
|
|
||||||
use super::prelude::*;
|
use super::prelude::*;
|
||||||
|
use crate::{entities::card::Card, status_builder::Visibility};
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use crate::entities::card::Card;
|
|
||||||
use crate::status_builder::Visibility;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
/// A status from the instance.
|
/// A status from the instance.
|
||||||
|
|||||||
+7
-9
@@ -1,6 +1,10 @@
|
|||||||
use std::{error, fmt, io::Error as IoError};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use std::{error, fmt, io::Error as IoError};
|
||||||
|
|
||||||
|
#[cfg(feature = "toml")]
|
||||||
|
use ::toml::de::Error as TomlDeError;
|
||||||
|
#[cfg(feature = "toml")]
|
||||||
|
use ::toml::ser::Error as TomlSerError;
|
||||||
#[cfg(feature = "env")]
|
#[cfg(feature = "env")]
|
||||||
use envy::Error as EnvyError;
|
use envy::Error as EnvyError;
|
||||||
use hyper_old_types::Error as HeaderParseError;
|
use hyper_old_types::Error as HeaderParseError;
|
||||||
@@ -8,12 +12,8 @@ use reqwest::{header::ToStrError as HeaderStrError, Error as HttpError, StatusCo
|
|||||||
use serde_json::Error as SerdeError;
|
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")]
|
|
||||||
use ::toml::de::Error as TomlDeError;
|
|
||||||
#[cfg(feature = "toml")]
|
|
||||||
use ::toml::ser::Error as TomlSerError;
|
|
||||||
use url::ParseError as UrlError;
|
|
||||||
use tungstenite::error::Error as WebSocketError;
|
use tungstenite::error::Error as WebSocketError;
|
||||||
|
use url::ParseError as UrlError;
|
||||||
|
|
||||||
/// Convience type over `std::result::Result` with `Error` as the error type.
|
/// Convience type over `std::result::Result` with `Error` as the error type.
|
||||||
pub type Result<T> = ::std::result::Result<T, Error>;
|
pub type Result<T> = ::std::result::Result<T, Error>;
|
||||||
@@ -94,9 +94,7 @@ impl error::Error for Error {
|
|||||||
Error::SerdeQs(ref e) => e,
|
Error::SerdeQs(ref e) => e,
|
||||||
Error::WebSocket(ref e) => e,
|
Error::WebSocket(ref e) => e,
|
||||||
|
|
||||||
Error::Client(..) | Error::Server(..) => {
|
Error::Client(..) | Error::Server(..) => return None,
|
||||||
return None
|
|
||||||
},
|
|
||||||
Error::ClientIdRequired => return None,
|
Error::ClientIdRequired => return None,
|
||||||
Error::ClientSecretRequired => return None,
|
Error::ClientSecretRequired => return None,
|
||||||
Error::AccessTokenRequired => return None,
|
Error::AccessTokenRequired => return None,
|
||||||
|
|||||||
+1
-4
@@ -1,9 +1,6 @@
|
|||||||
use std::io::{self, BufRead, Write};
|
use std::io::{self, BufRead, Write};
|
||||||
|
|
||||||
use crate::errors::Result;
|
use crate::{errors::Result, http_send::HttpSend, registration::Registered, Mastodon};
|
||||||
use crate::http_send::HttpSend;
|
|
||||||
use crate::registration::Registered;
|
|
||||||
use crate::Mastodon;
|
|
||||||
|
|
||||||
/// Finishes the authentication process for the given `Registered` object,
|
/// Finishes the authentication process for the given `Registered` object,
|
||||||
/// using the command-line
|
/// using the command-line
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
use envy;
|
use envy;
|
||||||
|
|
||||||
use crate::data::Data;
|
use crate::{data::Data, Result};
|
||||||
use crate::Result;
|
|
||||||
|
|
||||||
/// Attempts to deserialize a Data struct from the environment
|
/// Attempts to deserialize a Data struct from the environment
|
||||||
pub fn from_env() -> Result<Data> {
|
pub fn from_env() -> Result<Data> {
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@ use std::{
|
|||||||
|
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use crate::data::Data;
|
use crate::{data::Data, 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> {
|
||||||
|
|||||||
+1
-2
@@ -4,8 +4,7 @@ use std::{
|
|||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::data::Data;
|
use crate::{data::Data, 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> {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::Result;
|
||||||
use reqwest::{Client, Request, RequestBuilder, Response};
|
use reqwest::{Client, Request, RequestBuilder, Response};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use crate::Result;
|
|
||||||
|
|
||||||
/// Abstracts away the process of turning an HTTP request into an HTTP response
|
/// Abstracts away the process of turning an HTTP request into an HTTP response
|
||||||
pub trait HttpSend: Clone + Debug {
|
pub trait HttpSend: Clone + Debug {
|
||||||
|
|||||||
+49
-38
@@ -71,34 +71,34 @@
|
|||||||
)]
|
)]
|
||||||
#![allow(broken_intra_doc_links)]
|
#![allow(broken_intra_doc_links)]
|
||||||
|
|
||||||
use std::{
|
use std::{borrow::Cow, io::BufRead, ops};
|
||||||
borrow::Cow,
|
|
||||||
io::BufRead,
|
|
||||||
ops,
|
|
||||||
};
|
|
||||||
|
|
||||||
use reqwest::{Client, RequestBuilder, Response};
|
use reqwest::{Client, RequestBuilder, Response};
|
||||||
use tap_reader::Tap;
|
use tap_reader::Tap;
|
||||||
use tungstenite::client::AutoStream;
|
use tungstenite::client::AutoStream;
|
||||||
|
|
||||||
use crate::entities::prelude::*;
|
use crate::{
|
||||||
use crate::http_send::{HttpSend, HttpSender};
|
entities::prelude::*,
|
||||||
use crate::page::Page;
|
http_send::{HttpSend, HttpSender},
|
||||||
|
page::Page,
|
||||||
|
};
|
||||||
|
|
||||||
pub use crate::data::Data;
|
pub use crate::{
|
||||||
pub use crate::errors::{ApiError, Error, Result};
|
data::Data,
|
||||||
pub use isolang::Language;
|
errors::{ApiError, Error, Result},
|
||||||
pub use crate::mastodon_client::{MastodonClient, MastodonUnauthenticated};
|
mastodon_client::{MastodonClient, MastodonUnauthenticated},
|
||||||
pub use crate::media_builder::MediaBuilder;
|
media_builder::MediaBuilder,
|
||||||
pub use crate::registration::Registration;
|
registration::Registration,
|
||||||
pub use crate::requests::{
|
requests::{
|
||||||
AddFilterRequest,
|
AddFilterRequest,
|
||||||
AddPushRequest,
|
AddPushRequest,
|
||||||
StatusesRequest,
|
StatusesRequest,
|
||||||
UpdateCredsRequest,
|
UpdateCredsRequest,
|
||||||
UpdatePushRequest,
|
UpdatePushRequest,
|
||||||
|
},
|
||||||
|
status_builder::{NewStatus, StatusBuilder},
|
||||||
};
|
};
|
||||||
pub use crate::status_builder::{NewStatus, StatusBuilder};
|
pub use isolang::Language;
|
||||||
|
|
||||||
/// Registering your App
|
/// Registering your App
|
||||||
pub mod apps;
|
pub mod apps;
|
||||||
@@ -129,14 +129,16 @@ pub mod status_builder;
|
|||||||
mod macros;
|
mod macros;
|
||||||
/// Automatically import the things you need
|
/// Automatically import the things you need
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::scopes::Scopes;
|
pub use crate::{
|
||||||
pub use crate::Data;
|
scopes::Scopes,
|
||||||
pub use crate::Mastodon;
|
Data,
|
||||||
pub use crate::MastodonClient;
|
Mastodon,
|
||||||
pub use crate::NewStatus;
|
MastodonClient,
|
||||||
pub use crate::Registration;
|
NewStatus,
|
||||||
pub use crate::StatusBuilder;
|
Registration,
|
||||||
pub use crate::StatusesRequest;
|
StatusBuilder,
|
||||||
|
StatusesRequest,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Your mastodon application client, handles all requests to and from Mastodon.
|
/// Your mastodon application client, handles all requests to and from Mastodon.
|
||||||
@@ -473,7 +475,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -492,7 +495,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -511,7 +515,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -531,7 +536,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -551,7 +557,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -571,7 +578,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -590,7 +598,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
@@ -631,7 +640,8 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// WebSocket newtype so that EventStream can be implemented without coherency issues
|
/// WebSocket newtype so that EventStream can be implemented without coherency
|
||||||
|
/// issues
|
||||||
pub struct WebSocket(tungstenite::protocol::WebSocket<AutoStream>);
|
pub struct WebSocket(tungstenite::protocol::WebSocket<AutoStream>);
|
||||||
|
|
||||||
/// A type that streaming events can be read from
|
/// A type that streaming events can be read from
|
||||||
@@ -684,12 +694,12 @@ impl<R: EventStream> EventReader<R> {
|
|||||||
fn make_event(&self, lines: &[String]) -> Result<Event> {
|
fn make_event(&self, lines: &[String]) -> Result<Event> {
|
||||||
let event;
|
let event;
|
||||||
let data;
|
let data;
|
||||||
if let Some(event_line) = lines
|
if let Some(event_line) = lines.iter().find(|line| line.starts_with("event:")) {
|
||||||
.iter()
|
|
||||||
.find(|line| line.starts_with("event:"))
|
|
||||||
{
|
|
||||||
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;
|
use serde::Deserialize;
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -816,7 +826,8 @@ impl<H: HttpSend> MastodonUnauth<H> {
|
|||||||
"https" => "wss",
|
"https" => "wss",
|
||||||
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
x => return Err(Error::Other(format!("Bad URL scheme: {}", x))),
|
||||||
};
|
};
|
||||||
url.set_scheme(new_scheme).map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
url.set_scheme(new_scheme)
|
||||||
|
.map_err(|_| Error::Other("Bad URL scheme!".to_string()))?;
|
||||||
|
|
||||||
let client = tungstenite::connect(url.as_str())?.0;
|
let client = tungstenite::connect(url.as_str())?.0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::entities::prelude::*;
|
use crate::{
|
||||||
use crate::errors::Result;
|
entities::prelude::*,
|
||||||
use crate::http_send::{HttpSend, HttpSender};
|
errors::Result,
|
||||||
use crate::media_builder::MediaBuilder;
|
http_send::{HttpSend, HttpSender},
|
||||||
use crate::page::Page;
|
media_builder::MediaBuilder,
|
||||||
use crate::requests::{
|
page::Page,
|
||||||
|
requests::{
|
||||||
AddFilterRequest,
|
AddFilterRequest,
|
||||||
AddPushRequest,
|
AddPushRequest,
|
||||||
StatusesRequest,
|
StatusesRequest,
|
||||||
UpdateCredsRequest,
|
UpdateCredsRequest,
|
||||||
UpdatePushRequest,
|
UpdatePushRequest,
|
||||||
|
},
|
||||||
|
status_builder::NewStatus,
|
||||||
};
|
};
|
||||||
use crate::status_builder::NewStatus;
|
|
||||||
|
|
||||||
/// Represents the set of methods that a Mastodon Client can do, so that
|
/// Represents the set of methods that a Mastodon Client can do, so that
|
||||||
/// implementations might be swapped out for testing
|
/// implementations might be swapped out for testing
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::borrow::Cow;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// 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)]
|
||||||
@@ -21,6 +21,7 @@ impl MediaBuilder {
|
|||||||
focus: None,
|
focus: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set an alt text description for the attachment.
|
/// Set an alt text description for the attachment.
|
||||||
pub fn description(mut self, description: Cow<'static, str>) -> Self {
|
pub fn description(mut self, description: Cow<'static, str>) -> Self {
|
||||||
self.description = Some(description);
|
self.description = Some(description);
|
||||||
|
|||||||
+10
-8
@@ -5,14 +5,16 @@ 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};
|
||||||
|
|
||||||
use crate::apps::{App, AppBuilder};
|
use crate::{
|
||||||
use crate::http_send::{HttpSend, HttpSender};
|
apps::{App, AppBuilder},
|
||||||
use crate::scopes::Scopes;
|
http_send::{HttpSend, HttpSender},
|
||||||
use crate::Data;
|
scopes::Scopes,
|
||||||
use crate::Error;
|
Data,
|
||||||
use crate::Mastodon;
|
Error,
|
||||||
use crate::MastodonBuilder;
|
Mastodon,
|
||||||
use crate::Result;
|
MastodonBuilder,
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
|
||||||
const DEFAULT_REDIRECT_URI: &'static str = "urn:ietf:wg:oauth:2.0:oob";
|
const DEFAULT_REDIRECT_URI: &'static str = "urn:ietf:wg:oauth:2.0:oob";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::entities::filter::FilterContext;
|
use crate::entities::filter::FilterContext;
|
||||||
use std::time::Duration;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
/// Form used to create a filter
|
/// Form used to create a filter
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use crate::entities::push::{add_subscription, update_data};
|
use crate::{
|
||||||
use crate::errors::Result;
|
entities::push::{add_subscription, update_data},
|
||||||
|
errors::Result,
|
||||||
|
};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Container for the key & auth strings for an AddPushRequest
|
/// Container for the key & auth strings for an AddPushRequest
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::errors::Error;
|
use crate::errors::Error;
|
||||||
|
use serde::Serialize;
|
||||||
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;
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::entities::account::{Credentials, MetadataField, UpdateSource};
|
use crate::{
|
||||||
use crate::errors::Result;
|
entities::account::{Credentials, MetadataField, UpdateSource},
|
||||||
use crate::status_builder;
|
errors::Result,
|
||||||
|
status_builder,
|
||||||
|
};
|
||||||
|
|
||||||
/// Builder to pass to the Mastodon::update_credentials method
|
/// Builder to pass to the Mastodon::update_credentials method
|
||||||
///
|
///
|
||||||
@@ -202,8 +204,10 @@ impl UpdateCredsRequest {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::entities::account::{Credentials, MetadataField, UpdateSource};
|
use crate::{
|
||||||
use crate::status_builder::Visibility;
|
entities::account::{Credentials, MetadataField, UpdateSource},
|
||||||
|
status_builder::Visibility,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_update_creds_request_new() {
|
fn test_update_creds_request_new() {
|
||||||
|
|||||||
+12
-5
@@ -7,8 +7,12 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::errors::Error;
|
use crate::errors::Error;
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{
|
||||||
use serde::de::{self, Visitor};
|
de::{self, Visitor},
|
||||||
|
Deserialize,
|
||||||
|
Deserializer,
|
||||||
|
Serialize,
|
||||||
|
};
|
||||||
|
|
||||||
/// Represents a set of OAuth scopes
|
/// Represents a set of OAuth scopes
|
||||||
///
|
///
|
||||||
@@ -62,15 +66,18 @@ impl<'de> Visitor<'de> for DeserializeScopesVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
where E: de::Error
|
where
|
||||||
|
E: de::Error,
|
||||||
{
|
{
|
||||||
Scopes::from_str(v).map_err(de::Error::custom)
|
Scopes::from_str(v).map_err(de::Error::custom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Scopes {
|
impl<'de> Deserialize<'de> for Scopes {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error> where
|
fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
|
||||||
D: Deserializer<'de> {
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
deserializer.deserialize_str(DeserializeScopesVisitor)
|
deserializer.deserialize_str(DeserializeScopesVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user