1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::bid_escrow::job_offer::AuctionState;
use crate::rules::validation::Validation;
use crate::utils::Error;
use macros::Rule;

/// Verifies if the [`Job Offer`](crate::bid_escrow::job_offer::JobOffer) can be canceled
/// in the given state. May return [Error::JobOfferCannotBeYetCanceled].
#[derive(Rule)]
pub struct CanJobOfferBeCancelled {
    auction_state: AuctionState,
}

impl Validation for CanJobOfferBeCancelled {
    fn validate(&self) -> Result<(), Error> {
        if self.auction_state != AuctionState::None {
            return Err(Error::JobOfferCannotBeYetCanceled);
        }

        Ok(())
    }
}