pub struct OwnerCreditBalance {
pub owner_id: Uuid,
pub building_id: Uuid,
pub credits_earned: i32,
pub credits_spent: i32,
pub balance: i32,
pub total_exchanges: i32,
pub average_rating: Option<f32>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Owner Credit Balance for Local Exchange Trading System (SEL)
Tracks time-based currency balance for each owner per building. Credits are earned by providing services and spent by receiving services.
Balance = credits_earned - credits_spent
Fields§
§owner_id: Uuid§building_id: Uuid§credits_earned: i32§credits_spent: i32§balance: i32§total_exchanges: i32§average_rating: Option<f32>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl OwnerCreditBalance
impl OwnerCreditBalance
Sourcepub fn new(owner_id: Uuid, building_id: Uuid) -> Self
pub fn new(owner_id: Uuid, building_id: Uuid) -> Self
Create a new credit balance (starts at 0)
Sourcepub fn earn_credits(&mut self, amount: i32) -> Result<(), String>
pub fn earn_credits(&mut self, amount: i32) -> Result<(), String>
Earn credits (when providing a service)
Sourcepub fn spend_credits(&mut self, amount: i32) -> Result<(), String>
pub fn spend_credits(&mut self, amount: i32) -> Result<(), String>
Spend credits (when receiving a service)
Sourcepub fn increment_exchanges(&mut self)
pub fn increment_exchanges(&mut self)
Increment exchange counter
Sourcepub fn has_sufficient_credits(&self, required: i32) -> bool
pub fn has_sufficient_credits(&self, required: i32) -> bool
Check if owner has sufficient credits (for systems that enforce limits)
Sourcepub fn credit_status(&self) -> CreditStatus
pub fn credit_status(&self) -> CreditStatus
Get credit status
Sourcepub fn is_new_member(&self) -> bool
pub fn is_new_member(&self) -> bool
Check if owner is a new member (no exchanges yet)
Sourcepub fn participation_level(&self) -> ParticipationLevel
pub fn participation_level(&self) -> ParticipationLevel
Get participation level
Trait Implementations§
Source§impl Clone for OwnerCreditBalance
impl Clone for OwnerCreditBalance
Source§fn clone(&self) -> OwnerCreditBalance
fn clone(&self) -> OwnerCreditBalance
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OwnerCreditBalance
impl Debug for OwnerCreditBalance
Source§impl<'de> Deserialize<'de> for OwnerCreditBalance
impl<'de> Deserialize<'de> for OwnerCreditBalance
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
Source§impl PartialEq for OwnerCreditBalance
impl PartialEq for OwnerCreditBalance
Source§impl Serialize for OwnerCreditBalance
impl Serialize for OwnerCreditBalance
impl StructuralPartialEq for OwnerCreditBalance
Auto Trait Implementations§
impl Freeze for OwnerCreditBalance
impl RefUnwindSafe for OwnerCreditBalance
impl Send for OwnerCreditBalance
impl Sync for OwnerCreditBalance
impl Unpin for OwnerCreditBalance
impl UnwindSafe for OwnerCreditBalance
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreCreates a shared type from an unshared type.