Trait proj_billing::billing::BillingProtocol [] [src]

pub trait BillingProtocol<T: Read + Write, B> {
    type Consumption;
    type Prices;
    fn null_prices() -> Self::Prices;
    fn consume(&mut self, consumption: &Self::Consumption);
    fn send_billing_information(&mut self);
    fn pay_bill(&mut self) -> B;
    fn change_prices(&mut self, prices: &Self::Prices);
    fn new_meter(channel: T, prices: &Self::Prices, keys: MeterKeys) -> Self;
    fn new_server(channel: T, keys: Keys, prices: &Self::Prices) -> Self;
}

Functionality which all billing protocols must provide.

The first type argument it the channel over which communication occurs. This should probably be a proj_net::{Server, Client}. The second type argument is the return value of the constructors (i.e the structure implementing this trait)

Associated Types

Consumption information for billing e.g. the time of consumption and the units consumed

Information used to calculate the bill (e.g. coefficients for each in which a unit could be consumed)

Required Methods

returns a null Prices object

To be run on the meter. This function should check for any new prices, and then add the price of consumption to the running bill

Get the server up to speed with the current billing information: a message from the device to the server.

Pay bill (run on the server) This will block until it has received the billing information from the meter (via send_billing_information)

Change the way bills are calculated. This is a message sent from the server (utility company) to the meter.

Instantiate a new meter

Instantiate a new server

Implementors