| Crates.io | promotion_kit |
| lib.rs | promotion_kit |
| version | 0.1.1 |
| created_at | 2025-05-18 12:53:25.621615+00 |
| updated_at | 2025-05-31 12:13:43.522641+00 |
| description | A powerful Rust toolkit for managing dynamic promotions with flexible rules and seamless integration. |
| homepage | |
| repository | https://github.com/jerry-maheswara-github/promotion_kit |
| max_upload_size | |
| id | 1678631 |
| size | 36,225 |
A powerful Rust toolkit for managing dynamic promotions with flexible rules and seamless integration.
This crate provides a lightweight and extensible toolkit for managing promotions, vouchers, and discounts in any transactional system, such as e-commerce, SaaS, digital products, or other service platforms.
use promotion_kit::promotion::{Promotion, DiscountType, TargetScope};
use promotion_kit::service::apply_promotion;
fn main() {
let promo = Promotion {
code: "WELCOME10".into(),
description: "10% off for new users".into(),
discount: DiscountType::Percentage(10.0),
usage_limit: Some(100),
used: 0,
valid_from: 1_700_000_000,
valid_until: 1_800_000_000,
min_transaction: Some(100.0),
target: TargetScope::Global,
currency: Some("IDR".to_string()),
};
let discount = apply_promotion(&promo, 200.0, 1_750_000_000).unwrap();
assert_eq!(discount, 20.0);
}
Licensed under the Apache-2.0 license
Jerry Maheswara jerrymaheswara@gmail.com
This project is built with ❤️ using Rust — a systems programming language that is safe, fast, and concurrent.
Rust is the perfect choice for building reliable and efficient applications.
Pull requests, issues, and feedback are welcome!
If you find this crate useful, give it a ⭐ and share it with others in the Rustacean community.