pub struct LocalExchangeUseCases { /* private fields */ }Expand description
Use cases for Local Exchange Trading System (SEL)
Implementations§
Source§impl LocalExchangeUseCases
impl LocalExchangeUseCases
pub fn new( exchange_repo: Arc<dyn LocalExchangeRepository>, balance_repo: Arc<dyn OwnerCreditBalanceRepository>, owner_repo: Arc<dyn OwnerRepository>, ) -> Self
Sourcepub async fn create_exchange(
&self,
provider_id: Uuid,
dto: CreateLocalExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn create_exchange( &self, provider_id: Uuid, dto: CreateLocalExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Create a new exchange offer
Sourcepub async fn get_exchange(
&self,
id: Uuid,
) -> Result<LocalExchangeResponseDto, String>
pub async fn get_exchange( &self, id: Uuid, ) -> Result<LocalExchangeResponseDto, String>
Get exchange by ID
Sourcepub async fn list_building_exchanges(
&self,
building_id: Uuid,
) -> Result<Vec<LocalExchangeResponseDto>, String>
pub async fn list_building_exchanges( &self, building_id: Uuid, ) -> Result<Vec<LocalExchangeResponseDto>, String>
List all exchanges for a building
Sourcepub async fn list_available_exchanges(
&self,
building_id: Uuid,
) -> Result<Vec<LocalExchangeResponseDto>, String>
pub async fn list_available_exchanges( &self, building_id: Uuid, ) -> Result<Vec<LocalExchangeResponseDto>, String>
List available exchanges (status = Offered)
Sourcepub async fn list_owner_exchanges(
&self,
owner_id: Uuid,
) -> Result<Vec<LocalExchangeResponseDto>, String>
pub async fn list_owner_exchanges( &self, owner_id: Uuid, ) -> Result<Vec<LocalExchangeResponseDto>, String>
List exchanges by owner (as provider OR requester)
Sourcepub async fn list_exchanges_by_type(
&self,
building_id: Uuid,
exchange_type: ExchangeType,
) -> Result<Vec<LocalExchangeResponseDto>, String>
pub async fn list_exchanges_by_type( &self, building_id: Uuid, exchange_type: ExchangeType, ) -> Result<Vec<LocalExchangeResponseDto>, String>
List exchanges by type
Sourcepub async fn request_exchange(
&self,
exchange_id: Uuid,
requester_id: Uuid,
_dto: RequestExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn request_exchange( &self, exchange_id: Uuid, requester_id: Uuid, _dto: RequestExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Request an exchange (transition: Offered → Requested)
Sourcepub async fn start_exchange(
&self,
exchange_id: Uuid,
actor_id: Uuid,
) -> Result<LocalExchangeResponseDto, String>
pub async fn start_exchange( &self, exchange_id: Uuid, actor_id: Uuid, ) -> Result<LocalExchangeResponseDto, String>
Start an exchange (transition: Requested → InProgress) Only provider can start
Sourcepub async fn complete_exchange(
&self,
exchange_id: Uuid,
actor_id: Uuid,
_dto: CompleteExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn complete_exchange( &self, exchange_id: Uuid, actor_id: Uuid, _dto: CompleteExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Complete an exchange (transition: InProgress → Completed) Updates credit balances for both parties
Sourcepub async fn cancel_exchange(
&self,
exchange_id: Uuid,
actor_id: Uuid,
dto: CancelExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn cancel_exchange( &self, exchange_id: Uuid, actor_id: Uuid, dto: CancelExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Cancel an exchange
Sourcepub async fn rate_provider(
&self,
exchange_id: Uuid,
requester_id: Uuid,
dto: RateExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn rate_provider( &self, exchange_id: Uuid, requester_id: Uuid, dto: RateExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Rate the provider (by requester)
Sourcepub async fn rate_requester(
&self,
exchange_id: Uuid,
provider_id: Uuid,
dto: RateExchangeDto,
) -> Result<LocalExchangeResponseDto, String>
pub async fn rate_requester( &self, exchange_id: Uuid, provider_id: Uuid, dto: RateExchangeDto, ) -> Result<LocalExchangeResponseDto, String>
Rate the requester (by provider)
Sourcepub async fn delete_exchange(
&self,
exchange_id: Uuid,
actor_id: Uuid,
) -> Result<(), String>
pub async fn delete_exchange( &self, exchange_id: Uuid, actor_id: Uuid, ) -> Result<(), String>
Delete an exchange (only if not completed)
Sourcepub async fn get_credit_balance(
&self,
owner_id: Uuid,
building_id: Uuid,
) -> Result<OwnerCreditBalanceDto, String>
pub async fn get_credit_balance( &self, owner_id: Uuid, building_id: Uuid, ) -> Result<OwnerCreditBalanceDto, String>
Get credit balance for an owner in a building
Sourcepub async fn get_leaderboard(
&self,
building_id: Uuid,
limit: i32,
) -> Result<Vec<OwnerCreditBalanceDto>, String>
pub async fn get_leaderboard( &self, building_id: Uuid, limit: i32, ) -> Result<Vec<OwnerCreditBalanceDto>, String>
Get leaderboard (top contributors)
Sourcepub async fn get_statistics(
&self,
building_id: Uuid,
) -> Result<SelStatisticsDto, String>
pub async fn get_statistics( &self, building_id: Uuid, ) -> Result<SelStatisticsDto, String>
Get SEL statistics for a building
Sourcepub async fn get_owner_summary(
&self,
owner_id: Uuid,
) -> Result<OwnerExchangeSummaryDto, String>
pub async fn get_owner_summary( &self, owner_id: Uuid, ) -> Result<OwnerExchangeSummaryDto, String>
Get owner exchange summary
Auto Trait Implementations§
impl Freeze for LocalExchangeUseCases
impl !RefUnwindSafe for LocalExchangeUseCases
impl Send for LocalExchangeUseCases
impl Sync for LocalExchangeUseCases
impl Unpin for LocalExchangeUseCases
impl !UnwindSafe for LocalExchangeUseCases
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
§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.