pub struct BudgetRepository { /* private fields */ }Expand description
Repository for budget allocation persistence
Implementations§
Source§impl BudgetRepository
impl BudgetRepository
Sourcepub fn load(&self) -> Result<(), EnvelopeError>
pub fn load(&self) -> Result<(), EnvelopeError>
Load allocations from disk
Sourcepub fn save(&self) -> Result<(), EnvelopeError>
pub fn save(&self) -> Result<(), EnvelopeError>
Save allocations to disk
Sourcepub fn get(
&self,
category_id: CategoryId,
period: &BudgetPeriod,
) -> Result<Option<BudgetAllocation>, EnvelopeError>
pub fn get( &self, category_id: CategoryId, period: &BudgetPeriod, ) -> Result<Option<BudgetAllocation>, EnvelopeError>
Get an allocation for a category and period
Sourcepub fn get_or_default(
&self,
category_id: CategoryId,
period: &BudgetPeriod,
) -> Result<BudgetAllocation, EnvelopeError>
pub fn get_or_default( &self, category_id: CategoryId, period: &BudgetPeriod, ) -> Result<BudgetAllocation, EnvelopeError>
Get or create an allocation (returns default if not found)
Sourcepub fn get_for_period(
&self,
period: &BudgetPeriod,
) -> Result<Vec<BudgetAllocation>, EnvelopeError>
pub fn get_for_period( &self, period: &BudgetPeriod, ) -> Result<Vec<BudgetAllocation>, EnvelopeError>
Get all allocations for a period
Sourcepub fn get_for_category(
&self,
category_id: CategoryId,
) -> Result<Vec<BudgetAllocation>, EnvelopeError>
pub fn get_for_category( &self, category_id: CategoryId, ) -> Result<Vec<BudgetAllocation>, EnvelopeError>
Get all allocations for a category
Sourcepub fn upsert(&self, allocation: BudgetAllocation) -> Result<(), EnvelopeError>
pub fn upsert(&self, allocation: BudgetAllocation) -> Result<(), EnvelopeError>
Insert or update an allocation
Sourcepub fn delete(
&self,
category_id: CategoryId,
period: &BudgetPeriod,
) -> Result<bool, EnvelopeError>
pub fn delete( &self, category_id: CategoryId, period: &BudgetPeriod, ) -> Result<bool, EnvelopeError>
Delete an allocation
Sourcepub fn delete_for_category(
&self,
category_id: CategoryId,
) -> Result<usize, EnvelopeError>
pub fn delete_for_category( &self, category_id: CategoryId, ) -> Result<usize, EnvelopeError>
Delete all allocations for a category
Sourcepub fn count(&self) -> Result<usize, EnvelopeError>
pub fn count(&self) -> Result<usize, EnvelopeError>
Count allocations
Sourcepub fn get_all(&self) -> Result<Vec<BudgetAllocation>, EnvelopeError>
pub fn get_all(&self) -> Result<Vec<BudgetAllocation>, EnvelopeError>
Get all allocations
Auto Trait Implementations§
impl !Freeze for BudgetRepository
impl RefUnwindSafe for BudgetRepository
impl Send for BudgetRepository
impl Sync for BudgetRepository
impl Unpin for BudgetRepository
impl UnwindSafe for BudgetRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more