Change Mastodon::from_data to just Mastodon::from

This commit is contained in:
Paul Woolcock
2018-08-22 06:48:56 -04:00
parent 1847160369
commit cc083e335e
4 changed files with 18 additions and 15 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ use serde::Deserialize;
/// # redirect: "".into(),
/// # token: "".into(),
/// # };
/// let client = Mastodon::from_data(data);
/// let client = Mastodon::from(data);
/// let statuses = client.statuses("user-id", None)?;
/// for status in statuses.items_iter() {
/// // do something with `status`
+13 -11
View File
@@ -438,8 +438,18 @@ impl Mastodon {
}
}
methods![get, post, delete,];
fn route(&self, url: &str) -> String {
let mut s = (*self.base).to_owned();
s += url;
s
}
}
impl From<Data> for Mastodon {
/// Creates a mastodon instance from the data struct.
pub fn from_data(data: Data) -> Self {
fn from(data: Data) -> Mastodon {
let mut headers = Headers::new();
headers.set(Authorization(Bearer { token: (*data.token).to_owned() }));
@@ -449,14 +459,6 @@ impl Mastodon {
data: data,
}
}
methods![get, post, delete,];
fn route(&self, url: &str) -> String {
let mut s = (*self.base).to_owned();
s += url;
s
}
}
impl MastodonClient for Mastodon {
@@ -586,7 +588,7 @@ impl MastodonClient for Mastodon {
/// # redirect: "".into(),
/// # token: "".into(),
/// # };
/// let client = Mastodon::from_data(data);
/// let client = Mastodon::from(data);
/// let statuses = client.statuses("user-id", None)?;
/// # Ok(())
/// # }
@@ -604,7 +606,7 @@ impl MastodonClient for Mastodon {
/// # redirect: "".into(),
/// # token: "".into(),
/// # };
/// let client = Mastodon::from_data(data);
/// let client = Mastodon::from(data);
/// let request = StatusesRequest::default()
/// .only_media();
/// let statuses = client.statuses("user-id", request)?;