From e57f49f1131f0136cb5451be770d77ee69492c0f Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 12 Dec 2023 15:39:43 +0100 Subject: [PATCH] refactor: lint --- rustfmt.toml | 44 +++++-------------------------- src/api/endpoints/accounts.rs | 35 +++++++----------------- src/api/endpoints/addresses.rs | 16 +++-------- src/api/endpoints/assets.rs | 16 +++-------- src/api/endpoints/blocks.rs | 20 ++++---------- src/api/endpoints/epochs.rs | 21 ++++----------- src/api/endpoints/mempool.rs | 7 ++--- src/api/endpoints/metadata.rs | 11 +++----- src/api/endpoints/metrics.rs | 3 +-- src/api/endpoints/nutlink.rs | 13 +++------ src/api/endpoints/pools.rs | 25 +++++------------- src/api/endpoints/scripts.rs | 10 +++---- src/api/endpoints/transactions.rs | 27 +++++++------------ src/api/mod.rs | 8 ++---- src/error.rs | 10 +++---- src/ipfs.rs | 4 +-- src/request.rs | 17 ++++-------- src/url.rs | 9 ++----- 18 files changed, 75 insertions(+), 221 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 5e05cba..fe7853b 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,41 +1,11 @@ -# General -hard_tabs = false -tab_spaces = 4 -newline_style = "Unix" -width = 80 +# Sets the maximum line length. Code will be wrapped beyond this length. max_width = 100 -error_on_line_overflow = true -error_on_unformatted = true - -# Comments -wrap_comments = true -format_code_in_doc_comments = true - -# Control Flow -fn_call_width = 60 -brace_style = "SameLineWhere" -control_brace_style = "AlwaysSameLine" -# Indentation -indent_style = "Block" -match_block_trailing_comma = true - -# Imports -imports_indent = "Block" -imports_layout = "Vertical" -merge_imports = true - -# Ordering -reorder_imports = true -reorder_modules = true +# Use spaces for indentation rather than tabs. +hard_tabs = false -# Spaces -spaces_around_ranges = true -spaces_within_angle_brackets = true -spaces_within_parens_and_brackets = true +# Configure the visual indentation of arguments and parameters. +fn_params_layout = "Compressed" -# Misc -use_try_shorthand = true -use_field_init_shorthand = true -normalize_comments = true -normalize_doc_attributes = true +# Controls whether to put `else` on a new line. +newline_style = "Auto" diff --git a/src/api/endpoints/accounts.rs b/src/api/endpoints/accounts.rs index d37d6a3..41bcac7 100644 --- a/src/api/endpoints/accounts.rs +++ b/src/api/endpoints/accounts.rs @@ -19,9 +19,7 @@ impl BlockfrostAPI { /// Reward history of a specific account. pub async fn accounts_rewards( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/rewards", stake_address).as_str(), @@ -32,9 +30,7 @@ impl BlockfrostAPI { /// History of a specific account. pub async fn accounts_history( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/history", stake_address).as_str(), @@ -44,9 +40,7 @@ impl BlockfrostAPI { } pub async fn accounts_delegations( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/delegations", stake_address).as_str(), @@ -56,9 +50,7 @@ impl BlockfrostAPI { } pub async fn accounts_registrations( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/registrations", stake_address).as_str(), @@ -68,9 +60,7 @@ impl BlockfrostAPI { } pub async fn accounts_withdrawals( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/withdrawals", stake_address).as_str(), @@ -80,9 +70,7 @@ impl BlockfrostAPI { } pub async fn accounts_mirs( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/mirs", stake_address).as_str(), @@ -92,9 +80,7 @@ impl BlockfrostAPI { } pub async fn accounts_addresses( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/addresses", stake_address).as_str(), @@ -104,9 +90,7 @@ impl BlockfrostAPI { } pub async fn accounts_addresses_assets( - &self, - stake_address: &str, - pagination: Pagination, + &self, stake_address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/accounts/{}/addresses/assets", stake_address).as_str(), @@ -116,8 +100,7 @@ impl BlockfrostAPI { } pub async fn accounts_addresses_total( - &self, - stake_address: &str, + &self, stake_address: &str, ) -> BlockfrostResult { self.call_endpoint(format!("/accounts/{}/addresses/total", stake_address).as_str()) .await diff --git a/src/api/endpoints/addresses.rs b/src/api/endpoints/addresses.rs index 9f1934b..abfc8c5 100644 --- a/src/api/endpoints/addresses.rs +++ b/src/api/endpoints/addresses.rs @@ -14,8 +14,7 @@ impl BlockfrostAPI { } pub async fn addresses_extended( - &self, - address: &str, + &self, address: &str, ) -> BlockfrostResult { self.call_endpoint(format!("/addresses/{}/extended", address).as_str()) .await @@ -27,19 +26,14 @@ impl BlockfrostAPI { } pub async fn addresses_utxos( - &self, - address: &str, - pagination: Pagination, + &self, address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/addresses/{}/utxos", address).as_str(), pagination) .await } pub async fn addresses_utxos_asset( - &self, - address: &str, - asset: &str, - pagination: Pagination, + &self, address: &str, asset: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/addresses/{}/utxos/{}", address, asset).as_str(), @@ -49,9 +43,7 @@ impl BlockfrostAPI { } pub async fn addresses_transactions( - &self, - address: &str, - pagination: Pagination, + &self, address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/addresses/{}/transactions", address).as_str(), diff --git a/src/api/endpoints/assets.rs b/src/api/endpoints/assets.rs index 4fbd5d5..3972ce3 100644 --- a/src/api/endpoints/assets.rs +++ b/src/api/endpoints/assets.rs @@ -16,18 +16,14 @@ impl BlockfrostAPI { } pub async fn assets_history( - &self, - asset: &str, - pagination: Pagination, + &self, asset: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/assets/{}/history", asset).as_str(), pagination) .await } pub async fn assets_transactions( - &self, - asset: &str, - pagination: Pagination, + &self, asset: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/assets/{}/transactions", asset).as_str(), @@ -37,18 +33,14 @@ impl BlockfrostAPI { } pub async fn assets_addresses( - &self, - asset: &str, - pagination: Pagination, + &self, asset: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/assets/{}/addresses", asset).as_str(), pagination) .await } pub async fn assets_policy_by_id( - &self, - policy_id: &str, - pagination: Pagination, + &self, policy_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/assets/policy/{}", policy_id).as_str(), pagination) .await diff --git a/src/api/endpoints/blocks.rs b/src/api/endpoints/blocks.rs index 88eed2f..56ebafe 100644 --- a/src/api/endpoints/blocks.rs +++ b/src/api/endpoints/blocks.rs @@ -19,9 +19,7 @@ impl BlockfrostAPI { } pub async fn blocks_by_epoch_and_slot( - &self, - epoch_number: i32, - slot_number: i64, + &self, epoch_number: i32, slot_number: i64, ) -> BlockfrostResult { self.call_endpoint(format!("/blocks/epoch/{}/slot/{}", epoch_number, slot_number).as_str()) .await @@ -33,9 +31,7 @@ impl BlockfrostAPI { } pub async fn blocks_next( - &self, - hash_or_number: &str, - pagination: Pagination, + &self, hash_or_number: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/blocks/{}/next", hash_or_number).as_str(), @@ -45,9 +41,7 @@ impl BlockfrostAPI { } pub async fn blocks_previous( - &self, - hash_or_number: &str, - pagination: Pagination, + &self, hash_or_number: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/blocks/{}/previous", hash_or_number).as_str(), @@ -57,9 +51,7 @@ impl BlockfrostAPI { } pub async fn blocks_txs( - &self, - hash_or_number: &str, - pagination: Pagination, + &self, hash_or_number: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/blocks/{}/txs", hash_or_number).as_str(), @@ -69,9 +61,7 @@ impl BlockfrostAPI { } pub async fn blocks_affected_addresses( - &self, - hash_or_number: &str, - pagination: Pagination, + &self, hash_or_number: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/blocks/{}/addresses", hash_or_number).as_str(), diff --git a/src/api/endpoints/epochs.rs b/src/api/endpoints/epochs.rs index 2ba02e8..a88bd09 100644 --- a/src/api/endpoints/epochs.rs +++ b/src/api/endpoints/epochs.rs @@ -26,37 +26,28 @@ impl BlockfrostAPI { } pub async fn epochs_next( - &self, - number: i32, - pagination: Pagination, + &self, number: i32, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/epochs/{}/next", number).as_str(), pagination) .await } pub async fn epochs_previous( - &self, - number: i32, - pagination: Pagination, + &self, number: i32, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/epochs/{}/previous", number).as_str(), pagination) .await } pub async fn epochs_stakes( - &self, - number: i32, - pagination: Pagination, + &self, number: i32, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/epochs/{}/stakes", number).as_str(), pagination) .await } pub async fn epochs_stakes_by_pool( - &self, - number: i32, - pool_id: &str, - pagination: Pagination, + &self, number: i32, pool_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/epochs/{}/stakes/{}", number, pool_id).as_str(), @@ -71,9 +62,7 @@ impl BlockfrostAPI { } pub async fn epochs_blocks_by_pool( - &self, - number: i32, - pool_id: &str, + &self, number: i32, pool_id: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/epochs/{}/blocks/{}", number, pool_id).as_str()) .await diff --git a/src/api/endpoints/mempool.rs b/src/api/endpoints/mempool.rs index a96b2b8..387ff49 100644 --- a/src/api/endpoints/mempool.rs +++ b/src/api/endpoints/mempool.rs @@ -5,8 +5,7 @@ use blockfrost_openapi::models::{ impl BlockfrostAPI { pub async fn mempool( - &self, - pagination: Pagination, + &self, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint("/mempool", pagination).await } @@ -16,9 +15,7 @@ impl BlockfrostAPI { .await } pub async fn mempool_addresses_address( - &self, - address: &str, - pagination: Pagination, + &self, address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/mempool/addresses/{}", address).as_str(), diff --git a/src/api/endpoints/metadata.rs b/src/api/endpoints/metadata.rs index e298a06..c661cc8 100644 --- a/src/api/endpoints/metadata.rs +++ b/src/api/endpoints/metadata.rs @@ -8,8 +8,7 @@ use blockfrost_openapi::models::{ impl BlockfrostAPI { /// List of all used transaction metadata labels. pub async fn metadata_txs_labels( - &self, - pagination: Pagination, + &self, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint("/metadata/txs/labels", pagination) .await @@ -17,9 +16,7 @@ impl BlockfrostAPI { /// Transaction metadata per label (json). pub async fn metadata_txs_by_label( - &self, - label: &str, - pagination: Pagination, + &self, label: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/metadata/txs/labels/{}", label).as_str(), @@ -30,9 +27,7 @@ impl BlockfrostAPI { /// Transaction metadata per label (cbor). pub async fn metadata_txs_by_label_cbor( - &self, - label: &str, - pagination: Pagination, + &self, label: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/metadata/txs/labels/{}/cbor", label).as_str(), diff --git a/src/api/endpoints/metrics.rs b/src/api/endpoints/metrics.rs index dfcd062..693deea 100644 --- a/src/api/endpoints/metrics.rs +++ b/src/api/endpoints/metrics.rs @@ -9,8 +9,7 @@ impl BlockfrostAPI { } pub async fn metrics_endpoints( - &self, - pagination: Pagination, + &self, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint("/metrics/endpoints", pagination) .await diff --git a/src/api/endpoints/nutlink.rs b/src/api/endpoints/nutlink.rs index ddff7a4..8599a99 100644 --- a/src/api/endpoints/nutlink.rs +++ b/src/api/endpoints/nutlink.rs @@ -12,19 +12,14 @@ impl BlockfrostAPI { } pub async fn nutlink_address_tickers( - &self, - address: &str, - pagination: Pagination, + &self, address: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/nutlink/{}/tickers", address).as_str(), pagination) .await } pub async fn nutlink_address_ticker_by_id( - &self, - address: &str, - ticker: &str, - pagination: Pagination, + &self, address: &str, ticker: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/nutlink/{}/tickers/{}", address, ticker).as_str(), @@ -34,9 +29,7 @@ impl BlockfrostAPI { } pub async fn nutlink_ticker_by_id( - &self, - ticker: &str, - pagination: Pagination, + &self, ticker: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/nutlink/tickers/{}", ticker).as_str(), pagination) .await diff --git a/src/api/endpoints/pools.rs b/src/api/endpoints/pools.rs index 99960df..6732364 100644 --- a/src/api/endpoints/pools.rs +++ b/src/api/endpoints/pools.rs @@ -22,41 +22,34 @@ impl BlockfrostAPI { } pub async fn pools_retired( - &self, - pagination: Pagination, + &self, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint("/pools/retired", pagination).await } pub async fn pools_retiring( - &self, - pagination: Pagination, + &self, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint("/pools/retiring", pagination) .await } pub async fn pools_history( - &self, - pool_id: &str, - pagination: Pagination, + &self, pool_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/pools/{}/history", pool_id).as_str(), pagination) .await } pub async fn pools_relays( - &self, - pool_id: &str, + &self, pool_id: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/pools/{}/relays", pool_id).as_str()) .await } pub async fn pools_delegators( - &self, - pool_id: &str, - pagination: Pagination, + &self, pool_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/pools/{}/delegators", pool_id).as_str(), @@ -66,18 +59,14 @@ impl BlockfrostAPI { } pub async fn pools_blocks( - &self, - pool_id: &str, - pagination: Pagination, + &self, pool_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/pools/{}/blocks", pool_id).as_str(), pagination) .await } pub async fn pools_updates( - &self, - pool_id: &str, - pagination: Pagination, + &self, pool_id: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint(format!("/pools/{}/updates", pool_id).as_str(), pagination) .await diff --git a/src/api/endpoints/scripts.rs b/src/api/endpoints/scripts.rs index 52ea6e4..ad12553 100644 --- a/src/api/endpoints/scripts.rs +++ b/src/api/endpoints/scripts.rs @@ -24,9 +24,7 @@ impl BlockfrostAPI { } pub async fn scripts_redeemers( - &self, - script_hash: &str, - pagination: Pagination, + &self, script_hash: &str, pagination: Pagination, ) -> BlockfrostResult> { self.call_paged_endpoint( format!("/scripts/{}/redeemers", script_hash).as_str(), @@ -36,16 +34,14 @@ impl BlockfrostAPI { } pub async fn scripts_datum_hash( - &self, - datum_hash: &str, + &self, datum_hash: &str, ) -> BlockfrostResult { self.call_endpoint(format!("/scripts/datum/{}", datum_hash).as_str()) .await } pub async fn scripts_datum_hash_cbor( - &self, - datum_hash: &str, + &self, datum_hash: &str, ) -> BlockfrostResult { self.call_endpoint(format!("/scripts/{}/cbor", datum_hash).as_str()) .await diff --git a/src/api/endpoints/transactions.rs b/src/api/endpoints/transactions.rs index 242ab6f..d47fbda 100644 --- a/src/api/endpoints/transactions.rs +++ b/src/api/endpoints/transactions.rs @@ -43,8 +43,7 @@ impl BlockfrostAPI { } pub async fn transaction_by_hash( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult { self.call_endpoint(format!("/txs/{}", hash).as_str()).await } @@ -55,24 +54,21 @@ impl BlockfrostAPI { } pub async fn transactions_stakes( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/stakes", hash).as_str()) .await } pub async fn transactions_delegations( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/delegations", hash).as_str()) .await } pub async fn transactions_withdrawals( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/withdrawals", hash).as_str()) .await @@ -84,40 +80,35 @@ impl BlockfrostAPI { } pub async fn transactions_pool_updates( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/pool_updates", hash).as_str()) .await } pub async fn transactions_pool_retires( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/pool_retires", hash).as_str()) .await } pub async fn transactions_metadata( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/metadata", hash).as_str()) .await } pub async fn transactions_metadata_cbor( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/metadata/cbor", hash).as_str()) .await } pub async fn transactions_redeemers( - &self, - hash: &str, + &self, hash: &str, ) -> BlockfrostResult> { self.call_endpoint(format!("/txs/{}/redeemers", hash).as_str()) .await diff --git a/src/api/mod.rs b/src/api/mod.rs index 87fe3e6..cca3368 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -29,9 +29,7 @@ impl BlockfrostAPI { } pub fn new_with_client( - project_id: &str, - settings: BlockFrostSettings, - client_builder: ClientBuilder, + project_id: &str, settings: BlockFrostSettings, client_builder: ClientBuilder, ) -> reqwest::Result { let base_url = Url::get_base_url_from_project_id(project_id); @@ -55,9 +53,7 @@ impl BlockfrostAPI { } async fn call_paged_endpoint( - &self, - url_endpoint: &str, - pagination: Pagination, + &self, url_endpoint: &str, pagination: Pagination, ) -> Result, BlockfrostError> where T: for<'de> serde::Deserialize<'de> + serde::de::DeserializeOwned, diff --git a/src/error.rs b/src/error.rs index a972833..1d90fc4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -47,9 +47,7 @@ impl std::fmt::Display for ResponseError { // // This function can only return Error::ErrorResponse. pub(crate) fn process_error_response( - text: &str, - status_code: StatusCode, - url: &str, + text: &str, status_code: StatusCode, url: &str, ) -> BlockfrostError { let status_code = status_code.as_u16(); @@ -79,7 +77,7 @@ pub(crate) fn process_error_response( reason: http_error, url, } - }, + } } } @@ -101,9 +99,7 @@ pub(crate) fn reqwest_error(url: impl ToString, error: ReqwestError) -> Blockfro // Helper to create a Error::Json pub(crate) fn json_error( - url: impl ToString, - text: impl ToString, - error: SerdeJsonError, + url: impl ToString, text: impl ToString, error: SerdeJsonError, ) -> BlockfrostError { BlockfrostError::Json { url: url.to_string(), diff --git a/src/ipfs.rs b/src/ipfs.rs index 9de66a0..71ac565 100644 --- a/src/ipfs.rs +++ b/src/ipfs.rs @@ -59,9 +59,7 @@ impl BlockfrostIPFS { /// [`HeaderValue`]: reqwest::header::HeaderValue /// [`HeaderValue::from_str`]: reqwest::header::HeaderValue::from_str pub fn new_with_client( - project_id: impl AsRef, - settings: IpfsSettings, - client_builder: ClientBuilder, + project_id: impl AsRef, settings: IpfsSettings, client_builder: ClientBuilder, ) -> reqwest::Result { client_builder .default_headers(build_header_map(project_id.as_ref())) diff --git a/src/request.rs b/src/request.rs index 4d332ba..3c010fb 100644 --- a/src/request.rs +++ b/src/request.rs @@ -11,9 +11,7 @@ use std::{future::Future, thread}; // Used only for simple and common GET requests. // Functions that require extra logic may not call this. pub(crate) fn send_get_request( - client: &Client, - url: String, - retry_settings: RetrySettings, + client: &Client, url: String, retry_settings: RetrySettings, ) -> impl Future> + Send where T: serde::de::DeserializeOwned, @@ -35,8 +33,7 @@ where // Send requests with delayed retries, cloning the request builder only when necessary. pub(crate) async fn send_request_unprocessed( - request: RequestBuilder, - retry_settings: RetrySettings, + request: RequestBuilder, retry_settings: RetrySettings, ) -> reqwest::Result { for _ in 1..retry_settings.amount { let request = clone_request(&request); @@ -70,8 +67,7 @@ pub(crate) async fn send_request_unprocessed( // Calls send_request_unprocessed but break is down pub(crate) async fn send_request( - request: RequestBuilder, - retry_settings: RetrySettings, + request: RequestBuilder, retry_settings: RetrySettings, ) -> reqwest::Result<(StatusCode, String)> { let response = send_request_unprocessed(request, retry_settings).await?; let status = response.status(); @@ -88,10 +84,7 @@ fn clone_request(request: &RequestBuilder) -> RequestBuilder { } pub(crate) async fn fetch_all_pages( - client: &Client, - url: String, - retry_settings: RetrySettings, - pagination: Pagination, + client: &Client, url: String, retry_settings: RetrySettings, pagination: Pagination, ) -> Result, BlockfrostError> { const BATCH_SIZE: usize = 10; @@ -126,7 +119,7 @@ pub(crate) async fn fetch_all_pages( is_end = true; } result.extend(data); - }, + } Err(err) => return Err(err), } } diff --git a/src/url.rs b/src/url.rs index 569522b..934c756 100644 --- a/src/url.rs +++ b/src/url.rs @@ -15,9 +15,7 @@ impl Url { } pub fn from_paginated_endpoint( - base_url: &str, - endpoint_url: &str, - pagination: Pagination, + base_url: &str, endpoint_url: &str, pagination: Pagination, ) -> Result> { let mut url = Self::create_base_url(base_url, endpoint_url)?; let mut query_pairs = form_urlencoded::Serializer::new(String::new()); @@ -34,10 +32,7 @@ impl Url { } pub fn generate_batch( - url: &str, - batch_size: usize, - start: usize, - pagination: Pagination, + url: &str, batch_size: usize, start: usize, pagination: Pagination, ) -> Result, Box> { let mut result = Vec::new(); let mut url = UrlI::parse(url)?;