pub fn withdraw_with_threshold(
        &mut self,
        cycles: Cycles,
        threshold: Cycles,
    ) -> Result<(), CyclesAccountError> {
        let cycles_available = if self.cycles_balance() > threshold {
            self.cycles_balance() - threshold
        } else {
            Cycles::from(0)
        };

        if cycles > cycles_available {
            return Err(CyclesAccountError::CanisterOutOfCycles {
                available: cycles_available,
                requested: cycles,
            });
        }

        self.cycles_balance -= cycles;
        Ok(())
    }
/// Subtracts `cycles` worth of cycles from the canister's balance as long
/// as there's enough above the provided `threshold`. This call should be
/// used when the withdrawn cycles are sent somewhere else.
Subtracts `cycles` worth of cycles from the canister's balance as long
as there's enough above the provided `threshold`. This call should be
used when the withdrawn cycles are sent somewhere else.
Subtracts ` cycles ` worth of cycles from the canister ' s balance as long as there ' s enough above the provided ` threshold ` . This call should be used when the withdrawn cycles are sent somewhere else .
pub fn withdraw_with_threshold(
        &mut self,
        cycles: Cycles,
        threshold: Cycles,
    ) -> Result<(), CyclesAccountError> {
        let cycles_available = if self.cycles_balance() > threshold {
            self.cycles_balance() - threshold
        } else {
            Cycles::from(0)
        };
        if cycles > cycles_available {
            return Err(CyclesAccountError::CanisterOutOfCycles {
                available: cycles_available,
                requested: cycles,
            });
        }
        self.cycles_balance -= cycles;
        Ok(())
    }
pub fn withdraw_with_threshold ( & mut self , cycles : Cycles , threshold : Cycles , ) -> Result < ( ) , CyclesAccountError > { let cycles_available = if self . cycles_balance ( ) > threshold { self . cycles_balance ( ) - threshold } else { Cycles :: from ( 0 ) } ; if cycles > cycles_available { return Err ( CyclesAccountError :: CanisterOutOfCycles { available : cycles_available , requested : cycles , } ) ; } self . cycles_balance -= cycles ; Ok ( ( ) ) }
Subtracts `cycles` worth of cycles from the canister's balance as long
as there's enough above the provided `threshold`.
Subtracts ` cycles ` worth of cycles from the canister ' s balance as long as there ' s enough above the provided ` threshold ` .
&mut self
cycles
Cycles
threshold
Cycles
&mut self
cycles
Cycles
threshold
Cycles