#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Role {
Follower,
Candidate,
Leader,
}
impl Role {
pub const fn is_leader(self) -> bool {
matches!(self, Self::Leader)
}
pub const fn is_follower(self) -> bool {
matches!(self, Self::Follower)
}
pub const fn is_candidate(self) -> bool {
matches!(self, Self::Candidate)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn role_is() {
assert!(Role::Leader.is_leader());
assert!(Role::Follower.is_follower());
assert!(Role::Candidate.is_candidate());
}
}