module Database.MongoDB.Transport (
Transport(..),
fromHandle,
) where
import Prelude hiding (read)
import Data.ByteString (ByteString)
import qualified Data.ByteString as ByteString
import System.IO
data Transport = Transport {
read :: Int -> IO ByteString,
write :: ByteString -> IO (),
flush :: IO (),
close :: IO ()}
fromHandle :: Handle -> IO Transport
fromHandle handle = do
return Transport
{ read = ByteString.hGet handle
, write = ByteString.hPut handle
, flush = hFlush handle
, close = hClose handle
}