module Network.Flink.Internal.ProtoServant where import qualified Data.ByteString.Lazy as BS import qualified Data.List.NonEmpty as NE import qualified Data.ProtoLens as P import Network.HTTP.Media ((//)) import qualified Servant.API.ContentTypes as S data Proto instance S.Accept Proto where contentTypes :: Proxy Proto -> NonEmpty MediaType contentTypes _ = [MediaType] -> NonEmpty MediaType forall a. [a] -> NonEmpty a NE.fromList [ "application" ByteString -> ByteString -> MediaType // "octet-stream", "application" ByteString -> ByteString -> MediaType // "protobuf", "application" ByteString -> ByteString -> MediaType // "x-protobuf", "application" ByteString -> ByteString -> MediaType // "vnd.google.protobuf" ] instance P.Message m => S.MimeRender Proto m where mimeRender :: Proxy Proto -> m -> ByteString mimeRender _ = ByteString -> ByteString BS.fromStrict (ByteString -> ByteString) -> (m -> ByteString) -> m -> ByteString forall b c a. (b -> c) -> (a -> b) -> a -> c . m -> ByteString forall msg. Message msg => msg -> ByteString P.encodeMessage instance P.Message m => S.MimeUnrender Proto m where mimeUnrender :: Proxy Proto -> ByteString -> Either String m mimeUnrender _ = ByteString -> Either String m forall msg. Message msg => ByteString -> Either String msg P.decodeMessage (ByteString -> Either String m) -> (ByteString -> ByteString) -> ByteString -> Either String m forall b c a. (b -> c) -> (a -> b) -> a -> c . ByteString -> ByteString BS.toStrict