1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
mod cast;
mod tally;
mod tx;

use crate::controller::{Error, UserInteractionController};
use cast::CastVote;
use clap::Parser;
use tally::VoteTally;
use tx::SendTransaction;

#[derive(Parser, Debug)]
pub enum Send {
    /// Sends transaction
    Tx(SendTransaction),
    /// Tally the vote
    Tally(VoteTally),
    /// Send the vote
    Vote(CastVote),
}

impl Send {
    pub fn exec(&self, controller: &mut UserInteractionController) -> Result<(), Error> {
        match self {
            Send::Tx(transaction) => transaction.exec(controller),
            Send::Tally(vote_tally) => vote_tally.exec(controller),
            Send::Vote(cast_vote) => cast_vote.exec(controller),
        }
    }
}