summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2020-09-25 16:16:05 -0400
committerPaul Woolcock <paul@woolcock.us>2020-09-25 16:44:06 -0400
commit602bfb7cdd9e25a4447db6de7be90e973a88d93a (patch)
tree6b0b6928361a72f8f6149badd11823915bc2a1d6
parent7487f607e64a3e5149a84c258c6e102354e8ba14 (diff)
use nightly fmt
-rw-r--r--.github/workflows/rust.yml20
-rw-r--r--src/entities/account.rs5
-rw-r--r--src/lib.rs24
-rw-r--r--src/mastodon_client.rs6
-rw-r--r--src/registration.rs6
-rw-r--r--src/requests/push.rs4
-rw-r--r--src/scopes.rs20
7 files changed, 54 insertions, 31 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 582bdcb..9fe45a3 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -20,13 +20,13 @@ jobs:
- nightly
steps:
- uses: actions/checkout@v2
-
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- components: clippy
+ components: rustfmt, clippy
+
- uses: actions-rs/cargo@v1
with:
command: build
@@ -36,17 +36,11 @@ jobs:
command: test
args: --features all --verbose
- uses: actions-rs/cargo@v1
- with:
- command: clippy
- args: --features all -- -D warnings
-
- - uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: stable
- override: true
- components: rustfmt
- - uses: actions-rs/cargo@v1
+ if: ${{ matrix.rust == 'nightly' }}
with:
command: fmt
args: --verbose --all -- --check
+ - uses: actions-rs/cargo@v1
+ with:
+ command: clippy
+ args: --features all -- -D warnings
diff --git a/src/entities/account.rs b/src/entities/account.rs
index 092cf84..a0b1fd5 100644
--- a/src/entities/account.rs
+++ b/src/entities/account.rs
@@ -4,7 +4,8 @@ use crate::status_builder;
use chrono::prelude::*;
use serde::{
de::{self, Unexpected},
- Deserialize, Serialize,
+ Deserialize,
+ Serialize,
};
use std::path::PathBuf;
@@ -103,7 +104,7 @@ fn string_or_bool<'de, D: de::Deserializer<'de>>(val: D) -> ::std::result::Resul
&"true or false",
));
}
- }
+ },
})
}
diff --git a/src/lib.rs b/src/lib.rs
index 6782df0..7c5925a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -90,7 +90,11 @@ pub use crate::{
media_builder::MediaBuilder,
registration::Registration,
requests::{
- AddFilterRequest, AddPushRequest, StatusesRequest, UpdateCredsRequest, UpdatePushRequest,
+ AddFilterRequest,
+ AddPushRequest,
+ StatusesRequest,
+ UpdateCredsRequest,
+ UpdatePushRequest,
},
status_builder::{NewStatus, StatusBuilder},
};
@@ -126,7 +130,13 @@ mod macros;
/// Automatically import the things you need
pub mod prelude {
pub use crate::{
- scopes::Scopes, Data, Mastodon, MastodonClient, NewStatus, Registration, StatusBuilder,
+ scopes::Scopes,
+ Data,
+ Mastodon,
+ MastodonClient,
+ NewStatus,
+ Registration,
+ StatusBuilder,
StatusesRequest,
};
}
@@ -709,18 +719,18 @@ impl<R: EventStream> EventReader<R> {
})?;
let notification = serde_json::from_str::<Notification>(&data)?;
Event::Notification(notification)
- }
+ },
"update" => {
let data =
data.ok_or_else(|| Error::Other("Missing `data` line for update".to_string()))?;
let status = serde_json::from_str::<Status>(&data)?;
Event::Update(status)
- }
+ },
"delete" => {
let data =
data.ok_or_else(|| Error::Other("Missing `data` line for delete".to_string()))?;
Event::Delete(data)
- }
+ },
"filters_changed" => Event::FiltersChanged,
_ => return Err(Error::Other(format!("Unknown event `{}`", event))),
})
@@ -862,7 +872,7 @@ fn deserialise<T: for<'de> serde::Deserialize<'de>>(response: Response) -> Resul
Ok(t) => {
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) => {
@@ -871,6 +881,6 @@ fn deserialise<T: for<'de> serde::Deserialize<'de>>(response: Response) -> Resul
return Err(Error::Api(error));
}
Err(e.into())
- }
+ },
}
}
diff --git a/src/mastodon_client.rs b/src/mastodon_client.rs
index 2810dab..a81bd4e 100644
--- a/src/mastodon_client.rs
+++ b/src/mastodon_client.rs
@@ -7,7 +7,11 @@ use crate::{
media_builder::MediaBuilder,
page::Page,
requests::{
- AddFilterRequest, AddPushRequest, StatusesRequest, UpdateCredsRequest, UpdatePushRequest,
+ AddFilterRequest,
+ AddPushRequest,
+ StatusesRequest,
+ UpdateCredsRequest,
+ UpdatePushRequest,
},
status_builder::NewStatus,
};
diff --git a/src/registration.rs b/src/registration.rs
index 3486f1b..1ac5e7f 100644
--- a/src/registration.rs
+++ b/src/registration.rs
@@ -9,7 +9,11 @@ use crate::{
apps::{App, AppBuilder},
http_send::{HttpSend, HttpSender},
scopes::Scopes,
- Data, Error, Mastodon, MastodonBuilder, Result,
+ Data,
+ Error,
+ Mastodon,
+ MastodonBuilder,
+ Result,
};
const DEFAULT_REDIRECT_URI: &str = "urn:ietf:wg:oauth:2.0:oob";
diff --git a/src/requests/push.rs b/src/requests/push.rs
index 8a44394..970fe2c 100644
--- a/src/requests/push.rs
+++ b/src/requests/push.rs
@@ -606,7 +606,9 @@ mod tests {
form,
update_data::Form {
id: "some-id".to_string(),
- data: update_data::Data { alerts: None },
+ data: update_data::Data {
+ alerts: None
+ },
}
);
}
diff --git a/src/scopes.rs b/src/scopes.rs
index 04bea3e..d39ed09 100644
--- a/src/scopes.rs
+++ b/src/scopes.rs
@@ -9,7 +9,9 @@ use std::{
use crate::errors::Error;
use serde::{
de::{self, Visitor},
- Deserialize, Deserializer, Serialize,
+ Deserialize,
+ Deserializer,
+ Serialize,
};
/// Represents a set of OAuth scopes
@@ -38,7 +40,9 @@ impl FromStr for Scopes {
let scope = Scope::from_str(&scope)?;
set.insert(scope);
}
- Ok(Scopes { scopes: set })
+ Ok(Scopes {
+ scopes: set,
+ })
}
}
@@ -211,7 +215,9 @@ impl Scopes {
/// ```
pub fn and(self, other: Scopes) -> Scopes {
let newset: HashSet<_> = self.scopes.union(&other.scopes).copied().collect();
- Scopes { scopes: newset }
+ Scopes {
+ scopes: newset,
+ }
}
fn _write(subscope: Option<Write>) -> Scopes {
@@ -225,7 +231,9 @@ impl Scopes {
fn new(scope: Scope) -> Scopes {
let mut set = HashSet::new();
set.insert(scope);
- Scopes { scopes: set }
+ Scopes {
+ scopes: set,
+ }
}
}
@@ -313,11 +321,11 @@ impl FromStr for Scope {
read if read.starts_with("read:") => {
let r: Read = Read::from_str(&read[5..])?;
Scope::Read(Some(r))
- }
+ },
write if write.starts_with("write:") => {
let w: Write = Write::from_str(&write[6..])?;
Scope::Write(Some(w))
- }
+ },
_ => return Err(Error::Other("Unknown scope".to_string())),
})
}