pub fn unpack(mut input: Vec<u8>) -> Result<Self, ProgramError> {
        check_min_len_and_not_multisig(&input, S::LEN)?;
        let mut rest = input.split_off(S::LEN);
        let base = S::unpack(&input)?;
        if let Some((account_type_index, tlv_start_index)) = type_and_tlv_indices::<S>(&rest)? {
            // type_and_tlv_indices() checks that returned indexes are within range
            let account_type = AccountType::try_from(rest[account_type_index])
                .map_err(|_| ProgramError::InvalidAccountData)?;
            check_account_type::<S>(account_type)?;
            let tlv_data = rest.split_off(tlv_start_index);
            Ok(Self { base, tlv_data })
        } else {
            Ok(Self {
                base,
                tlv_data: vec![],
            })
        }
    }
/// Unpack base state, leaving the extension data as a slice
///
/// Fails if the base state is not initialized.
Unpack base state, leaving the extension data as a slice
Fails if the base state is not initialized.
Unpack base state leaving the extension data as a slice Fails if the base state is not initialized .
pub fn unpack(mut input: Vec<u8>) -> Result<Self, ProgramError> {
        check_min_len_and_not_multisig(&input, S::LEN)?;
        let mut rest = input.split_off(S::LEN);
        let base = S::unpack(&input)?;
        if let Some((account_type_index, tlv_start_index)) = type_and_tlv_indices::<S>(&rest)? {
            // type_and_tlv_indices() checks that returned indexes are within range
            let account_type = AccountType::try_from(rest[account_type_index])
                .map_err(|_| ProgramError::InvalidAccountData)?;
            check_account_type::<S>(account_type)?;
            let tlv_data = rest.split_off(tlv_start_index);
            Ok(Self { base, tlv_data })
        } else {
            Ok(Self {
                base,
                tlv_data: vec![],
            })
        }
    }
pub fn unpack ( mut input : Vec < u8 > ) -> Result < Self , ProgramError > { check_min_len_and_not_multisig ( & input , S :: LEN ) ? ; let mut rest = input . split_off ( S :: LEN ) ; let base = S :: unpack ( & input ) ? ; if let Some ( ( account_type_index , tlv_start_index ) ) = type_and_tlv_indices :: < S > ( & rest ) ? { // type_and_tlv_indices() checks that returned indexes are within range let account_type = AccountType :: try_from ( rest [ account_type_index ] ) . map_err ( | _ | ProgramError :: InvalidAccountData ) ? ; check_account_type :: < S > ( account_type ) ? ; let tlv_data = rest . split_off ( tlv_start_index ) ; Ok ( Self { base , tlv_data } ) } else { Ok ( Self { base , tlv_data : vec ! [ ] , } ) } }
Unpack base state, leaving the extension data as a slice
Fails if the base state is not initialized.
Unpack base state leaving the extension data as a slice Fails if the base state is not initialized .
input
Vec<u8>
input
Vec<u8>