fix: resolve all remaining clippy warnings in examples and benchmarks including unused imports, variables, empty println statements, and enum naming conventions

This commit is contained in:
floor-licker
2025-12-04 07:37:40 -05:00
parent 3742a5b864
commit 88f116511c
20 changed files with 63 additions and 63 deletions
+18 -18
View File
@@ -202,7 +202,7 @@ impl ClobClient {
/// Get order book for a token
pub async fn get_order_book(&self, token_id: &str) -> Result<OrderBookSummary> {
let response = self.http_client
.get(&format!("{}/book", self.base_url))
.get(format!("{}/book", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await?;
@@ -218,7 +218,7 @@ impl ClobClient {
/// Get midpoint for a token
pub async fn get_midpoint(&self, token_id: &str) -> Result<MidpointResponse> {
let response = self.http_client
.get(&format!("{}/midpoint", self.base_url))
.get(format!("{}/midpoint", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await?;
@@ -234,7 +234,7 @@ impl ClobClient {
/// Get spread for a token
pub async fn get_spread(&self, token_id: &str) -> Result<SpreadResponse> {
let response = self.http_client
.get(&format!("{}/spread", self.base_url))
.get(format!("{}/spread", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await?;
@@ -259,7 +259,7 @@ impl ClobClient {
.collect();
let response = self.http_client
.post(&format!("{}/spreads", self.base_url))
.post(format!("{}/spreads", self.base_url))
.json(&request_data)
.send()
.await?;
@@ -275,7 +275,7 @@ impl ClobClient {
/// Get price for a token and side
pub async fn get_price(&self, token_id: &str, side: Side) -> Result<PriceResponse> {
let response = self.http_client
.get(&format!("{}/price", self.base_url))
.get(format!("{}/price", self.base_url))
.query(&[
("token_id", token_id),
("side", side.as_str()),
@@ -294,7 +294,7 @@ impl ClobClient {
/// Get tick size for a token
pub async fn get_tick_size(&self, token_id: &str) -> Result<Decimal> {
let response = self.http_client
.get(&format!("{}/tick-size", self.base_url))
.get(format!("{}/tick-size", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await?;
@@ -413,7 +413,7 @@ impl ClobClient {
/// Get neg risk for a token
pub async fn get_neg_risk(&self, token_id: &str) -> Result<bool> {
let response = self.http_client
.get(&format!("{}/neg-risk", self.base_url))
.get(format!("{}/neg-risk", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await?;
@@ -877,7 +877,7 @@ impl ClobClient {
.collect();
let response = self.http_client
.post(&format!("{}/midpoints", self.base_url))
.post(format!("{}/midpoints", self.base_url))
.json(&request_data)
.send()
.await?;
@@ -909,7 +909,7 @@ impl ClobClient {
.collect();
let response = self.http_client
.post(&format!("{}/prices", self.base_url))
.post(format!("{}/prices", self.base_url))
.json(&request_data)
.send()
.await?;
@@ -934,7 +934,7 @@ impl ClobClient {
.collect();
let response = self.http_client
.post(&format!("{}/books", self.base_url))
.post(format!("{}/books", self.base_url))
.json(&request_data)
.send()
.await
@@ -969,7 +969,7 @@ impl ClobClient {
/// Get last trade price for a token
pub async fn get_last_trade_price(&self, token_id: &str) -> Result<Value> {
let response = self.http_client
.get(&format!("{}/last-trade-price", self.base_url))
.get(format!("{}/last-trade-price", self.base_url))
.query(&[("token_id", token_id)])
.send()
.await
@@ -991,7 +991,7 @@ impl ClobClient {
.collect();
let response = self.http_client
.post(&format!("{}/last-trades-prices", self.base_url))
.post(format!("{}/last-trades-prices", self.base_url))
.json(&request_data)
.send()
.await
@@ -1140,7 +1140,7 @@ impl ClobClient {
let next_cursor = next_cursor.unwrap_or("MA=="); // INITIAL_CURSOR
let response = self.http_client
.get(&format!("{}/sampling-markets", self.base_url))
.get(format!("{}/sampling-markets", self.base_url))
.query(&[("next_cursor", next_cursor)])
.send()
.await
@@ -1155,7 +1155,7 @@ impl ClobClient {
let next_cursor = next_cursor.unwrap_or("MA=="); // INITIAL_CURSOR
let response = self.http_client
.get(&format!("{}/sampling-simplified-markets", self.base_url))
.get(format!("{}/sampling-simplified-markets", self.base_url))
.query(&[("next_cursor", next_cursor)])
.send()
.await
@@ -1170,7 +1170,7 @@ impl ClobClient {
let next_cursor = next_cursor.unwrap_or("MA=="); // INITIAL_CURSOR
let response = self.http_client
.get(&format!("{}/markets", self.base_url))
.get(format!("{}/markets", self.base_url))
.query(&[("next_cursor", next_cursor)])
.send()
.await
@@ -1185,7 +1185,7 @@ impl ClobClient {
let next_cursor = next_cursor.unwrap_or("MA=="); // INITIAL_CURSOR
let response = self.http_client
.get(&format!("{}/simplified-markets", self.base_url))
.get(format!("{}/simplified-markets", self.base_url))
.query(&[("next_cursor", next_cursor)])
.send()
.await
@@ -1198,7 +1198,7 @@ impl ClobClient {
/// Get single market by condition ID
pub async fn get_market(&self, condition_id: &str) -> Result<crate::types::Market> {
let response = self.http_client
.get(&format!("{}/markets/{}", self.base_url, condition_id))
.get(format!("{}/markets/{}", self.base_url, condition_id))
.send()
.await
.map_err(|e| PolyfillError::network(format!("Request failed: {}", e), e))?;
@@ -1210,7 +1210,7 @@ impl ClobClient {
/// Get market trades events
pub async fn get_market_trades_events(&self, condition_id: &str) -> Result<Value> {
let response = self.http_client
.get(&format!("{}/live-activity/events/{}", self.base_url, condition_id))
.get(format!("{}/live-activity/events/{}", self.base_url, condition_id))
.send()
.await
.map_err(|e| PolyfillError::network(format!("Request failed: {}", e), e))?;
+1 -1
View File
@@ -409,7 +409,7 @@ impl FillProcessor {
// Add to pending fills
self.pending_fills
.entry(fill.order_id.clone())
.or_insert_with(Vec::new)
.or_default()
.push(fill.clone());
// Move to processed if complete
+1 -1
View File
@@ -13,7 +13,7 @@ pub async fn prewarm_connections(client: &Client, base_url: &str) -> Result<(),
for endpoint in endpoints {
let _ = client
.get(&format!("{}{}", base_url, endpoint))
.get(format!("{}{}", base_url, endpoint))
.timeout(Duration::from_millis(1000))
.send()
.await;
+13
View File
@@ -432,6 +432,12 @@ pub struct MockStream {
connected: bool,
}
impl Default for MockStream {
fn default() -> Self {
Self::new()
}
}
impl MockStream {
pub fn new() -> Self {
Self {
@@ -494,12 +500,19 @@ impl MarketStream for MockStream {
}
/// Stream manager for handling multiple streams
#[allow(dead_code)]
pub struct StreamManager {
streams: Vec<Box<dyn MarketStream>>,
message_tx: mpsc::UnboundedSender<StreamMessage>,
message_rx: mpsc::UnboundedReceiver<StreamMessage>,
}
impl Default for StreamManager {
fn default() -> Self {
Self::new()
}
}
impl StreamManager {
pub fn new() -> Self {
let (message_tx, message_rx) = mpsc::unbounded_channel();
+8 -15
View File
@@ -185,6 +185,7 @@ pub fn is_price_tick_aligned(decimal: Decimal, tick_size_decimal: Decimal) -> bo
/// Trading side for orders
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[allow(clippy::upper_case_acronyms)]
pub enum Side {
BUY = 0,
SELL = 1,
@@ -208,6 +209,7 @@ impl Side {
/// Order type specifications
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[allow(clippy::upper_case_acronyms)]
pub enum OrderType {
GTC,
FOK,
@@ -480,7 +482,7 @@ pub struct Order {
}
/// API credentials for authentication
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ApiCredentials {
#[serde(rename = "apiKey")]
pub api_key: String,
@@ -488,16 +490,6 @@ pub struct ApiCredentials {
pub passphrase: String,
}
impl Default for ApiCredentials {
fn default() -> Self {
Self {
api_key: String::new(),
secret: String::new(),
passphrase: String::new(),
}
}
}
/// Configuration for order creation
#[derive(Debug, Clone)]
pub struct OrderOptions {
@@ -905,16 +897,17 @@ impl BalanceAllowanceParams {
}
/// Asset type enum for balance allowance queries
#[allow(clippy::upper_case_acronyms)]
pub enum AssetType {
COLLATERAL,
CONDITIONAL,
}
impl ToString for AssetType {
fn to_string(&self) -> String {
impl std::fmt::Display for AssetType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AssetType::COLLATERAL => "COLLATERAL".to_string(),
AssetType::CONDITIONAL => "CONDITIONAL".to_string(),
AssetType::COLLATERAL => write!(f, "COLLATERAL"),
AssetType::CONDITIONAL => write!(f, "CONDITIONAL"),
}
}
}
+2 -2
View File
@@ -67,7 +67,7 @@ pub mod time {
#[inline]
pub fn secs_to_datetime(timestamp: u64) -> DateTime<Utc> {
DateTime::from_timestamp(timestamp as i64, 0)
.unwrap_or_else(|| Utc::now())
.unwrap_or_else(Utc::now)
}
}
@@ -392,7 +392,7 @@ pub mod retry {
}
}
Err(last_error.unwrap_or_else(|| PolyfillError::internal("Retry loop failed", std::io::Error::new(std::io::ErrorKind::Other, "No error captured"))))
Err(last_error.unwrap_or_else(|| PolyfillError::internal("Retry loop failed", std::io::Error::other("No error captured"))))
}
}