pub struct Category {
pub id: CategoryId,
pub name: String,
pub group_id: CategoryGroupId,
pub sort_order: i32,
pub hidden: bool,
pub goal_amount: Option<i64>,
pub notes: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
A budget category within a group
Fields§
§id: CategoryIdUnique identifier
name: StringCategory name
group_id: CategoryGroupIdThe group this category belongs to
sort_order: i32Sort order within the group
Whether this category is hidden
goal_amount: Option<i64>Goal amount per period (optional)
notes: StringNotes about this category
created_at: DateTime<Utc>When the category was created
updated_at: DateTime<Utc>When the category was last modified
Implementations§
Source§impl Category
impl Category
Sourcepub fn new(name: impl Into<String>, group_id: CategoryGroupId) -> Self
pub fn new(name: impl Into<String>, group_id: CategoryGroupId) -> Self
Create a new category
Sourcepub fn with_sort_order(
name: impl Into<String>,
group_id: CategoryGroupId,
sort_order: i32,
) -> Self
pub fn with_sort_order( name: impl Into<String>, group_id: CategoryGroupId, sort_order: i32, ) -> Self
Create a new category with a specific sort order
Sourcepub fn clear_goal(&mut self)
pub fn clear_goal(&mut self)
Clear the goal
Sourcepub fn move_to_group(&mut self, group_id: CategoryGroupId)
pub fn move_to_group(&mut self, group_id: CategoryGroupId)
Move to a different group
Sourcepub fn validate(&self) -> Result<(), CategoryValidationError>
pub fn validate(&self) -> Result<(), CategoryValidationError>
Validate the category
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Category
impl<'de> Deserialize<'de> for Category
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Category
impl RefUnwindSafe for Category
impl Send for Category
impl Sync for Category
impl Unpin for Category
impl UnwindSafe for Category
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more