Move From<> impls too
This commit is contained in:
+22
-3
@@ -1,7 +1,7 @@
|
||||
use std::{
|
||||
io,
|
||||
fmt,
|
||||
error
|
||||
error,
|
||||
io::Error as IoError
|
||||
};
|
||||
|
||||
use json::Error as SerdeError;
|
||||
@@ -28,7 +28,7 @@ pub enum Error {
|
||||
Http(HttpError),
|
||||
/// Wrapper around the `std::io::Error` struct.
|
||||
#[serde(skip_deserializing)]
|
||||
Io(io::Error),
|
||||
Io(IoError),
|
||||
/// Wrapper around the `url::ParseError` struct.
|
||||
#[serde(skip_deserializing)]
|
||||
Url(UrlError),
|
||||
@@ -86,3 +86,22 @@ pub struct ApiError {
|
||||
pub error_description: Option<String>,
|
||||
}
|
||||
|
||||
macro_rules! from {
|
||||
($($typ:ident, $variant:ident,)*) => {
|
||||
$(
|
||||
impl From<$typ> for Error {
|
||||
fn from(from: $typ) -> Self {
|
||||
use Error::*;
|
||||
$variant(from)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
from! {
|
||||
HttpError, Http,
|
||||
IoError, Io,
|
||||
SerdeError, Serde,
|
||||
UrlError, Url,
|
||||
}
|
||||
|
||||
-23
@@ -61,14 +61,10 @@ pub mod prelude {
|
||||
}
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::io::Error as IoError;
|
||||
use std::ops;
|
||||
|
||||
use json::Error as SerdeError;
|
||||
use reqwest::Error as HttpError;
|
||||
use reqwest::{Client, Response};
|
||||
use reqwest::header::{Authorization, Bearer, Headers};
|
||||
use url::ParseError as UrlError;
|
||||
|
||||
use entities::prelude::*;
|
||||
pub use status_builder::StatusBuilder;
|
||||
@@ -686,25 +682,6 @@ impl ops::Deref for Mastodon {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! from {
|
||||
($($typ:ident, $variant:ident,)*) => {
|
||||
$(
|
||||
impl From<$typ> for Error {
|
||||
fn from(from: $typ) -> Self {
|
||||
use Error::*;
|
||||
$variant(from)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
from! {
|
||||
HttpError, Http,
|
||||
IoError, Io,
|
||||
SerdeError, Serde,
|
||||
UrlError, Url,
|
||||
}
|
||||
|
||||
// Convert the HTTP response body from JSON. Pass up deserialization errors
|
||||
// transparently.
|
||||
|
||||
Reference in New Issue
Block a user