paystack/models/status_models.rs
1//! Status
2//! ===============
3//! This file contains the status options for the paystack API.
4
5use serde::{Deserialize, Serialize};
6use std::fmt;
7
8/// Represents the status of a transaction.
9///
10/// The `Status` enum defines the possible status values for a transaction,
11/// indicating whether the transaction was successful, abandoned, or failed.
12///
13/// # Variants
14///
15/// - `Success`: Represents a successful transaction.
16/// - `Abandoned`: Represents an abandoned transaction.
17/// - `Failed`: Represents a failed transaction.
18///
19/// # Examples
20///
21/// ```
22/// use paystack::Status;
23///
24/// let success_status = Status::Success;
25/// let abandoned_status = Status::Abandoned;
26/// let failed_status = Status::Failed;
27///
28/// println!("{:?}", success_status); // Prints: Success
29/// ```
30///
31/// The example demonstrates the usage of the `Status` enum, creating instances of each variant
32/// and printing their debug representation.
33#[derive(Debug, Serialize, Deserialize, Clone)]
34#[serde(rename_all = "lowercase")]
35pub enum Status {
36 /// A successful transaction.
37 Success,
38 /// An abandoned transaction.
39 Abandoned,
40 /// A failed transaction.
41 Failed,
42}
43
44impl fmt::Display for Status {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 let lowercase_string = match self {
47 Status::Success => "success",
48 Status::Abandoned => "abandoned",
49 Status::Failed => "failed",
50 };
51 write!(f, "{}", lowercase_string)
52 }
53}