Example #1
0
// Min sets a new minimum balance. Returns true for success, false for incompatible unit
// or in case the min is more than the current balance.
func (h *Resource) Min(min us.Quantity) bool {
	if !us.AreCompatible(h.balance, min) || us.More(min, h.balance) {
		return false
	}
	h.min = min
	return true
}
Example #2
0
func (h *Resource) outOfBounds(q us.Quantity) bool {
	return us.Less(q, h.min) || us.More(q, h.max)
}