EnergyCampaignRepository

Trait EnergyCampaignRepository 

Source
pub trait EnergyCampaignRepository: Send + Sync {
    // Required methods
    fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        campaign: &'life1 EnergyCampaign,
    ) -> Pin<Box<dyn Future<Output = Result<EnergyCampaign, String>> + 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<EnergyCampaign>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_by_organization<'life0, 'async_trait>(
        &'life0 self,
        organization_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EnergyCampaign>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_by_building<'life0, 'async_trait>(
        &'life0 self,
        building_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EnergyCampaign>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        campaign: &'life1 EnergyCampaign,
    ) -> Pin<Box<dyn Future<Output = Result<EnergyCampaign, String>> + 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<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_offer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        campaign_id: Uuid,
        offer: &'life1 ProviderOffer,
    ) -> Pin<Box<dyn Future<Output = Result<ProviderOffer, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_offers<'life0, 'async_trait>(
        &'life0 self,
        campaign_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderOffer>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_offer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        offer: &'life1 ProviderOffer,
    ) -> Pin<Box<dyn Future<Output = Result<ProviderOffer, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_offer<'life0, 'async_trait>(
        &'life0 self,
        offer_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn find_offer_by_id<'life0, 'async_trait>(
        &'life0 self,
        offer_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ProviderOffer>, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_aggregation<'life0, 'async_trait>(
        &'life0 self,
        campaign_id: Uuid,
        total_kwh_electricity: Option<f64>,
        total_kwh_gas: Option<f64>,
        avg_kwh_per_unit: Option<f64>,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Repository trait for energy campaign persistence

Required Methods§

Source

fn create<'life0, 'life1, 'async_trait>( &'life0 self, campaign: &'life1 EnergyCampaign, ) -> Pin<Box<dyn Future<Output = Result<EnergyCampaign, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new energy campaign

Source

fn find_by_id<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<EnergyCampaign>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find campaign by ID

Source

fn find_by_organization<'life0, 'async_trait>( &'life0 self, organization_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<EnergyCampaign>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find all campaigns for an organization

Source

fn find_by_building<'life0, 'async_trait>( &'life0 self, building_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<EnergyCampaign>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find all campaigns for a building

Source

fn update<'life0, 'life1, 'async_trait>( &'life0 self, campaign: &'life1 EnergyCampaign, ) -> Pin<Box<dyn Future<Output = Result<EnergyCampaign, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update campaign

Source

fn delete<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete campaign

Source

fn add_offer<'life0, 'life1, 'async_trait>( &'life0 self, campaign_id: Uuid, offer: &'life1 ProviderOffer, ) -> Pin<Box<dyn Future<Output = Result<ProviderOffer, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add provider offer to campaign

Source

fn get_offers<'life0, 'async_trait>( &'life0 self, campaign_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<ProviderOffer>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all offers for a campaign

Source

fn update_offer<'life0, 'life1, 'async_trait>( &'life0 self, offer: &'life1 ProviderOffer, ) -> Pin<Box<dyn Future<Output = Result<ProviderOffer, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update provider offer

Source

fn delete_offer<'life0, 'async_trait>( &'life0 self, offer_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete provider offer

Source

fn find_offer_by_id<'life0, 'async_trait>( &'life0 self, offer_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<ProviderOffer>, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get offer by ID

Source

fn update_aggregation<'life0, 'async_trait>( &'life0 self, campaign_id: Uuid, total_kwh_electricity: Option<f64>, total_kwh_gas: Option<f64>, avg_kwh_per_unit: Option<f64>, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update campaign aggregated statistics (total_kwh, participants, etc.)

Implementors§