From af60f0551f7ed51669422234ad0916c71ba42e71 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Thu, 5 Dec 2019 13:34:03 -0500 Subject: Marshall AnnounceKey as raw ByteString. --- dht/Announcer.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'dht/Announcer.hs') 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 , scheduleToList , packAnnounceKey , unpackAnnounceKey + , encodeAnnounceKey + , decodeAnnounceKey , forkAnnouncer , stopAnnouncer , cancel @@ -44,15 +46,18 @@ import qualified GHC.Generics as Generics newtype AnnounceKey = AnnounceKey ByteString deriving (Hashable,Ord,Eq) --- instance Show AnnounceKey where --- show (AnnounceKey bs) = "AnnounceKey " ++ show (Char8.unpack bs) - packAnnounceKey :: Announcer -> String -> AnnounceKey packAnnounceKey _ = AnnounceKey . Char8.pack unpackAnnounceKey :: Announcer -> AnnounceKey -> String unpackAnnounceKey _ (AnnounceKey bs) = Char8.unpack bs +encodeAnnounceKey :: Announcer -> AnnounceKey -> ByteString +encodeAnnounceKey _ (AnnounceKey k) = k + +decodeAnnounceKey :: Announcer -> ByteString -> AnnounceKey +decodeAnnounceKey _ k = AnnounceKey k + -- | Actions that can be scheduled to occur at some particular time in the -- future. Since periodic event handlers are responsible for re-scheduling -- themselves, they are typically bootstrapped using 'scheduleImmediately' with -- cgit v1.2.3