| Copyright | (c) Serokell 2016 |
|---|---|
| License | GPL-3 (see the file LICENSE) |
| Maintainer | Serokell <hi@serokell.io> |
| Stability | experimental |
| Portability | POSIX, GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.TimeWarp.Rpc.Message
Description
- type MessageName = Text
- class Typeable m => Message m where
- class PackingType p where
- type IntermediateForm p :: *
- class PackingType p => Packable p r where
- class PackingType p => Unpackable p r where
- data BinaryP header = BinaryP
- plainBinaryP :: BinaryP ()
- data ContentData r = ContentData r
- data NameData = NameData MessageName
- data RawData = RawData ByteString
- data WithHeaderData h r = WithHeaderData h r
- messageName' :: Message m => m -> MessageName
- runGetOrThrow :: MonadThrow m => Get a -> ByteString -> m a
Message
type MessageName = Text Source #
Message name, which is expected to uniquely define type of message.
class Typeable m => Message m where Source #
Defines type with it's own MessageName.
Methods
messageName :: Proxy m -> MessageName Source #
Uniquely identifies this type
messageName :: Data m => Proxy m -> MessageName Source #
Uniquely identifies this type
formatMessage :: m -> Text Source #
Description of message, for debug purposes
formatMessage :: Buildable m => m -> Text Source #
Description of message, for debug purposes
Serialization and deserialization
class PackingType p where Source #
Defines a serialization / deserialization strategy. Deserealization is assumed to be performed in two phases:
- byte stream -> intermediate form
- intermediate form -> any part of message (or their combination)
Minimal complete definition
Methods
unpackMsg :: MonadThrow m => p -> Conduit ByteString m (IntermediateForm p) Source #
Way of unpacking raw bytes to intermediate form.
Instances
| Binary h => PackingType (BinaryP h) Source # | |
class PackingType p => Packable p r where Source #
Defines a way to serialize object r with given packing type p.
Minimal complete definition
Methods
packMsg :: MonadThrow m => p -> Conduit r m ByteString Source #
Way of packing data to raw bytes.
class PackingType p => Unpackable p r where Source #
Defines a way to deserealize data with given packing type p and extract object r.
Minimal complete definition
Methods
extractMsgPart :: MonadThrow m => p -> IntermediateForm p -> m r Source #
Way to extract message part from intermediate form.
Instances
| Binary h => Unpackable (BinaryP h) NameData Source # | |
| (Binary h, Binary r) => Unpackable (BinaryP h) (ContentData r) Source # | |
| Binary h => Unpackable (BinaryP h) (WithHeaderData h RawData) Source # | |
Basic packing types
Defines way to encode Binary instances into message of format
(header, [[name], content]), where [x] = (length of x, x).
P here denotes to "packing".
Constructors
| BinaryP |
Instances
| Binary h => PackingType (BinaryP h) Source # | |
| Binary h => Unpackable (BinaryP h) NameData Source # | |
| (Binary h, Binary r) => Unpackable (BinaryP h) (ContentData r) Source # | |
| Binary h => Unpackable (BinaryP h) (WithHeaderData h RawData) Source # | |
| Binary h => Packable (BinaryP h) (WithHeaderData h RawData) Source # | |
| (Binary h, Binary r, Message r) => Packable (BinaryP h) (WithHeaderData h (ContentData r)) Source # | |
| type IntermediateForm (BinaryP h) Source # | |
plainBinaryP :: BinaryP () Source #
Parts of message
This part describes different parts of message. which are enought for serializing message / could be extracted on deserializing.
| Message's content.
data ContentData r Source #
Constructors
| ContentData r |
Instances
| (Binary h, Binary r) => Unpackable (BinaryP h) (ContentData r) Source # | |
| (Binary h, Binary r, Message r) => Packable (BinaryP h) (WithHeaderData h (ContentData r)) Source # | |
Message's name.
Constructors
| NameData MessageName |
Designates data given from incoming message, but not deserialized to any specified object.
Constructors
| RawData ByteString |
Instances
| Binary h => Unpackable (BinaryP h) (WithHeaderData h RawData) Source # | |
| Binary h => Packable (BinaryP h) (WithHeaderData h RawData) Source # | |
data WithHeaderData h r Source #
Message's header & something else
Constructors
| WithHeaderData h r |
Instances
| Binary h => Unpackable (BinaryP h) (WithHeaderData h RawData) Source # | |
| Binary h => Packable (BinaryP h) (WithHeaderData h RawData) Source # | |
| (Binary h, Binary r, Message r) => Packable (BinaryP h) (WithHeaderData h (ContentData r)) Source # | |
Util
messageName' :: Message m => m -> MessageName Source #
As messageName, but accepts message itself, may be more convinient is most cases.
runGetOrThrow :: MonadThrow m => Get a -> ByteString -> m a Source #
Parses given bytestring, throwing ParseError on fail.