Skip to content

Commit

Permalink
use ByteString for ObjectStr for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
l29ah committed Jul 24, 2020
1 parent 1ec4ac2 commit 8bfa799
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/Data/MessagePack/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ getFloat = tag 0xCA >> getFloat32be
getDouble :: Get Double
getDouble = tag 0xCB >> getFloat64be

getStr :: Get T.Text
getStr :: Get S.ByteString
getStr = do
len <- getWord8 >>= \case
t | t .&. 0xE0 == 0xA0 ->
Expand All @@ -104,10 +104,7 @@ getStr = do
0xDA -> fromIntegral <$> getWord16be
0xDB -> fromIntegral <$> getWord32be
_ -> empty
bs <- getByteString len
case T.decodeUtf8' bs of
Left _ -> empty
Right v -> return v
getByteString len

getBin :: Get S.ByteString
getBin = do
Expand Down
5 changes: 2 additions & 3 deletions src/Data/MessagePack/Put.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ putDouble d = do
putWord8 0xCB
putFloat64be d

putStr :: T.Text -> Put
putStr t = do
let bs = T.encodeUtf8 t
putStr :: S.ByteString -> Put
putStr bs = do
case S.length bs of
len | len <= 31 ->
putWord8 $ 0xA0 .|. fromIntegral len
Expand Down

0 comments on commit 8bfa799

Please sign in to comment.