agent: export decompressedSize (#1763)

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
Evgeny
2026-04-11 17:28:00 +01:00
committed by GitHub
parent 34c0909c1a
commit f2dafd983b
+6
View File
@@ -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