Rename readExactly to read
This commit is contained in:
parent
73dfdb0b7f
commit
655f4b90bc
3 changed files with 5 additions and 5 deletions
|
@ -16,7 +16,7 @@ import System.IO
|
|||
--
|
||||
-- `read` should return `ByteString.null` on EOF
|
||||
data Connection = Connection {
|
||||
readExactly :: Int -> IO ByteString,
|
||||
read :: Int -> IO ByteString,
|
||||
write :: ByteString -> IO (),
|
||||
flush :: IO (),
|
||||
close :: IO ()}
|
||||
|
@ -25,7 +25,7 @@ fromHandle :: Handle -> IO Connection
|
|||
-- ^ Make connection form handle
|
||||
fromHandle handle = do
|
||||
return Connection
|
||||
{ readExactly = ByteString.hGet handle
|
||||
{ read = ByteString.hGet handle
|
||||
, write = ByteString.hPut handle
|
||||
, flush = hFlush handle
|
||||
, close = hClose handle
|
||||
|
|
|
@ -207,8 +207,8 @@ readMessage :: Connection -> IO Response
|
|||
-- ^ read response from a connection
|
||||
readMessage conn = readResp where
|
||||
readResp = do
|
||||
len <- fromEnum . decodeSize . L.fromStrict <$> Connection.readExactly conn 4
|
||||
runGet getReply . L.fromStrict <$> Connection.readExactly conn len
|
||||
len <- fromEnum . decodeSize . L.fromStrict <$> Connection.read conn 4
|
||||
runGet getReply . L.fromStrict <$> Connection.read conn len
|
||||
decodeSize = subtract 4 . runGet getInt32
|
||||
|
||||
type FullCollection = Text
|
||||
|
|
|
@ -56,7 +56,7 @@ tlsConnection :: TLS.Context -> IO () -> IO Connection
|
|||
tlsConnection ctx close = do
|
||||
restRef <- newIORef mempty
|
||||
return Connection
|
||||
{ Connection.readExactly = \count -> let
|
||||
{ Connection.read = \count -> let
|
||||
readSome = do
|
||||
rest <- readIORef restRef
|
||||
writeIORef restRef mempty
|
||||
|
|
Loading…
Reference in a new issue