pub fn serialize<W: Write>(self, writer: &mut W) -> Result<(), ProgramError> {
        if self.account_type == GovernanceAccountType::VoteRecordV2 {
            BorshSerialize::serialize(&self, writer)?
        } else if self.account_type == GovernanceAccountType::VoteRecordV1 {
            // V1 account can't be resized and we have to translate it back to the original format

            // If reserved_v2 is used it must be individually asses for v1 backward compatibility impact
            if self.reserved_v2 != [0; 8] {
                panic!("Extended data not supported by VoteRecordV1")
            }

            let vote_weight = match &self.vote {
                Vote::Approve(_options) => VoteWeightV1::Yes(self.voter_weight),
                Vote::Deny => VoteWeightV1::No(self.voter_weight),
                Vote::Abstain | Vote::Veto => {
                    panic!("Vote type: {:?} not supported by VoteRecordV1", &self.vote)
                }
            };

            let vote_record_data_v1 = VoteRecordV1 {
                account_type: self.account_type,
                proposal: self.proposal,
                governing_token_owner: self.governing_token_owner,
                is_relinquished: self.is_relinquished,
                vote_weight,
            };

            BorshSerialize::serialize(&vote_record_data_v1, writer)?;
        }

        Ok(())
    }
/// Serializes account into the target buffer
Serializes account into the target buffer
Serializes account into the target buffer
pub fn serialize<W: Write>(self, writer: &mut W) -> Result<(), ProgramError> {
        if self.account_type == GovernanceAccountType::VoteRecordV2 {
            BorshSerialize::serialize(&self, writer)?
        } else if self.account_type == GovernanceAccountType::VoteRecordV1 {
            // V1 account can't be resized and we have to translate it back to the original format
            // If reserved_v2 is used it must be individually asses for v1 backward compatibility impact
            if self.reserved_v2 != [0; 8] {
                panic!("Extended data not supported by VoteRecordV1")
            }
            let vote_weight = match &self.vote {
                Vote::Approve(_options) => VoteWeightV1::Yes(self.voter_weight),
                Vote::Deny => VoteWeightV1::No(self.voter_weight),
                Vote::Abstain | Vote::Veto => {
                    panic!("Vote type: {:?} not supported by VoteRecordV1", &self.vote)
                }
            };
            let vote_record_data_v1 = VoteRecordV1 {
                account_type: self.account_type,
                proposal: self.proposal,
                governing_token_owner: self.governing_token_owner,
                is_relinquished: self.is_relinquished,
                vote_weight,
            };
            BorshSerialize::serialize(&vote_record_data_v1, writer)?;
        }
        Ok(())
    }
pub fn serialize < W : Write > ( self , writer : & mut W ) -> Result < ( ) , ProgramError > { if self . account_type == GovernanceAccountType :: VoteRecordV2 { BorshSerialize :: serialize ( & self , writer ) ? } else if self . account_type == GovernanceAccountType :: VoteRecordV1 { // V1 account can't be resized and we have to translate it back to the original format // If reserved_v2 is used it must be individually asses for v1 backward compatibility impact if self . reserved_v2 != [ 0 ; 8 ] { panic ! ( " " ) } let vote_weight = match & self . vote { Vote :: Approve ( _options ) => VoteWeightV1 :: Yes ( self . voter_weight ) , Vote :: Deny => VoteWeightV1 :: No ( self . voter_weight ) , Vote :: Abstain | Vote :: Veto => { panic ! ( " " self vote ) } } ; let vote_record_data_v1 = VoteRecordV1 { account_type : self . account_type , proposal : self . proposal , governing_token_owner : self . governing_token_owner , is_relinquished : self . is_relinquished , vote_weight , } ; BorshSerialize :: serialize ( & vote_record_data_v1 , writer ) ? ; } Ok ( ( ) ) }
Serializes account into the target buffer
Serializes account into the target buffer
self
writer
&mut W
self
writer
&mut W