Copyright | (c) Eric Crockett 2011-2017 Chris Peikert 2011-2017 |
---|---|
License | GPL-3 |
Maintainer | ecrockett0@email.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Convenient interfaces for serialization with protocol buffers.
Synopsis
- class Protoable a where
- msgPut :: (ReflectDescriptor (ProtoType a), Wire (ProtoType a), Protoable a) => a -> ByteString
- msgGet :: (ReflectDescriptor (ProtoType a), Wire (ProtoType a), Protoable a) => ByteString -> Either String (a, ByteString)
- uToString :: Utf8 -> String
- uFromString :: String -> Utf8
- readProtoType :: (ReflectDescriptor a, Wire a, MonadIO m, MonadError String m) => FilePath -> m a
- parseProtoFile :: (ProtoReadable a, MonadIO m, MonadError String m) => FilePath -> m a
- writeProtoType :: (ReflectDescriptor a, Wire a) => FilePath -> a -> IO ()
- writeProtoFile :: (ProtoReadable a, MonadIO m) => FilePath -> a -> m ()
- type ProtoReadable a = (Protoable a, Wire (ProtoType a), ReflectDescriptor (ProtoType a))
Documentation
class Protoable a where Source #
Conversion between Haskell types and their protocol buffer representations.
toProto :: a -> ProtoType a Source #
Convert from a type to its protocol buffer representation.
fromProto :: MonadError String m => ProtoType a -> m a Source #
Convert from a protocol buffer representation.
Instances
msgPut :: (ReflectDescriptor (ProtoType a), Wire (ProtoType a), Protoable a) => a -> ByteString Source #
Serialize a Haskell type to its protocol buffer ByteString
.
msgGet :: (ReflectDescriptor (ProtoType a), Wire (ProtoType a), Protoable a) => ByteString -> Either String (a, ByteString) Source #
Read a protocol buffer ByteString
to a Haskell type.
uFromString :: String -> Utf8 #
readProtoType :: (ReflectDescriptor a, Wire a, MonadIO m, MonadError String m) => FilePath -> m a Source #
Read a serialized protobuffer from a file.
parseProtoFile :: (ProtoReadable a, MonadIO m, MonadError String m) => FilePath -> m a Source #
Read a protocol buffer stream at the given path and convert it to typed Haskell data.
writeProtoType :: (ReflectDescriptor a, Wire a) => FilePath -> a -> IO () Source #
Writes any auto-gen'd proto object to path/filename.
writeProtoFile :: (ProtoReadable a, MonadIO m) => FilePath -> a -> m () Source #
Write a protocol buffer stream for Haskell data to the given path.
type ProtoReadable a = (Protoable a, Wire (ProtoType a), ReflectDescriptor (ProtoType a)) Source #
Constraint synonym for end-to-end readingparsingwriting of Protoable
types.