pub trait PortfolioRepository: Send + Sync {
// Required methods
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Portfolio>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_for_user<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Portfolio>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
is_favorite: bool,
) -> Pin<Box<dyn Future<Output = Result<PortfolioBuilding, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn remove_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_buildings<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<PortfolioBuildingEntry>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn share_with<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
shared_with_user_id: Uuid,
can_edit: bool,
) -> Pin<Box<dyn Future<Output = Result<PortfolioShare, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn unshare<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
shared_with_user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_shares<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<PortfolioShare>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Port repository Portfolio.
Required Methods§
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persiste un nouveau portfolio. Retourne l’entité telle que stockée.
Sourcefn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Portfolio>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Portfolio>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Récupère par id. None si absent (pas une erreur).
Sourcefn list_for_user<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Portfolio>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_for_user<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Portfolio>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Liste les portfolios dont user_id est owner_user_id ou
figure dans portfolio_shares. Tri : created_at DESC.
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
portfolio: &'life1 Portfolio,
) -> Pin<Box<dyn Future<Output = Result<Portfolio, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Met à jour un portfolio existant. Retourne AppError::NotFound
si aucune ligne affectée.
Sourcefn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Supprime un portfolio (DELETE physique — cascade sur
portfolio_buildings et portfolio_shares).
Sourcefn add_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
is_favorite: bool,
) -> Pin<Box<dyn Future<Output = Result<PortfolioBuilding, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
is_favorite: bool,
) -> Pin<Box<dyn Future<Output = Result<PortfolioBuilding, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Ajoute (ou remplace) un building dans le portfolio.
Idempotent : un ON CONFLICT (portfolio_id, building_id) DO UPDATE
rafraîchit is_favorite si la ligne existe déjà.
Sourcefn remove_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove_building<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
building_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retire un building du portfolio. AppError::NotFound si aucune
ligne supprimée.
Sourcefn list_buildings<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<PortfolioBuildingEntry>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_buildings<'life0, 'async_trait>(
&'life0 self,
portfolio_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<PortfolioBuildingEntry>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Liste les buildings d’un portfolio.
Tri stable : favoris d’abord (is_favorite DESC) puis
added_at DESC (cf. AC @happy Story 2.1).
Partage le portfolio avec un autre user.
Idempotent : ON CONFLICT (portfolio_id, shared_with_user_id) DO UPDATE
rafraîchit can_edit.
Retire un partage. AppError::NotFound si aucune ligne supprimée.
Liste les partages d’un portfolio.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".