Second fmt pass
This commit is contained in:
@@ -20,13 +20,13 @@ jobs:
|
|||||||
- nightly
|
- nightly
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt, clippy
|
components: clippy
|
||||||
|
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
@@ -35,11 +35,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --features all --verbose
|
args: --features all --verbose
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --verbose --all -- --check
|
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: --features all -- -D warnings
|
args: --features all -- -D warnings
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --verbose --all -- --check
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ use crate::status_builder;
|
|||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{self, Unexpected},
|
de::{self, Unexpected},
|
||||||
Deserialize,
|
Deserialize, Serialize,
|
||||||
Serialize,
|
|
||||||
};
|
};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ fn string_or_bool<'de, D: de::Deserializer<'de>>(val: D) -> ::std::result::Resul
|
|||||||
&"true or false",
|
&"true or false",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-17
@@ -90,11 +90,7 @@ pub use crate::{
|
|||||||
media_builder::MediaBuilder,
|
media_builder::MediaBuilder,
|
||||||
registration::Registration,
|
registration::Registration,
|
||||||
requests::{
|
requests::{
|
||||||
AddFilterRequest,
|
AddFilterRequest, AddPushRequest, StatusesRequest, UpdateCredsRequest, UpdatePushRequest,
|
||||||
AddPushRequest,
|
|
||||||
StatusesRequest,
|
|
||||||
UpdateCredsRequest,
|
|
||||||
UpdatePushRequest,
|
|
||||||
},
|
},
|
||||||
status_builder::{NewStatus, StatusBuilder},
|
status_builder::{NewStatus, StatusBuilder},
|
||||||
};
|
};
|
||||||
@@ -130,13 +126,7 @@ mod macros;
|
|||||||
/// Automatically import the things you need
|
/// Automatically import the things you need
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
scopes::Scopes,
|
scopes::Scopes, Data, Mastodon, MastodonClient, NewStatus, Registration, StatusBuilder,
|
||||||
Data,
|
|
||||||
Mastodon,
|
|
||||||
MastodonClient,
|
|
||||||
NewStatus,
|
|
||||||
Registration,
|
|
||||||
StatusBuilder,
|
|
||||||
StatusesRequest,
|
StatusesRequest,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -719,18 +709,18 @@ impl<R: EventStream> EventReader<R> {
|
|||||||
})?;
|
})?;
|
||||||
let notification = serde_json::from_str::<Notification>(&data)?;
|
let notification = serde_json::from_str::<Notification>(&data)?;
|
||||||
Event::Notification(notification)
|
Event::Notification(notification)
|
||||||
},
|
}
|
||||||
"update" => {
|
"update" => {
|
||||||
let data =
|
let data =
|
||||||
data.ok_or_else(|| Error::Other("Missing `data` line for update".to_string()))?;
|
data.ok_or_else(|| Error::Other("Missing `data` line for update".to_string()))?;
|
||||||
let status = serde_json::from_str::<Status>(&data)?;
|
let status = serde_json::from_str::<Status>(&data)?;
|
||||||
Event::Update(status)
|
Event::Update(status)
|
||||||
},
|
}
|
||||||
"delete" => {
|
"delete" => {
|
||||||
let data =
|
let data =
|
||||||
data.ok_or_else(|| Error::Other("Missing `data` line for delete".to_string()))?;
|
data.ok_or_else(|| Error::Other("Missing `data` line for delete".to_string()))?;
|
||||||
Event::Delete(data)
|
Event::Delete(data)
|
||||||
},
|
}
|
||||||
"filters_changed" => Event::FiltersChanged,
|
"filters_changed" => Event::FiltersChanged,
|
||||||
_ => return Err(Error::Other(format!("Unknown event `{}`", event))),
|
_ => return Err(Error::Other(format!("Unknown event `{}`", event))),
|
||||||
})
|
})
|
||||||
@@ -872,7 +862,7 @@ fn deserialise<T: for<'de> serde::Deserialize<'de>>(response: Response) -> Resul
|
|||||||
Ok(t) => {
|
Ok(t) => {
|
||||||
log::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) => {
|
||||||
@@ -881,6 +871,6 @@ fn deserialise<T: for<'de> serde::Deserialize<'de>>(response: Response) -> Resul
|
|||||||
return Err(Error::Api(error));
|
return Err(Error::Api(error));
|
||||||
}
|
}
|
||||||
Err(e.into())
|
Err(e.into())
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,7 @@ use crate::{
|
|||||||
media_builder::MediaBuilder,
|
media_builder::MediaBuilder,
|
||||||
page::Page,
|
page::Page,
|
||||||
requests::{
|
requests::{
|
||||||
AddFilterRequest,
|
AddFilterRequest, AddPushRequest, StatusesRequest, UpdateCredsRequest, UpdatePushRequest,
|
||||||
AddPushRequest,
|
|
||||||
StatusesRequest,
|
|
||||||
UpdateCredsRequest,
|
|
||||||
UpdatePushRequest,
|
|
||||||
},
|
},
|
||||||
status_builder::NewStatus,
|
status_builder::NewStatus,
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-5
@@ -9,11 +9,7 @@ use crate::{
|
|||||||
apps::{App, AppBuilder},
|
apps::{App, AppBuilder},
|
||||||
http_send::{HttpSend, HttpSender},
|
http_send::{HttpSend, HttpSender},
|
||||||
scopes::Scopes,
|
scopes::Scopes,
|
||||||
Data,
|
Data, Error, Mastodon, MastodonBuilder, Result,
|
||||||
Error,
|
|
||||||
Mastodon,
|
|
||||||
MastodonBuilder,
|
|
||||||
Result,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_REDIRECT_URI: &str = "urn:ietf:wg:oauth:2.0:oob";
|
const DEFAULT_REDIRECT_URI: &str = "urn:ietf:wg:oauth:2.0:oob";
|
||||||
|
|||||||
@@ -606,9 +606,7 @@ mod tests {
|
|||||||
form,
|
form,
|
||||||
update_data::Form {
|
update_data::Form {
|
||||||
id: "some-id".to_string(),
|
id: "some-id".to_string(),
|
||||||
data: update_data::Data {
|
data: update_data::Data { alerts: None },
|
||||||
alerts: None,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-19
@@ -9,9 +9,7 @@ use std::{
|
|||||||
use crate::errors::Error;
|
use crate::errors::Error;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{self, Visitor},
|
de::{self, Visitor},
|
||||||
Deserialize,
|
Deserialize, Deserializer, Serialize,
|
||||||
Deserializer,
|
|
||||||
Serialize,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents a set of OAuth scopes
|
/// Represents a set of OAuth scopes
|
||||||
@@ -40,9 +38,7 @@ impl FromStr for Scopes {
|
|||||||
let scope = Scope::from_str(&scope)?;
|
let scope = Scope::from_str(&scope)?;
|
||||||
set.insert(scope);
|
set.insert(scope);
|
||||||
}
|
}
|
||||||
Ok(Scopes {
|
Ok(Scopes { scopes: set })
|
||||||
scopes: set,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,14 +210,8 @@ impl Scopes {
|
|||||||
/// let read_write = read.and(write);
|
/// let read_write = read.and(write);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn and(self, other: Scopes) -> Scopes {
|
pub fn and(self, other: Scopes) -> Scopes {
|
||||||
let newset: HashSet<_> = self
|
let newset: HashSet<_> = self.scopes.union(&other.scopes).copied().collect();
|
||||||
.scopes
|
Scopes { scopes: newset }
|
||||||
.union(&other.scopes)
|
|
||||||
.copied()
|
|
||||||
.collect();
|
|
||||||
Scopes {
|
|
||||||
scopes: newset,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _write(subscope: Option<Write>) -> Scopes {
|
fn _write(subscope: Option<Write>) -> Scopes {
|
||||||
@@ -235,9 +225,7 @@ impl Scopes {
|
|||||||
fn new(scope: Scope) -> Scopes {
|
fn new(scope: Scope) -> Scopes {
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
set.insert(scope);
|
set.insert(scope);
|
||||||
Scopes {
|
Scopes { scopes: set }
|
||||||
scopes: set,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,11 +313,11 @@ impl FromStr for Scope {
|
|||||||
read if read.starts_with("read:") => {
|
read if read.starts_with("read:") => {
|
||||||
let r: Read = Read::from_str(&read[5..])?;
|
let r: Read = Read::from_str(&read[5..])?;
|
||||||
Scope::Read(Some(r))
|
Scope::Read(Some(r))
|
||||||
},
|
}
|
||||||
write if write.starts_with("write:") => {
|
write if write.starts_with("write:") => {
|
||||||
let w: Write = Write::from_str(&write[6..])?;
|
let w: Write = Write::from_str(&write[6..])?;
|
||||||
Scope::Write(Some(w))
|
Scope::Write(Some(w))
|
||||||
},
|
}
|
||||||
_ => return Err(Error::Other("Unknown scope".to_string())),
|
_ => return Err(Error::Other("Unknown scope".to_string())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user