mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-26 19:35:14 +00:00
agent: export decompressedSize (#1763)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ module Simplex.Messaging.Compression
|
||||
compressionLevel,
|
||||
compress1,
|
||||
decompress1,
|
||||
decompressedSize,
|
||||
) where
|
||||
|
||||
import qualified Codec.Compression.Zstd as Z1
|
||||
@@ -42,6 +43,11 @@ compress1 bs
|
||||
| B.length bs <= maxLengthPassthrough = Passthrough bs
|
||||
| otherwise = Compressed . Large $ Z1.compress compressionLevel bs
|
||||
|
||||
decompressedSize :: Compressed -> Maybe Int
|
||||
decompressedSize = \case
|
||||
Passthrough bs -> Just $ B.length bs
|
||||
Compressed (Large bs) -> Z1.decompressedSize bs
|
||||
|
||||
decompress1 :: Int -> Compressed -> Either String ByteString
|
||||
decompress1 limit = \case
|
||||
Passthrough bs -> Right bs
|
||||
|
||||
Reference in New Issue
Block a user