{-# OPTIONS_HADDOCK hide #-}
module Cometa.Internal.Reencode (reencode) where
import Cometa.Error (Error)
import qualified Cometa.Internal.FFI.Reencode as FFI
import qualified Cometa.Internal.Runtime as Runtime
import Data.ByteString (ByteString)
import Data.Text (Text)
import Foreign.C.Types (CUInt)
reencode :: Text -> CUInt -> ByteString -> IO (Either Error ByteString)
reencode :: Text -> CUInt -> ByteString -> IO (Either Error ByteString)
reencode Text
operation CUInt
kind ByteString
bytes = ByteString
-> (Ptr Word8 -> CSize -> IO (Either Error ByteString))
-> IO (Either Error ByteString)
forall a. ByteString -> (Ptr Word8 -> CSize -> IO a) -> IO a
Runtime.withBytes ByteString
bytes ((Ptr Word8 -> CSize -> IO (Either Error ByteString))
-> IO (Either Error ByteString))
-> (Ptr Word8 -> CSize -> IO (Either Error ByteString))
-> IO (Either Error ByteString)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
input CSize
size -> Text
-> (Ptr (Ptr Buffer) -> IO CUInt) -> IO (Either Error ByteString)
Runtime.withOwnedBuffer Text
operation (CUInt -> Ptr Word8 -> CSize -> Ptr (Ptr Buffer) -> IO CUInt
FFI.cReencode CUInt
kind Ptr Word8
input CSize
size)