Skip to content

Commit

Permalink
Make BlockFrostApi's Settings public
Browse files Browse the repository at this point in the history
Possible now that project_id is not stored in Settings, but in
BlockFrostApi directly.
  • Loading branch information
marcospb19 committed Oct 12, 2021
1 parent e18535a commit 5e01c93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/api/lister.rs
Expand Up @@ -23,7 +23,7 @@ pub struct Lister<'api, T> {
impl<T> Lister<'_, T> {
pub(crate) fn list_from_endpoint(api: &BlockFrostApi, endpoint: String) -> Lister<'_, T> {
let inner = FuturesOrdered::<ListerFuture<T>>::new();
let current_page = api.settings().query_parameters().page.unwrap_or(1);
let current_page = api.settings.query_parameters().page.unwrap_or(1);
Lister { inner, endpoint, api, current_page }
}
}
Expand All @@ -34,7 +34,7 @@ impl<'api, T: 'api + for<'de> serde::Deserialize<'de>> Stream for Lister<'api, T
fn poll_next(mut self: Pin<&mut Self>, context: &mut Context) -> Poll<Option<Self::Item>> {
while self.inner.len() < 10 {
// Making the next requests
let settings = self.api.settings();
let settings = &self.api.settings;
let endpoint = &self.endpoint;
let page = Some(self.current_page);

Expand Down
8 changes: 2 additions & 6 deletions src/api/mod.rs
Expand Up @@ -21,7 +21,7 @@ pub const USER_AGENT: &str = concat!("blockfrost-rust/", env!("CARGO_PKG_VERSION

#[derive(Debug, Clone)]
pub struct BlockFrostApi {
settings: Settings,
pub settings: Settings,
client: reqwest::Client,
}

Expand All @@ -42,10 +42,6 @@ impl BlockFrostApi {
Self { settings, client }
}

pub fn settings(&self) -> &Settings {
&self.settings
}

// Url endpoint example: "/blocks"
fn get_from_endpoint<T>(
&self,
Expand All @@ -54,7 +50,7 @@ impl BlockFrostApi {
where
T: serde::de::DeserializeOwned,
{
let Url(url) = Url::from_endpoint(self.settings(), url_endpoint);
let Url(url) = Url::from_endpoint(&self.settings, url_endpoint);
Self::get_from_url(self, url)
}

Expand Down

0 comments on commit 5e01c93

Please sign in to comment.