/// attempt to apply the vote to one of the proposals
///
/// If the given identifier already had a vote, the previous vote will
/// be discarded and only the new one will be kept.
///
/// # errors
///
/// * this function may fail if the proposal identifier is different
/// * if the proposal index is not one one of the proposal listed
/// * if the block_date show it is no longer valid to cast a vote for any
///   of the managed proposals
/// * if the payload type of the vote is not the expected one
///
attempt to apply the vote to one of the proposals
If the given identifier already had a vote, the previous vote will
be discarded and only the new one will be kept.
attempt to apply the vote to one of the proposals If the given identifier already had a vote the previous vote will be discarded and only the new one will be kept .
pub fn vote(
        &self,
        block_date: BlockDate,
        identifier: UnspecifiedAccountIdentifier,
        cast: VoteCast,
    ) -> Result<Self, VoteError> {
        if cast.vote_plan() != self.id() {
            Err(VoteError::InvalidVotePlan {
                expected: self.id().clone(),
                vote: cast,
            })
        } else if !self.can_vote(block_date) {
            Err(VoteError::VoteTimeElapsed {
                start: self.plan().vote_start(),
                end: self.plan().vote_end(),
                vote: cast,
            })
        } else if self.plan().payload_type() != cast.payload().payload_type() {
            Err(VoteError::InvalidPayloadType {
                expected: self.plan().payload_type(),
                received: cast.payload().payload_type(),
            })
        } else {
            let proposal_managers = self.proposal_managers.vote(identifier, cast)?;
            Ok(Self {
                proposal_managers,
                plan: Arc::clone(&self.plan),
                id: self.id.clone(),
            })
        }
    }
pub fn vote ( & self , block_date : BlockDate , identifier : UnspecifiedAccountIdentifier , cast : VoteCast , ) -> Result < Self , VoteError > { if cast . vote_plan ( ) != self . id ( ) { Err ( VoteError :: InvalidVotePlan { expected : self . id ( ) . clone ( ) , vote : cast , } ) } else if ! self . can_vote ( block_date ) { Err ( VoteError :: VoteTimeElapsed { start : self . plan ( ) . vote_start ( ) , end : self . plan ( ) . vote_end ( ) , vote : cast , } ) } else if self . plan ( ) . payload_type ( ) != cast . payload ( ) . payload_type ( ) { Err ( VoteError :: InvalidPayloadType { expected : self . plan ( ) . payload_type ( ) , received : cast . payload ( ) . payload_type ( ) , } ) } else { let proposal_managers = self . proposal_managers . vote ( identifier , cast ) ? ; Ok ( Self { proposal_managers , plan : Arc :: clone ( & self . plan ) , id : self . id . clone ( ) , } ) } }
attempt to apply the vote to one of the proposals
If the given identifier already had a vote, the previous vote will
be discarded and only the new one will be kept.
attempt to apply the vote to one of the proposals If the given identifier already had a vote the previous vote will be discarded and only the new one will be kept .
&self
block_date
BlockDate
identifier
UnspecifiedAccountIdentifier
cast
VoteCast
errors
this function may fail if the proposal identifier is different
if the proposal index is not one one of the proposal listed
if the block_date show it is no longer valid to cast a vote for any
of the managed proposals
if the payload type of the vote is not the expected one
this function may fail if the proposal identifier is different if the proposal index is not one one of the proposal listed if the block_date show it is no longer valid to cast a vote for any of the managed proposals if the payload type of the vote is not the expected one