diff options
author | Joe Crayne <joe@jerkface.net> | 2019-12-05 13:34:03 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 23:22:52 -0500 |
commit | af60f0551f7ed51669422234ad0916c71ba42e71 (patch) | |
tree | 47f3999b52f7206cb38bb12e996de7fd6bf0fb6f /dht | |
parent | 917abe95273afedd9d6b8e57ea34c0f8e55509e8 (diff) |
Marshall AnnounceKey as raw ByteString.
Diffstat (limited to 'dht')
-rw-r--r-- | dht/Announcer.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/dht/Announcer.hs b/dht/Announcer.hs index 41f86f24..98fcdf94 100644 --- a/dht/Announcer.hs +++ b/dht/Announcer.hs | |||
@@ -13,6 +13,8 @@ module Announcer | |||
13 | , scheduleToList | 13 | , scheduleToList |
14 | , packAnnounceKey | 14 | , packAnnounceKey |
15 | , unpackAnnounceKey | 15 | , unpackAnnounceKey |
16 | , encodeAnnounceKey | ||
17 | , decodeAnnounceKey | ||
16 | , forkAnnouncer | 18 | , forkAnnouncer |
17 | , stopAnnouncer | 19 | , stopAnnouncer |
18 | , cancel | 20 | , cancel |
@@ -44,15 +46,18 @@ import qualified GHC.Generics as Generics | |||
44 | newtype AnnounceKey = AnnounceKey ByteString | 46 | newtype AnnounceKey = AnnounceKey ByteString |
45 | deriving (Hashable,Ord,Eq) | 47 | deriving (Hashable,Ord,Eq) |
46 | 48 | ||
47 | -- instance Show AnnounceKey where | ||
48 | -- show (AnnounceKey bs) = "AnnounceKey " ++ show (Char8.unpack bs) | ||
49 | |||
50 | packAnnounceKey :: Announcer -> String -> AnnounceKey | 49 | packAnnounceKey :: Announcer -> String -> AnnounceKey |
51 | packAnnounceKey _ = AnnounceKey . Char8.pack | 50 | packAnnounceKey _ = AnnounceKey . Char8.pack |
52 | 51 | ||
53 | unpackAnnounceKey :: Announcer -> AnnounceKey -> String | 52 | unpackAnnounceKey :: Announcer -> AnnounceKey -> String |
54 | unpackAnnounceKey _ (AnnounceKey bs) = Char8.unpack bs | 53 | unpackAnnounceKey _ (AnnounceKey bs) = Char8.unpack bs |
55 | 54 | ||
55 | encodeAnnounceKey :: Announcer -> AnnounceKey -> ByteString | ||
56 | encodeAnnounceKey _ (AnnounceKey k) = k | ||
57 | |||
58 | decodeAnnounceKey :: Announcer -> ByteString -> AnnounceKey | ||
59 | decodeAnnounceKey _ k = AnnounceKey k | ||
60 | |||
56 | -- | Actions that can be scheduled to occur at some particular time in the | 61 | -- | Actions that can be scheduled to occur at some particular time in the |
57 | -- future. Since periodic event handlers are responsible for re-scheduling | 62 | -- future. Since periodic event handlers are responsible for re-scheduling |
58 | -- themselves, they are typically bootstrapped using 'scheduleImmediately' with | 63 | -- themselves, they are typically bootstrapped using 'scheduleImmediately' with |