pub fn serialize<W: Write>(self, writer: &mut W) -> Result<(), ProgramError> {
        if self.account_type == GovernanceAccountType::TokenOwnerRecordV2 {
            BorshSerialize::serialize(&self, writer)?
        } else if self.account_type == GovernanceAccountType::TokenOwnerRecordV1 {
            // 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; 128] {
                panic!("Extended data not supported by TokenOwnerRecordV1")
            }

            let token_owner_record_data_v1 = TokenOwnerRecordV1 {
                account_type: self.account_type,
                realm: self.realm,
                governing_token_mint: self.governing_token_mint,
                governing_token_owner: self.governing_token_owner,
                governing_token_deposit_amount: self.governing_token_deposit_amount,
                unrelinquished_votes_count: self.unrelinquished_votes_count,
                total_votes_count: self.total_votes_count,
                outstanding_proposal_count: self.outstanding_proposal_count,
                reserved: self.reserved,
                governance_delegate: self.governance_delegate,
            };

            BorshSerialize::serialize(&token_owner_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::TokenOwnerRecordV2 {
            BorshSerialize::serialize(&self, writer)?
        } else if self.account_type == GovernanceAccountType::TokenOwnerRecordV1 {
            // 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; 128] {
                panic!("Extended data not supported by TokenOwnerRecordV1")
            }
            let token_owner_record_data_v1 = TokenOwnerRecordV1 {
                account_type: self.account_type,
                realm: self.realm,
                governing_token_mint: self.governing_token_mint,
                governing_token_owner: self.governing_token_owner,
                governing_token_deposit_amount: self.governing_token_deposit_amount,
                unrelinquished_votes_count: self.unrelinquished_votes_count,
                total_votes_count: self.total_votes_count,
                outstanding_proposal_count: self.outstanding_proposal_count,
                reserved: self.reserved,
                governance_delegate: self.governance_delegate,
            };
            BorshSerialize::serialize(&token_owner_record_data_v1, writer)?;
        }
        Ok(())
    }
pub fn serialize < W : Write > ( self , writer : & mut W ) -> Result < ( ) , ProgramError > { if self . account_type == GovernanceAccountType :: TokenOwnerRecordV2 { BorshSerialize :: serialize ( & self , writer ) ? } else if self . account_type == GovernanceAccountType :: TokenOwnerRecordV1 { // 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 ; 128 ] { panic ! ( " " ) } let token_owner_record_data_v1 = TokenOwnerRecordV1 { account_type : self . account_type , realm : self . realm , governing_token_mint : self . governing_token_mint , governing_token_owner : self . governing_token_owner , governing_token_deposit_amount : self . governing_token_deposit_amount , unrelinquished_votes_count : self . unrelinquished_votes_count , total_votes_count : self . total_votes_count , outstanding_proposal_count : self . outstanding_proposal_count , reserved : self . reserved , governance_delegate : self . governance_delegate , } ; BorshSerialize :: serialize ( & token_owner_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