Merge pull request #14 from matthiasbeyer/clippy
Fix clippy warnings and add CI check
This commit is contained in:
commit
8516091c5b
|
@ -20,3 +20,15 @@ jobs:
|
||||||
run: cargo build --verbose
|
run: cargo build --verbose
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose
|
run: cargo test --verbose
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: 1.65.0
|
||||||
|
components: clippy
|
||||||
|
- run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
|
|
@ -110,13 +110,13 @@ impl<'a> AppBuilder<'a> {
|
||||||
Ok(App {
|
Ok(App {
|
||||||
client_name: self
|
client_name: self
|
||||||
.client_name
|
.client_name
|
||||||
.ok_or_else(|| Error::MissingField("client_name"))?
|
.ok_or(Error::MissingField("client_name"))?
|
||||||
.into(),
|
.into(),
|
||||||
redirect_uris: self
|
redirect_uris: self
|
||||||
.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()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ impl<'a> TryInto<App> for AppBuilder<'a> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_into(self) -> Result<App> {
|
fn try_into(self) -> Result<App> {
|
||||||
Ok(self.build()?)
|
self.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// 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.
|
||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
|
||||||
pub struct Data {
|
pub struct Data {
|
||||||
/// Base url of instance eg. `https://botsin.space`.
|
/// Base url of instance eg. `https://botsin.space`.
|
||||||
pub base: Cow<'static, str>,
|
pub base: Cow<'static, str>,
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub struct Account {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single name: value pair from a user's profile
|
/// A single name: value pair from a user's profile
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
|
||||||
pub struct MetadataField {
|
pub struct MetadataField {
|
||||||
/// name part of metadata
|
/// name part of metadata
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -74,7 +74,7 @@ impl MetadataField {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An extra object given from `verify_credentials` giving defaults about a user
|
/// An extra object given from `verify_credentials` giving defaults about a user
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Source {
|
pub struct Source {
|
||||||
privacy: Option<status_builder::Visibility>,
|
privacy: Option<status_builder::Visibility>,
|
||||||
#[serde(deserialize_with = "string_or_bool")]
|
#[serde(deserialize_with = "string_or_bool")]
|
||||||
|
@ -84,7 +84,7 @@ pub struct Source {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bool, D::Error> {
|
fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bool, D::Error> {
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum BoolOrString {
|
pub enum BoolOrString {
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
|
@ -108,7 +108,7 @@ fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
|
#[derive(Debug, Default, Clone, Serialize, PartialEq, Eq)]
|
||||||
pub(crate) struct UpdateSource {
|
pub(crate) struct UpdateSource {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub(crate) privacy: Option<status_builder::Visibility>,
|
pub(crate) privacy: Option<status_builder::Visibility>,
|
||||||
|
@ -116,7 +116,7 @@ pub(crate) struct UpdateSource {
|
||||||
pub(crate) sensitive: Option<bool>,
|
pub(crate) sensitive: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Serialize, PartialEq)]
|
#[derive(Debug, Default, Serialize, PartialEq, Eq)]
|
||||||
pub(crate) struct Credentials {
|
pub(crate) struct Credentials {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub(crate) display_name: Option<String>,
|
pub(crate) display_name: Option<String>,
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub struct ImageDetails {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of media attachment.
|
/// The type of media attachment.
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq)]
|
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum MediaType {
|
pub enum MediaType {
|
||||||
/// An image.
|
/// An image.
|
||||||
#[serde(rename = "image")]
|
#[serde(rename = "image")]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A card of a status.
|
/// A card of a status.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Card {
|
pub struct Card {
|
||||||
/// The url associated with the card.
|
/// The url associated with the card.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents a single Filter
|
/// Represents a single Filter
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Filter {
|
pub struct Filter {
|
||||||
id: String,
|
id: String,
|
||||||
phrase: String,
|
phrase: String,
|
||||||
|
@ -12,7 +12,7 @@ pub struct Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the various types of Filter contexts
|
/// Represents the various types of Filter contexts
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum FilterContext {
|
pub enum FilterContext {
|
||||||
/// Represents the "home" context
|
/// Represents the "home" context
|
||||||
#[serde(rename = "home")]
|
#[serde(rename = "home")]
|
||||||
|
|
|
@ -32,14 +32,14 @@ pub struct Instance {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object containing url for streaming api.
|
/// Object containing url for streaming api.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct StreamingApi {
|
pub struct StreamingApi {
|
||||||
/// Url for streaming API, typically a `wss://` url.
|
/// Url for streaming API, typically a `wss://` url.
|
||||||
pub streaming_api: String,
|
pub streaming_api: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Statistics about the Mastodon instance.
|
/// Statistics about the Mastodon instance.
|
||||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct Stats {
|
pub struct Stats {
|
||||||
user_count: u64,
|
user_count: u64,
|
||||||
status_count: u64,
|
status_count: u64,
|
||||||
|
|
|
@ -90,9 +90,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de> + Serialize> ItemsIter<T> {
|
||||||
Some((item, this))
|
Some((item, this))
|
||||||
} else {
|
} else {
|
||||||
if this.need_next_page() {
|
if this.need_next_page() {
|
||||||
if this.fill_next_page().await.is_none() {
|
this.fill_next_page().await?;
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let idx = this.cur_idx;
|
let idx = this.cur_idx;
|
||||||
this.cur_idx += 1;
|
this.cur_idx += 1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Used for ser/de of list resources
|
/// Used for ser/de of list resources
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
pub struct List {
|
pub struct List {
|
||||||
id: String,
|
id: String,
|
||||||
title: String,
|
title: String,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents a `mention` used in a status
|
/// Represents a `mention` used in a status
|
||||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub struct Mention {
|
pub struct Mention {
|
||||||
/// URL of user's profile (can be remote)
|
/// URL of user's profile (can be remote)
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub mod search_result;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
|
|
||||||
/// An empty JSON object.
|
/// An empty JSON object.
|
||||||
#[derive(Deserialize, Serialize, Debug, Copy, Clone, PartialEq)]
|
#[derive(Deserialize, Serialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct Empty {}
|
pub struct Empty {}
|
||||||
|
|
||||||
/// The purpose of this module is to alleviate imports of many common
|
/// The purpose of this module is to alleviate imports of many common
|
||||||
|
|
|
@ -5,6 +5,7 @@ use chrono::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct containing info about a notification.
|
/// A struct containing info about a notification.
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
|
||||||
pub struct Notification {
|
pub struct Notification {
|
||||||
/// The notification ID.
|
/// The notification ID.
|
||||||
|
@ -21,7 +22,7 @@ pub struct Notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of notification.
|
/// The type of notification.
|
||||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq)]
|
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum NotificationType {
|
pub enum NotificationType {
|
||||||
/// Someone mentioned the application client in another status.
|
/// Someone mentioned the application client in another status.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
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, Eq, Serialize, Deserialize, Default)]
|
||||||
pub struct Alerts {
|
pub struct Alerts {
|
||||||
/// flag for follow alerts
|
/// flag for follow alerts
|
||||||
pub follow: Option<bool>,
|
pub follow: Option<bool>,
|
||||||
|
@ -14,7 +14,7 @@ pub struct Alerts {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a new Push subscription
|
/// Represents a new Push subscription
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Subscription {
|
pub struct Subscription {
|
||||||
/// The `id` of the subscription
|
/// The `id` of the subscription
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
@ -37,19 +37,19 @@ pub(crate) mod add_subscription {
|
||||||
pub(crate) data: Option<Data>,
|
pub(crate) data: Option<Data>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub(crate) struct Subscription {
|
pub(crate) struct Subscription {
|
||||||
pub(crate) endpoint: String,
|
pub(crate) endpoint: String,
|
||||||
pub(crate) keys: Keys,
|
pub(crate) keys: Keys,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub(crate) struct Keys {
|
pub(crate) struct Keys {
|
||||||
pub(crate) p256dh: String,
|
pub(crate) p256dh: String,
|
||||||
pub(crate) auth: String,
|
pub(crate) auth: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub(crate) struct Data {
|
pub(crate) struct Data {
|
||||||
pub(crate) alerts: Option<Alerts>,
|
pub(crate) alerts: Option<Alerts>,
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,12 @@ pub(crate) mod update_data {
|
||||||
|
|
||||||
use super::Alerts;
|
use super::Alerts;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub(crate) struct Data {
|
pub(crate) struct Data {
|
||||||
pub(crate) alerts: Option<Alerts>,
|
pub(crate) alerts: Option<Alerts>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
pub(crate) struct Form {
|
pub(crate) struct Form {
|
||||||
pub(crate) id: String,
|
pub(crate) id: String,
|
||||||
pub(crate) data: Data,
|
pub(crate) data: Data,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct containing information about a relationship with another account.
|
/// A struct containing information about a relationship with another account.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Relationship {
|
pub struct Relationship {
|
||||||
/// Target account id
|
/// Target account id
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct containing info about a report.
|
/// A struct containing info about a report.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Report {
|
pub struct Report {
|
||||||
/// The ID of the report.
|
/// The ID of the report.
|
||||||
pub id: String,
|
pub id: String,
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub struct Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mention of another user.
|
/// A mention of another user.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Mention {
|
pub struct Mention {
|
||||||
/// URL of user's profile (can be remote).
|
/// URL of user's profile (can be remote).
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
@ -78,7 +78,7 @@ pub struct Mention {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Struct representing an emoji within text.
|
/// Struct representing an emoji within text.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Emoji {
|
pub struct Emoji {
|
||||||
/// The shortcode of the emoji
|
/// The shortcode of the emoji
|
||||||
pub shortcode: String,
|
pub shortcode: String,
|
||||||
|
@ -93,6 +93,7 @@ pub struct Emoji {
|
||||||
/// as a [`Tag`](https://docs.joinmastodon.org/entities/Tag/). In the case of
|
/// as a [`Tag`](https://docs.joinmastodon.org/entities/Tag/). In the case of
|
||||||
/// the former, at the time of writing, the history field is always empty and
|
/// the former, at the time of writing, the history field is always empty and
|
||||||
/// the following field is always none.
|
/// the following field is always none.
|
||||||
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
/// The hashtag, not including the preceding `#`.
|
/// The hashtag, not including the preceding `#`.
|
||||||
|
@ -107,7 +108,7 @@ pub struct Tag {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Application details.
|
/// Application details.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Application {
|
pub struct Application {
|
||||||
/// Name of the application.
|
/// Name of the application.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -116,7 +117,7 @@ pub struct Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Usage statistics for given days (typically the past week).
|
/// Usage statistics for given days (typically the past week).
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct TagHistory {
|
pub struct TagHistory {
|
||||||
/// UNIX timestamp on midnight of the given day.
|
/// UNIX timestamp on midnight of the given day.
|
||||||
pub day: String,
|
pub day: String,
|
||||||
|
|
|
@ -173,7 +173,7 @@ from! {
|
||||||
macro_rules! format_err {
|
macro_rules! format_err {
|
||||||
( $( $arg:tt )* ) => {
|
( $( $arg:tt )* ) => {
|
||||||
{
|
{
|
||||||
crate::Error::Other(format!($($arg)*))
|
$crate::Error::Other(format!($($arg)*))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn event_stream(
|
||||||
while let Some(line) = lines_iter.next_line().await? {
|
while let Some(line) = lines_iter.next_line().await? {
|
||||||
debug!(message = line, location = &location; "received message");
|
debug!(message = line, location = &location; "received 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);
|
||||||
|
|
|
@ -86,6 +86,7 @@ macro_rules! paged_routes {
|
||||||
_marker: ::std::marker::PhantomData<&'a ()>,
|
_marker: ::std::marker::PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::redundant_field_names)]
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param: $param,
|
||||||
|
@ -135,6 +136,7 @@ macro_rules! route_v2 {
|
||||||
_marker: ::std::marker::PhantomData<&'a ()>,
|
_marker: ::std::marker::PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::redundant_field_names)]
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param: $param,
|
||||||
|
@ -349,6 +351,7 @@ macro_rules! route {
|
||||||
_marker: ::std::marker::PhantomData<&'a ()>,
|
_marker: ::std::marker::PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::redundant_field_names)]
|
||||||
let qs_data = Data {
|
let qs_data = Data {
|
||||||
$(
|
$(
|
||||||
$param: $param,
|
$param: $param,
|
||||||
|
|
|
@ -326,11 +326,11 @@ impl Mastodon {
|
||||||
|
|
||||||
if ids.len() == 1 {
|
if ids.len() == 1 {
|
||||||
url += "id=";
|
url += "id=";
|
||||||
url += &ids[0];
|
url += ids[0];
|
||||||
} else {
|
} else {
|
||||||
for id in ids {
|
for id in ids {
|
||||||
url += "id[]=";
|
url += "id[]=";
|
||||||
url += &id;
|
url += id;
|
||||||
url += "&";
|
url += "&";
|
||||||
}
|
}
|
||||||
url.pop();
|
url.pop();
|
||||||
|
@ -427,7 +427,7 @@ impl Mastodon {
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(path = as_debug!(path), error = as_debug!(err); "error reading file contents for multipart form");
|
error!(path = as_debug!(path), error = as_debug!(err); "error reading file contents for multipart form");
|
||||||
return Err(err.into());
|
Err(err.into())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ fn get_links(response: &Response, call_id: Uuid) -> Result<(Option<Url>, Option<
|
||||||
let link_header = link_header.to_str()?;
|
let link_header = link_header.to_str()?;
|
||||||
trace!(link_header = link_header, call_id = as_debug!(call_id); "parsing link header");
|
trace!(link_header = link_header, call_id = as_debug!(call_id); "parsing link header");
|
||||||
let link_header = link_header.as_bytes();
|
let link_header = link_header.as_bytes();
|
||||||
let link_header: Link = parsing::from_raw_str(&link_header)?;
|
let link_header: Link = parsing::from_raw_str(link_header)?;
|
||||||
for value in link_header.values() {
|
for value in link_header.values() {
|
||||||
if let Some(relations) = value.rel() {
|
if let Some(relations) = value.rel() {
|
||||||
if relations.contains(&RelationType::Next) {
|
if relations.contains(&RelationType::Next) {
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::time::Duration;
|
||||||
/// use mastodon_async::{entities::filter::FilterContext, requests::AddFilterRequest};
|
/// use mastodon_async::{entities::filter::FilterContext, requests::AddFilterRequest};
|
||||||
/// let request = AddFilterRequest::new("foo", FilterContext::Home);
|
/// let request = AddFilterRequest::new("foo", FilterContext::Home);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct AddFilterRequest {
|
pub struct AddFilterRequest {
|
||||||
phrase: String,
|
phrase: String,
|
||||||
context: FilterContext,
|
context: FilterContext,
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
||||||
///
|
///
|
||||||
/// let keys = Keys::new("anetohias===", "oeatssah=");
|
/// let keys = Keys::new("anetohias===", "oeatssah=");
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct Keys {
|
pub struct Keys {
|
||||||
pub(crate) p256dh: String,
|
pub(crate) p256dh: String,
|
||||||
pub(crate) auth: String,
|
pub(crate) auth: String,
|
||||||
|
@ -55,7 +55,7 @@ impl Keys {
|
||||||
/// client.add_push_subscription(&request).await.unwrap();
|
/// client.add_push_subscription(&request).await.unwrap();
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct AddPushRequest {
|
pub struct AddPushRequest {
|
||||||
endpoint: String,
|
endpoint: String,
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ impl AddPushRequest {
|
||||||
/// client.update_push_data(&request).await.unwrap();
|
/// client.update_push_data(&request).await.unwrap();
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize)]
|
||||||
pub struct UpdatePushRequest {
|
pub struct UpdatePushRequest {
|
||||||
id: String,
|
id: String,
|
||||||
follow: Option<bool>,
|
follow: Option<bool>,
|
||||||
|
|
|
@ -29,7 +29,7 @@ mod bool_qs_serialize {
|
||||||
/// request.only_media().pinned().since_id("foo");
|
/// request.only_media().pinned().since_id("foo");
|
||||||
/// assert_eq!(&request.to_querystring().expect("Couldn't serialize qs")[..], "?only_media=1&pinned=1&since_id=foo");
|
/// assert_eq!(&request.to_querystring().expect("Couldn't serialize qs")[..], "?only_media=1&pinned=1&since_id=foo");
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
|
||||||
pub struct StatusesRequest<'a> {
|
pub struct StatusesRequest<'a> {
|
||||||
#[serde(skip_serializing_if = "bool_qs_serialize::is_false")]
|
#[serde(skip_serializing_if = "bool_qs_serialize::is_false")]
|
||||||
#[serde(serialize_with = "bool_qs_serialize::serialize")]
|
#[serde(serialize_with = "bool_qs_serialize::serialize")]
|
||||||
|
@ -50,16 +50,16 @@ pub struct StatusesRequest<'a> {
|
||||||
min_id: Option<Cow<'a, str>>,
|
min_id: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<Option<StatusesRequest<'a>>> for &'a mut StatusesRequest<'a> {
|
impl<'a> From<&'a mut StatusesRequest<'a>> for Option<StatusesRequest<'a>> {
|
||||||
fn into(self) -> Option<StatusesRequest<'a>> {
|
fn from(sr: &'a mut StatusesRequest<'a>) -> Self {
|
||||||
Some(StatusesRequest {
|
Some(StatusesRequest {
|
||||||
only_media: self.only_media,
|
only_media: sr.only_media,
|
||||||
exclude_replies: self.exclude_replies,
|
exclude_replies: sr.exclude_replies,
|
||||||
pinned: self.pinned,
|
pinned: sr.pinned,
|
||||||
max_id: self.max_id.clone(),
|
max_id: sr.max_id.clone(),
|
||||||
since_id: self.since_id.clone(),
|
since_id: sr.since_id.clone(),
|
||||||
limit: self.limit.clone(),
|
limit: sr.limit,
|
||||||
min_id: self.min_id.clone(),
|
min_id: sr.min_id.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
/// let result = client.update_credentials(&mut builder).await.unwrap();
|
/// let result = client.update_credentials(&mut builder).await.unwrap();
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct UpdateCredsRequest {
|
pub struct UpdateCredsRequest {
|
||||||
display_name: Option<String>,
|
display_name: Option<String>,
|
||||||
note: Option<String>,
|
note: Option<String>,
|
||||||
|
@ -176,8 +176,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(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl FromStr for Scopes {
|
||||||
fn from_str(s: &str) -> Result<Scopes, Self::Err> {
|
fn from_str(s: &str) -> Result<Scopes, Self::Err> {
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
for scope in s.split_whitespace() {
|
for scope in s.split_whitespace() {
|
||||||
let scope = Scope::from_str(&scope)?;
|
let scope = Scope::from_str(scope)?;
|
||||||
set.insert(scope);
|
set.insert(scope);
|
||||||
}
|
}
|
||||||
Ok(Scopes {
|
Ok(Scopes {
|
||||||
|
@ -184,7 +184,7 @@ impl Scopes {
|
||||||
.scopes
|
.scopes
|
||||||
.union(&other.scopes)
|
.union(&other.scopes)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| *s)
|
.copied()
|
||||||
.collect();
|
.collect();
|
||||||
Scopes {
|
Scopes {
|
||||||
scopes: newset,
|
scopes: newset,
|
||||||
|
@ -264,7 +264,7 @@ impl fmt::Display for Scopes {
|
||||||
/// Permission scope of the application.
|
/// Permission scope of the application.
|
||||||
/// [Details on what each permission provides][1]
|
/// [Details on what each permission provides][1]
|
||||||
/// [1]: https://github.com/tootsuite/documentation/blob/master/Using-the-API/OAuth-details.md)
|
/// [1]: https://github.com/tootsuite/documentation/blob/master/Using-the-API/OAuth-details.md)
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Hash, Serialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)]
|
||||||
enum Scope {
|
enum Scope {
|
||||||
/// Read only permissions.
|
/// Read only permissions.
|
||||||
#[serde(rename = "read")]
|
#[serde(rename = "read")]
|
||||||
|
@ -302,6 +302,12 @@ impl FromStr for Scope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for Scope {
|
||||||
|
fn partial_cmp(&self, other: &Scope) -> Option<Ordering> {
|
||||||
|
Some(self.cmp(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Ord for Scope {
|
impl Ord for Scope {
|
||||||
fn cmp(&self, other: &Scope) -> Ordering {
|
fn cmp(&self, other: &Scope) -> Ordering {
|
||||||
match (*self, *other) {
|
match (*self, *other) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
|
||||||
/// .language(Language::Eng)
|
/// .language(Language::Eng)
|
||||||
/// .build().unwrap();
|
/// .build().unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct StatusBuilder {
|
pub struct StatusBuilder {
|
||||||
status: Option<String>,
|
status: Option<String>,
|
||||||
in_reply_to_id: Option<String>,
|
in_reply_to_id: Option<String>,
|
||||||
|
@ -210,17 +210,17 @@ 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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a post that can be sent to the POST /api/v1/status endpoint
|
/// Represents a post that can be sent to the POST /api/v1/status endpoint
|
||||||
#[derive(Debug, Default, Clone, Serialize, PartialEq)]
|
#[derive(Debug, Default, Clone, Serialize, PartialEq, Eq)]
|
||||||
pub struct NewStatus {
|
pub struct NewStatus {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
status: Option<String>,
|
status: Option<String>,
|
||||||
|
@ -241,7 +241,7 @@ pub struct NewStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The visibility of a status.
|
/// The visibility of a status.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Visibility {
|
pub enum Visibility {
|
||||||
/// A Direct message to a user
|
/// A Direct message to a user
|
||||||
|
|
Loading…
Reference in New Issue