pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
        let (&tag, rest) = input
            .split_first()
            .ok_or(LendingError::InstructionUnpackError)?;
        Ok(match tag {
            0 => {
                let (market_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::InitLendingMarket { market_owner }
            }
            1 => {
                let (liquidity_amount, rest) = Self::unpack_u64(rest)?;
                let (optimal_utilization_rate, rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, rest) = Self::unpack_u8(rest)?;
                let (liquidation_bonus, rest) = Self::unpack_u8(rest)?;
                let (liquidation_threshold, rest) = Self::unpack_u8(rest)?;
                let (min_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (optimal_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (max_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (borrow_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (host_fee_percentage, _rest) = Self::unpack_u8(rest)?;
                Self::InitReserve {
                    liquidity_amount,
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            host_fee_percentage,
                        },
                    },
                }
            }
            2 => Self::InitObligation,
            3 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidity { liquidity_amount }
            }
            4 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawReserveLiquidity { collateral_amount }
            }
            5 => {
                let (amount, rest) = Self::unpack_u64(rest)?;
                let (amount_type, _rest) = Self::unpack_u8(rest)?;
                let amount_type = BorrowAmountType::from_u8(amount_type)
                    .ok_or(LendingError::InstructionUnpackError)?;
                Self::BorrowReserveLiquidity {
                    amount,
                    amount_type,
                }
            }
            6 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RepayReserveLiquidity { liquidity_amount }
            }
            7 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::LiquidateObligation { liquidity_amount }
            }
            8 => Self::AccrueReserveInterest,
            9 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositObligationCollateral { collateral_amount }
            }
            10 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateral { collateral_amount }
            }
            11 => {
                let (new_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::SetLendingMarketOwner { new_owner }
            }
            _ => return Err(LendingError::InstructionUnpackError.into()),
        })
    }
/// Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [ LendingInstruction ] ( enum . LendingInstruction . html ) .
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
        let (&tag, rest) = input
            .split_first()
            .ok_or(LendingError::InstructionUnpackError)?;
        Ok(match tag {
            0 => {
                let (market_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::InitLendingMarket { market_owner }
            }
            1 => {
                let (liquidity_amount, rest) = Self::unpack_u64(rest)?;
                let (optimal_utilization_rate, rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, rest) = Self::unpack_u8(rest)?;
                let (liquidation_bonus, rest) = Self::unpack_u8(rest)?;
                let (liquidation_threshold, rest) = Self::unpack_u8(rest)?;
                let (min_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (optimal_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (max_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (borrow_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (host_fee_percentage, _rest) = Self::unpack_u8(rest)?;
                Self::InitReserve {
                    liquidity_amount,
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            host_fee_percentage,
                        },
                    },
                }
            }
            2 => Self::InitObligation,
            3 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidity { liquidity_amount }
            }
            4 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawReserveLiquidity { collateral_amount }
            }
            5 => {
                let (amount, rest) = Self::unpack_u64(rest)?;
                let (amount_type, _rest) = Self::unpack_u8(rest)?;
                let amount_type = BorrowAmountType::from_u8(amount_type)
                    .ok_or(LendingError::InstructionUnpackError)?;
                Self::BorrowReserveLiquidity {
                    amount,
                    amount_type,
                }
            }
            6 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RepayReserveLiquidity { liquidity_amount }
            }
            7 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::LiquidateObligation { liquidity_amount }
            }
            8 => Self::AccrueReserveInterest,
            9 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositObligationCollateral { collateral_amount }
            }
            10 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateral { collateral_amount }
            }
            11 => {
                let (new_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::SetLendingMarketOwner { new_owner }
            }
            _ => return Err(LendingError::InstructionUnpackError.into()),
        })
    }
pub fn unpack ( input : & [ u8 ] ) -> Result < Self , ProgramError > { let ( & tag , rest ) = input . split_first ( ) . ok_or ( LendingError :: InstructionUnpackError ) ? ; Ok ( match tag { 0 => { let ( market_owner , _rest ) = Self :: unpack_pubkey ( rest ) ? ; Self :: InitLendingMarket { market_owner } } 1 => { let ( liquidity_amount , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( optimal_utilization_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( loan_to_value_ratio , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( liquidation_bonus , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( liquidation_threshold , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( min_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( optimal_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( max_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( borrow_fee_wad , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( host_fee_percentage , _rest ) = Self :: unpack_u8 ( rest ) ? ; Self :: InitReserve { liquidity_amount , config : ReserveConfig { optimal_utilization_rate , loan_to_value_ratio , liquidation_bonus , liquidation_threshold , min_borrow_rate , optimal_borrow_rate , max_borrow_rate , fees : ReserveFees { borrow_fee_wad , host_fee_percentage , } , } , } } 2 => Self :: InitObligation , 3 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: DepositReserveLiquidity { liquidity_amount } } 4 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: WithdrawReserveLiquidity { collateral_amount } } 5 => { let ( amount , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( amount_type , _rest ) = Self :: unpack_u8 ( rest ) ? ; let amount_type = BorrowAmountType :: from_u8 ( amount_type ) . ok_or ( LendingError :: InstructionUnpackError ) ? ; Self :: BorrowReserveLiquidity { amount , amount_type , } } 6 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: RepayReserveLiquidity { liquidity_amount } } 7 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: LiquidateObligation { liquidity_amount } } 8 => Self :: AccrueReserveInterest , 9 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: DepositObligationCollateral { collateral_amount } } 10 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: WithdrawObligationCollateral { collateral_amount } } 11 => { let ( new_owner , _rest ) = Self :: unpack_pubkey ( rest ) ? ; Self :: SetLendingMarketOwner { new_owner } } _ => return Err ( LendingError :: InstructionUnpackError . into ( ) ) , } ) }
Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [ LendingInstruction ] ( enum . LendingInstruction . html ) .
input
&[u8]