pub struct SharedObject {Show 19 fields
pub id: Uuid,
pub owner_id: Uuid,
pub building_id: Uuid,
pub object_category: SharedObjectCategory,
pub object_name: String,
pub description: String,
pub condition: ObjectCondition,
pub is_available: bool,
pub rental_credits_per_day: Option<i32>,
pub deposit_credits: Option<i32>,
pub borrowing_duration_days: Option<i32>,
pub current_borrower_id: Option<Uuid>,
pub borrowed_at: Option<DateTime<Utc>>,
pub due_back_at: Option<DateTime<Utc>>,
pub photos: Option<Vec<String>>,
pub location_details: Option<String>,
pub usage_instructions: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Shared object for community equipment sharing
Represents an object that a building resident can lend to other members. Integrates with SEL (Local Exchange Trading System) for optional credit-based rental.
§Business Rules
- object_name must be 3-100 characters
- description max 1000 characters
- rental_credits_per_day: 0-20 (0 = free, reasonable daily rate)
- deposit_credits: 0-100 (security deposit)
- borrowing_duration_days: 1-90 (max borrowing period)
- Only owner can update/delete object
- Only available objects can be borrowed
- Borrower must return object before borrowing another from same owner
Fields§
§id: Uuid§owner_id: Uuid§building_id: Uuid§object_category: SharedObjectCategory§object_name: String§description: String§condition: ObjectCondition§is_available: bool§rental_credits_per_day: Option<i32>Rental rate in SEL credits per day (0 = free, None = not specified)
deposit_credits: Option<i32>Security deposit in SEL credits (refunded on return)
borrowing_duration_days: Option<i32>Maximum borrowing duration in days (1-90)
current_borrower_id: Option<Uuid>Current borrower (if borrowed)
borrowed_at: Option<DateTime<Utc>>When object was borrowed
due_back_at: Option<DateTime<Utc>>When object is due back
photos: Option<Vec<String>>Photo URLs (optional)
location_details: Option<String>Pickup location details (optional)
usage_instructions: Option<String>Usage instructions (optional)
created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Sourcepub fn new(
owner_id: Uuid,
building_id: Uuid,
object_category: SharedObjectCategory,
object_name: String,
description: String,
condition: ObjectCondition,
is_available: bool,
rental_credits_per_day: Option<i32>,
deposit_credits: Option<i32>,
borrowing_duration_days: Option<i32>,
photos: Option<Vec<String>>,
location_details: Option<String>,
usage_instructions: Option<String>,
) -> Result<Self, String>
pub fn new( owner_id: Uuid, building_id: Uuid, object_category: SharedObjectCategory, object_name: String, description: String, condition: ObjectCondition, is_available: bool, rental_credits_per_day: Option<i32>, deposit_credits: Option<i32>, borrowing_duration_days: Option<i32>, photos: Option<Vec<String>>, location_details: Option<String>, usage_instructions: Option<String>, ) -> Result<Self, String>
Create a new shared object
§Validation
- object_name: 3-100 characters
- description: max 1000 characters
- rental_credits_per_day: 0-20 if provided
- deposit_credits: 0-100 if provided
- borrowing_duration_days: 1-90 if provided
Sourcepub fn update(
&mut self,
object_name: Option<String>,
description: Option<String>,
condition: Option<ObjectCondition>,
is_available: Option<bool>,
rental_credits_per_day: Option<Option<i32>>,
deposit_credits: Option<Option<i32>>,
borrowing_duration_days: Option<Option<i32>>,
photos: Option<Option<Vec<String>>>,
location_details: Option<Option<String>>,
usage_instructions: Option<Option<String>>,
) -> Result<(), String>
pub fn update( &mut self, object_name: Option<String>, description: Option<String>, condition: Option<ObjectCondition>, is_available: Option<bool>, rental_credits_per_day: Option<Option<i32>>, deposit_credits: Option<Option<i32>>, borrowing_duration_days: Option<Option<i32>>, photos: Option<Option<Vec<String>>>, location_details: Option<Option<String>>, usage_instructions: Option<Option<String>>, ) -> Result<(), String>
Update shared object information
§Validation
- Same validation rules as new()
- Cannot update if currently borrowed
Sourcepub fn mark_available(&mut self) -> Result<(), String>
pub fn mark_available(&mut self) -> Result<(), String>
Mark object as available for borrowing
Mark object as unavailable for borrowing
Sourcepub fn borrow(
&mut self,
borrower_id: Uuid,
duration_days: Option<i32>,
) -> Result<(), String>
pub fn borrow( &mut self, borrower_id: Uuid, duration_days: Option<i32>, ) -> Result<(), String>
Sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Check if object is currently borrowed
Sourcepub fn is_overdue(&self) -> bool
pub fn is_overdue(&self) -> bool
Check if object is overdue
Sourcepub fn calculate_total_cost(&self) -> (i32, i32)
pub fn calculate_total_cost(&self) -> (i32, i32)
Calculate total rental cost for actual borrowing period
Returns (rental_cost, deposit)
Sourcepub fn days_overdue(&self) -> i32
pub fn days_overdue(&self) -> i32
Calculate days overdue
Trait Implementations§
Source§fn clone(&self) -> SharedObject
fn clone(&self) -> SharedObject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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>,
Auto Trait Implementations§
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
§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>
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>
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