module Blaze.ByteString.Builder.ByteString
(
writeByteString
, fromByteString
, fromByteStringWith
, copyByteString
, insertByteString
, fromLazyByteString
, fromLazyByteStringWith
, copyLazyByteString
, insertLazyByteString
) where
import Blaze.ByteString.Builder.Internal.Write ( Write, exactWrite )
import Foreign
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Extra as B
import qualified Data.ByteString as S
import qualified Data.ByteString.Internal as S
import qualified Data.ByteString.Lazy as L
writeByteString :: S.ByteString -> Write
writeByteString :: ByteString -> Write
writeByteString bs :: ByteString
bs = Int -> (Ptr Word8 -> IO ()) -> Write
exactWrite Int
l Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
io
where
(fptr :: ForeignPtr Word8
fptr, o :: Int
o, l :: Int
l) = ByteString -> (ForeignPtr Word8, Int, Int)
S.toForeignPtr ByteString
bs
io :: Ptr a -> IO ()
io pf :: Ptr a
pf = ForeignPtr Word8 -> (Ptr Word8 -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Word8
fptr ((Ptr Word8 -> IO ()) -> IO ()) -> (Ptr Word8 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \p :: Ptr Word8
p -> Ptr a -> Ptr a -> Int -> IO ()
forall a. Ptr a -> Ptr a -> Int -> IO ()
copyBytes Ptr a
pf (Ptr Word8
p Ptr Word8 -> Int -> Ptr a
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
o) Int
l
{-# INLINE writeByteString #-}
fromByteString :: S.ByteString -> B.Builder
fromByteString :: ByteString -> Builder
fromByteString = ByteString -> Builder
B.byteString
{-# INLINE fromByteString #-}
fromByteStringWith :: Int
-> S.ByteString
-> B.Builder
fromByteStringWith :: Int -> ByteString -> Builder
fromByteStringWith = Int -> ByteString -> Builder
B.byteStringThreshold
{-# INLINE fromByteStringWith #-}
copyByteString :: S.ByteString -> B.Builder
copyByteString :: ByteString -> Builder
copyByteString = ByteString -> Builder
B.byteStringCopy
{-# INLINE copyByteString #-}
insertByteString :: S.ByteString -> B.Builder
insertByteString :: ByteString -> Builder
insertByteString = ByteString -> Builder
B.byteStringInsert
{-# INLINE insertByteString #-}
fromLazyByteString :: L.ByteString -> B.Builder
fromLazyByteString :: ByteString -> Builder
fromLazyByteString = ByteString -> Builder
B.lazyByteString
{-# INLINE fromLazyByteString #-}
fromLazyByteStringWith :: Int -> L.ByteString -> B.Builder
fromLazyByteStringWith :: Int -> ByteString -> Builder
fromLazyByteStringWith = Int -> ByteString -> Builder
B.lazyByteStringThreshold
{-# INLINE fromLazyByteStringWith #-}
copyLazyByteString :: L.ByteString -> B.Builder
copyLazyByteString :: ByteString -> Builder
copyLazyByteString = ByteString -> Builder
B.lazyByteStringCopy
{-# INLINE copyLazyByteString #-}
insertLazyByteString :: L.ByteString -> B.Builder
insertLazyByteString :: ByteString -> Builder
insertLazyByteString = ByteString -> Builder
B.lazyByteStringInsert
{-# INLINE insertLazyByteString #-}