pub fn unpack_uninitialized(input: &'data mut [u8]) -> Result<Self, ProgramError> {
        check_min_len_and_not_multisig(input, S::LEN)?;
        let (base_data, rest) = input.split_at_mut(S::LEN);
        let base = S::unpack_unchecked(base_data)?;
        if base.is_initialized() {
            return Err(TokenError::AlreadyInUse.into());
        }
        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)?;
            if account_type != AccountType::Uninitialized {
                return Err(ProgramError::InvalidAccountData);
            }
            let (account_type, tlv_data) = rest.split_at_mut(tlv_start_index);
            let state = Self {
                base,
                base_data,
                account_type: &mut account_type[account_type_index..tlv_start_index],
                tlv_data,
            };
            if let Some(extension_type) = state.get_first_extension_type()? {
                let account_type = extension_type.get_account_type();
                if account_type != S::ACCOUNT_TYPE {
                    return Err(TokenError::ExtensionBaseMismatch.into());
                }
            }
            Ok(state)
        } else {
            Ok(Self {
                base,
                base_data,
                account_type: &mut [],
                tlv_data: &mut [],
            })
        }
    }
/// Unpack an uninitialized base state, leaving the extension data as a mutable slice
///
/// Fails if the base state has already been initialized.
Unpack an uninitialized base state, leaving the extension data as a mutable slice
Fails if the base state has already been initialized.
Unpack an uninitialized base state leaving the extension data as a mutable slice Fails if the base state has already been initialized .
pub fn unpack_uninitialized(input: &'data mut [u8]) -> Result<Self, ProgramError> {
        check_min_len_and_not_multisig(input, S::LEN)?;
        let (base_data, rest) = input.split_at_mut(S::LEN);
        let base = S::unpack_unchecked(base_data)?;
        if base.is_initialized() {
            return Err(TokenError::AlreadyInUse.into());
        }
        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)?;
            if account_type != AccountType::Uninitialized {
                return Err(ProgramError::InvalidAccountData);
            }
            let (account_type, tlv_data) = rest.split_at_mut(tlv_start_index);
            let state = Self {
                base,
                base_data,
                account_type: &mut account_type[account_type_index..tlv_start_index],
                tlv_data,
            };
            if let Some(extension_type) = state.get_first_extension_type()? {
                let account_type = extension_type.get_account_type();
                if account_type != S::ACCOUNT_TYPE {
                    return Err(TokenError::ExtensionBaseMismatch.into());
                }
            }
            Ok(state)
        } else {
            Ok(Self {
                base,
                base_data,
                account_type: &mut [],
                tlv_data: &mut [],
            })
        }
    }
pub fn unpack_uninitialized ( input : & ' data mut [ u8 ] ) -> Result < Self , ProgramError > { check_min_len_and_not_multisig ( input , S :: LEN ) ? ; let ( base_data , rest ) = input . split_at_mut ( S :: LEN ) ; let base = S :: unpack_unchecked ( base_data ) ? ; if base . is_initialized ( ) { return Err ( TokenError :: AlreadyInUse . into ( ) ) ; } 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 ) ? ; if account_type != AccountType :: Uninitialized { return Err ( ProgramError :: InvalidAccountData ) ; } let ( account_type , tlv_data ) = rest . split_at_mut ( tlv_start_index ) ; let state = Self { base , base_data , account_type : & mut account_type [ account_type_index .. tlv_start_index ] , tlv_data , } ; if let Some ( extension_type ) = state . get_first_extension_type ( ) ? { let account_type = extension_type . get_account_type ( ) ; if account_type != S :: ACCOUNT_TYPE { return Err ( TokenError :: ExtensionBaseMismatch . into ( ) ) ; } } Ok ( state ) } else { Ok ( Self { base , base_data , account_type : & mut [ ] , tlv_data : & mut [ ] , } ) } }
Unpack an uninitialized base state, leaving the extension data as a mutable slice
Fails if the base state has already been initialized.
Unpack an uninitialized base state leaving the extension data as a mutable slice Fails if the base state has already been initialized .
input
&'data mut [u8]
input
&'data mut [u8]