Small improvements

This commit is contained in:
VyacheslavHashov 2017-02-08 18:41:00 +03:00
parent 4ac1d9f9d3
commit e897fa33a4

View File

@ -1,9 +1,10 @@
module Database.PostgreSQL.Protocol.Encoders where
module Database.PostgreSQL.Protocol.Encoders
( encodeStartMessage
, encodeClientMessage
) where
import Data.Word
import Data.Int
import Data.Monoid
import Data.Foldable
import Data.Int (Int32)
import Data.Monoid ((<>))
import qualified Data.Vector as V
import qualified Data.ByteString as B
@ -72,7 +73,7 @@ encodeClientMessage Sync
encodeClientMessage Terminate
= prependHeader 'X' mempty
-- Encodes single data values. Length `-1` indicates a NULL parameter value.
-- | Encodes single data values. Length `-1` indicates a NULL parameter value.
-- No value bytes follow in the NULL case.
encodeValue :: Maybe B.ByteString -> Encode
encodeValue Nothing = putInt32BE (-1)
@ -83,10 +84,6 @@ encodeFormat :: Format -> Encode
encodeFormat Text = putInt16BE 0
encodeFormat Binary = putInt16BE 1
----------
-- Utils
---------
prependHeader :: Char -> Encode -> Encode
prependHeader c payload =
-- Length includes itself but not the first message-type byte