New TODO for hashing files with detached GPG signatures.
[quix0rs-apt-p2p.git] / apt_p2p / interfaces.py
1
2 """Some interfaces that are used by the apt-p2p classes."""
3
4 from zope.interface import Interface
5
6 class IDHT(Interface):
7     """An abstract interface for using a DHT implementation."""
8     
9     def loadConfig(self, config, section):
10         """Load the DHTs configuration from a dictionary.
11         
12         @type config: C{SafeConfigParser}
13         @param config: the dictionary of config values
14         """
15     
16     def join(self):
17         """Bootstrap the new DHT node into the DHT.
18         
19         @rtype: C{Deferred}
20         @return: a deferred that will fire when the node has joined
21         """
22         
23     def leave(self):
24         """Depart gracefully from the DHT.
25         
26         @rtype: C{Deferred}
27         @return: a deferred that will fire when the node has left
28         """
29         
30     def getValue(self, key):
31         """Get a value from the DHT for the specified key.
32         
33         The length of the key may be adjusted for use with the DHT.
34
35         @rtype: C{Deferred}
36         @return: a deferred that will fire with the stored values
37         """
38         
39     def storeValue(self, key, value):
40         """Store a value in the DHT for the specified key.
41
42         The length of the key may be adjusted for use with the DHT.
43         """
44
45 class IDHTStats(Interface):
46     """An abstract interface for DHTs that support statistics gathering."""
47     
48     def getStats(self):
49         """Gather and format all the statistics for the DHT.
50         
51         The statistics will be formatted for inclusion in the body
52         of an HTML page.
53         
54         @rtype: C{string}
55         @return: the formatted statistics, suitable for displaying to the user
56         """
57     
58 class IDHTStatsFactory(Interface):
59     """An abstract interface for DHTs that support statistics displaying."""
60     
61     def getStatsFactory(self):
62         """Create and return an HTTP factory for displaying statistics.
63         
64         @rtype: 
65         """
66