fix: Remove warnings

This commit is contained in:
Mahmoud Emad
2025-05-18 09:48:28 +03:00
parent e4e403e231
commit 60198dc2d4
20 changed files with 1411 additions and 764 deletions

View File

@@ -112,6 +112,7 @@ pub struct Asset {
pub external_url: Option<String>,
}
#[allow(dead_code)]
impl Asset {
/// Creates a new asset
pub fn new(

View File

@@ -85,6 +85,7 @@ pub struct ContractSigner {
pub comments: Option<String>,
}
#[allow(dead_code)]
impl ContractSigner {
/// Creates a new contract signer
pub fn new(name: String, email: String) -> Self {
@@ -123,6 +124,7 @@ pub struct ContractRevision {
pub comments: Option<String>,
}
#[allow(dead_code)]
impl ContractRevision {
/// Creates a new contract revision
pub fn new(version: u32, content: String, created_by: String, comments: Option<String>) -> Self {
@@ -166,6 +168,7 @@ pub struct Contract {
pub toc: Option<Vec<TocItem>>,
}
#[allow(dead_code)]
impl Contract {
/// Creates a new contract
pub fn new(title: String, description: String, contract_type: ContractType, created_by: String, organization_id: Option<String>) -> Self {

View File

@@ -14,6 +14,7 @@ pub enum DefiPositionStatus {
Cancelled
}
#[allow(dead_code)]
impl DefiPositionStatus {
pub fn as_str(&self) -> &str {
match self {
@@ -35,6 +36,7 @@ pub enum DefiPositionType {
Collateral,
}
#[allow(dead_code)]
impl DefiPositionType {
pub fn as_str(&self) -> &str {
match self {
@@ -95,6 +97,7 @@ pub struct DefiDatabase {
receiving_positions: HashMap<String, ReceivingPosition>,
}
#[allow(dead_code)]
impl DefiDatabase {
pub fn new() -> Self {
Self {

View File

@@ -110,6 +110,7 @@ pub struct FlowStep {
pub logs: Vec<FlowLog>,
}
#[allow(dead_code)]
impl FlowStep {
/// Creates a new flow step
pub fn new(name: String, description: String, order: u32) -> Self {
@@ -189,6 +190,7 @@ pub struct FlowLog {
pub timestamp: DateTime<Utc>,
}
#[allow(dead_code)]
impl FlowLog {
/// Creates a new flow log
pub fn new(message: String) -> Self {
@@ -231,6 +233,7 @@ pub struct Flow {
pub current_step: Option<FlowStep>,
}
#[allow(dead_code)]
impl Flow {
/// Creates a new flow
pub fn new(name: &str, description: &str, flow_type: FlowType, owner_id: &str, owner_name: &str) -> Self {

View File

@@ -75,6 +75,7 @@ pub struct Proposal {
pub voting_ends_at: Option<DateTime<Utc>>,
}
#[allow(dead_code)]
impl Proposal {
/// Creates a new proposal
pub fn new(creator_id: i32, creator_name: String, title: String, description: String) -> Self {
@@ -140,6 +141,7 @@ pub struct Vote {
pub updated_at: DateTime<Utc>,
}
#[allow(dead_code)]
impl Vote {
/// Creates a new vote
pub fn new(proposal_id: String, voter_id: i32, voter_name: String, vote_type: VoteType, comment: Option<String>) -> Self {
@@ -200,6 +202,7 @@ pub struct VotingResults {
pub total_votes: usize,
}
#[allow(dead_code)]
impl VotingResults {
/// Creates a new empty voting results object
pub fn new(proposal_id: String) -> Self {

View File

@@ -1,7 +1,7 @@
use crate::models::asset::AssetType;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::models::asset::{Asset, AssetType};
/// Status of a marketplace listing
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -12,6 +12,7 @@ pub enum ListingStatus {
Expired,
}
#[allow(dead_code)]
impl ListingStatus {
pub fn as_str(&self) -> &str {
match self {
@@ -63,6 +64,7 @@ pub enum BidStatus {
Cancelled,
}
#[allow(dead_code)]
impl BidStatus {
pub fn as_str(&self) -> &str {
match self {
@@ -103,6 +105,7 @@ pub struct Listing {
pub image_url: Option<String>,
}
#[allow(dead_code)]
impl Listing {
/// Creates a new listing
pub fn new(
@@ -150,7 +153,13 @@ impl Listing {
}
/// Adds a bid to the listing
pub fn add_bid(&mut self, bidder_id: String, bidder_name: String, amount: f64, currency: String) -> Result<(), String> {
pub fn add_bid(
&mut self,
bidder_id: String,
bidder_name: String,
amount: f64,
currency: String,
) -> Result<(), String> {
if self.status != ListingStatus::Active {
return Err("Listing is not active".to_string());
}
@@ -160,7 +169,10 @@ impl Listing {
}
if currency != self.currency {
return Err(format!("Currency mismatch: expected {}, got {}", self.currency, currency));
return Err(format!(
"Currency mismatch: expected {}, got {}",
self.currency, currency
));
}
// Check if bid amount is higher than current highest bid or starting price
@@ -193,13 +205,19 @@ impl Listing {
/// Gets the highest bid on the listing
pub fn highest_bid(&self) -> Option<&Bid> {
self.bids.iter()
self.bids
.iter()
.filter(|b| b.status == BidStatus::Active)
.max_by(|a, b| a.amount.partial_cmp(&b.amount).unwrap())
}
/// Marks the listing as sold
pub fn mark_as_sold(&mut self, buyer_id: String, buyer_name: String, sale_price: f64) -> Result<(), String> {
pub fn mark_as_sold(
&mut self,
buyer_id: String,
buyer_name: String,
sale_price: f64,
) -> Result<(), String> {
if self.status != ListingStatus::Active {
return Err("Listing is not active".to_string());
}
@@ -257,11 +275,13 @@ impl MarketplaceStatistics {
let mut listings_by_type = std::collections::HashMap::new();
let mut sales_by_asset_type = std::collections::HashMap::new();
let active_listings = listings.iter()
let active_listings = listings
.iter()
.filter(|l| l.status == ListingStatus::Active)
.count();
let sold_listings = listings.iter()
let sold_listings = listings
.iter()
.filter(|l| l.status == ListingStatus::Sold)
.count();

View File

@@ -1,17 +1,16 @@
// Export models
pub mod user;
pub mod ticket;
pub mod calendar;
pub mod governance;
pub mod flow;
pub mod contract;
pub mod asset;
pub mod marketplace;
pub mod calendar;
pub mod contract;
pub mod defi;
pub mod flow;
pub mod governance;
pub mod marketplace;
pub mod ticket;
pub mod user;
// Re-export models for easier imports
pub use user::User;
pub use ticket::{Ticket, TicketComment, TicketStatus, TicketPriority};
pub use calendar::{CalendarEvent, CalendarViewMode};
pub use marketplace::{Listing, ListingStatus, ListingType, Bid, BidStatus, MarketplaceStatistics};
pub use defi::{DefiPosition, DefiPositionType, DefiPositionStatus, ProvidingPosition, ReceivingPosition, DEFI_DB, initialize_mock_data};
pub use defi::initialize_mock_data;
pub use ticket::{Ticket, TicketComment, TicketPriority, TicketStatus};
pub use user::User;

View File

@@ -76,6 +76,7 @@ pub struct Ticket {
pub assigned_to: Option<i32>,
}
#[allow(dead_code)]
impl Ticket {
/// Creates a new ticket
pub fn new(user_id: i32, title: String, description: String, priority: TicketPriority) -> Self {

View File

@@ -4,6 +4,7 @@ use bcrypt::{hash, verify, DEFAULT_COST};
/// Represents a user in the system
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(dead_code)]
pub struct User {
/// Unique identifier for the user
pub id: Option<i32>,
@@ -31,6 +32,7 @@ pub enum UserRole {
Admin,
}
#[allow(dead_code)]
impl User {
/// Creates a new user with default values
pub fn new(name: String, email: String) -> Self {
@@ -125,6 +127,7 @@ impl User {
/// Represents user login credentials
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
pub struct LoginCredentials {
pub email: String,
pub password: String,
@@ -132,6 +135,7 @@ pub struct LoginCredentials {
/// Represents user registration data
#[derive(Debug, Deserialize)]
#[allow(dead_code)]
pub struct RegistrationData {
pub name: String,
pub email: String,