summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-27 12:01:20 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-27 12:08:37 -0400
commit5c542bb09e51eeb407a59f5bd4a2c6c460863446 (patch)
tree25c5b9cb53892b1445496d81357d9c889f162724 /Types.hs
parent952cc2941091518e61345f005b6e218bc34f75ec (diff)
downloaddebug-me-5c542bb09e51eeb407a59f5bd4a2c6c460863446.tar.gz
switch wire message seralization to use protocol buffers
This way it's not tied to details of the haskell binary library, and implementations in other languages should be fairly simple to do. The haskell protobuf library was used because it does not need extra tooling or build steps. So I didn't write a .proto file, but one could fairly easily be written by following ProtocolBuffers.hs and translating it. ProtocolBuffers.hs is *extremely* repetative and tedious code. Surely there must be a way to not need to write all of that? Oh well, I wrote it.. Sizes of serialized messages: ">>> debug-me session started": 121 sending a single key press: 169 This seems equally as efficient as the binary serialization was; that was 165 bytes before elapsedTime was added. This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs24
1 files changed, 4 insertions, 20 deletions
diff --git a/Types.hs b/Types.hs
index 678455c..18b197e 100644
--- a/Types.hs
+++ b/Types.hs
@@ -2,9 +2,9 @@
{- | Main types for debug-me
-
- - Note that changing types in ways that change the Binary serialization
- - changes debug-me's wire format. Changing types in ways that change the
- - aeson serialization changes debug-me's log format.
+ - Note that changing types in ways that change the JSON serialization
+ - changes debug-me's log format, and in some cases also changes the wire
+ - format.
-}
module Types (
@@ -14,7 +14,7 @@ module Types (
import Val
import Memory
-import Serialization
+import JSON
import Data.Time.Clock.POSIX
@@ -169,7 +169,6 @@ data AnyMessage
| Developer (Message Entered)
deriving (Show, Generic)
-instance Binary ElapsedTime
instance ToJSON ElapsedTime
instance FromJSON ElapsedTime
@@ -177,70 +176,55 @@ instance DataSize AnyMessage where
dataSize (User a) = dataSize a
dataSize (Developer a) = dataSize a
-instance Binary AnyMessage
instance ToJSON AnyMessage where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions
instance FromJSON AnyMessage where
parseJSON = genericParseJSON sumOptions
-instance Binary Seen
instance ToJSON Seen
instance FromJSON Seen
-instance Binary Entered
instance ToJSON Entered
instance FromJSON Entered
-instance Binary (Activity Seen)
instance ToJSON (Activity Seen)
instance FromJSON (Activity Seen)
-instance Binary (Activity Entered)
instance ToJSON (Activity Entered)
instance FromJSON (Activity Entered)
-instance Binary Control
instance ToJSON Control
instance FromJSON Control
-instance Binary Hash
instance ToJSON Hash
instance FromJSON Hash
-instance Binary HashMethod
instance ToJSON HashMethod
instance FromJSON HashMethod
-instance Binary PublicKey
instance ToJSON PublicKey
instance FromJSON PublicKey
-instance Binary GpgSig
instance ToJSON GpgSig
instance FromJSON GpgSig
-instance Binary (Message Seen)
instance ToJSON (Message Seen) where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions
instance FromJSON (Message Seen) where
parseJSON = genericParseJSON sumOptions
-instance Binary (Message Entered)
instance ToJSON (Message Entered) where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions
instance FromJSON (Message Entered) where
parseJSON = genericParseJSON sumOptions
-instance Binary Signature
instance ToJSON Signature where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions
instance FromJSON Signature where
parseJSON = genericParseJSON sumOptions
-instance Binary ControlAction
instance ToJSON ControlAction where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions
instance FromJSON ControlAction where
parseJSON = genericParseJSON sumOptions
-instance Binary (PerhapsSigned PublicKey)
instance ToJSON (PerhapsSigned PublicKey) where
toJSON = genericToJSON sumOptions
toEncoding = genericToEncoding sumOptions