CategoryService

Struct CategoryService 

Source
pub struct CategoryService<'a> { /* private fields */ }
Expand description

Service for category management

Implementations§

Source§

impl<'a> CategoryService<'a>

Source

pub fn new(storage: &'a Storage) -> Self

Create a new category service

Source

pub fn create_group(&self, name: &str) -> EnvelopeResult<CategoryGroup>

Create a new category group

Source

pub fn get_group( &self, id: CategoryGroupId, ) -> EnvelopeResult<Option<CategoryGroup>>

Get a group by ID

Source

pub fn get_group_by_name( &self, name: &str, ) -> EnvelopeResult<Option<CategoryGroup>>

Get a group by name (case-insensitive)

Source

pub fn find_group( &self, identifier: &str, ) -> EnvelopeResult<Option<CategoryGroup>>

Find a group by name or ID string

Source

pub fn list_groups(&self) -> EnvelopeResult<Vec<CategoryGroup>>

List all groups

Source

pub fn list_groups_with_categories( &self, ) -> EnvelopeResult<Vec<CategoryGroupWithCategories>>

List all groups with their categories

Source

pub fn update_group( &self, id: CategoryGroupId, name: Option<&str>, ) -> EnvelopeResult<CategoryGroup>

Update a group’s name

Source

pub fn delete_group( &self, id: CategoryGroupId, force_delete_categories: bool, ) -> EnvelopeResult<()>

Delete a group

If the group has categories, they must be moved or deleted first unless force_delete_categories is true.

Automatically creates a backup before deletion if one hasn’t been created recently.

Source

pub fn reorder_groups(&self, order: &[CategoryGroupId]) -> EnvelopeResult<()>

Reorder groups

Source

pub fn create_category( &self, name: &str, group_id: CategoryGroupId, ) -> EnvelopeResult<Category>

Create a new category in a group

Source

pub fn get_category(&self, id: CategoryId) -> EnvelopeResult<Option<Category>>

Get a category by ID

Source

pub fn get_category_by_name( &self, name: &str, ) -> EnvelopeResult<Option<Category>>

Get a category by name (case-insensitive)

Source

pub fn find_category( &self, identifier: &str, ) -> EnvelopeResult<Option<Category>>

Find a category by name or ID string

Source

pub fn list_categories(&self) -> EnvelopeResult<Vec<Category>>

List all categories

Source

pub fn list_categories_in_group( &self, group_id: CategoryGroupId, ) -> EnvelopeResult<Vec<Category>>

List categories in a group

Source

pub fn update_category( &self, id: CategoryId, name: Option<&str>, goal: Option<i64>, clear_goal: bool, ) -> EnvelopeResult<Category>

Update a category

Source

pub fn move_category( &self, id: CategoryId, new_group_id: CategoryGroupId, ) -> EnvelopeResult<Category>

Move a category to a different group

Source

pub fn delete_category(&self, id: CategoryId) -> EnvelopeResult<()>

Delete a category

Automatically creates a backup before deletion if one hasn’t been created recently.

Source

pub fn reorder_categories( &self, group_id: CategoryGroupId, order: &[CategoryId], ) -> EnvelopeResult<()>

Reorder categories within a group

Auto Trait Implementations§

§

impl<'a> Freeze for CategoryService<'a>

§

impl<'a> RefUnwindSafe for CategoryService<'a>

§

impl<'a> Send for CategoryService<'a>

§

impl<'a> Sync for CategoryService<'a>

§

impl<'a> Unpin for CategoryService<'a>

§

impl<'a> UnwindSafe for CategoryService<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.