[][src]Trait wybr::tally::Tally

pub trait Tally: Sized {
    fn get_meta(&self) -> &Metadata;
fn get_candidates(&self) -> u32; fn get_seats(&self) -> u32 { ... }
fn name_candidate(&self, id: u32) -> Option<&String> { ... }
fn map_withdrawn<F: FnMut(u32)>(&self, f: F) { ... }
fn from_blt_file(name: &str) -> Result<Self, VoteReadError>
    where
        Result<Self, VoteReadError>: FromIterator<VoteToken>
, { ... } }

Generic trait for tallied ballot data

Tally is a junction between ballot data parsers and election methods. It exists because some methods require only a beat table, so candidates^2 integers (VoteMatrix), while other the counts for all possible ballot contents (VoteTree).

On the other side, you can built given tally by collecting from iterator of vote tokens, use debug constructors of either implementers, or simply use from_blt_file to read from a *.blt file.

Required methods

fn get_meta(&self) -> &Metadata

Returns a copy of metadata

fn get_candidates(&self) -> u32

Returns the number of candidates

Loading content...

Provided methods

fn get_seats(&self) -> u32

Return a number of seats

fn name_candidate(&self, id: u32) -> Option<&String>

Get the name of a candidate from metadata

fn map_withdrawn<F: FnMut(u32)>(&self, f: F)

Map over IDs of withdrawn candidates

fn from_blt_file(name: &str) -> Result<Self, VoteReadError> where
    Result<Self, VoteReadError>: FromIterator<VoteToken>, 

Loading content...

Implementors

impl Tally for VoteMatrix[src]

fn get_seats(&self) -> u32[src]

fn name_candidate(&self, id: u32) -> Option<&String>[src]

fn map_withdrawn<F: FnMut(u32)>(&self, f: F)[src]

fn from_blt_file(name: &str) -> Result<Self, VoteReadError> where
    Result<Self, VoteReadError>: FromIterator<VoteToken>, 
[src]

impl Tally for VoteTree[src]

fn get_seats(&self) -> u32[src]

fn name_candidate(&self, id: u32) -> Option<&String>[src]

fn map_withdrawn<F: FnMut(u32)>(&self, f: F)[src]

fn from_blt_file(name: &str) -> Result<Self, VoteReadError> where
    Result<Self, VoteReadError>: FromIterator<VoteToken>, 
[src]

Loading content...