module Codec.Archive.Zip.Conduit.Types where
import Control.Exception (Exception(..))
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Conduit as C
import Data.Conduit.Binary (sourceLbs)
import Data.Semigroup (Semigroup(..))
import Data.String (IsString(..))
import qualified Data.Text as T
import Data.Time.LocalTime (LocalTime)
import Data.Typeable (Typeable)
import Data.Word (Word32, Word64)
newtype ZipError = ZipError String
deriving (Int -> ZipError -> ShowS
[ZipError] -> ShowS
ZipError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipError] -> ShowS
$cshowList :: [ZipError] -> ShowS
show :: ZipError -> String
$cshow :: ZipError -> String
showsPrec :: Int -> ZipError -> ShowS
$cshowsPrec :: Int -> ZipError -> ShowS
Show, Typeable)
instance IsString ZipError where
fromString :: String -> ZipError
fromString = String -> ZipError
ZipError
instance Exception ZipError where
displayException :: ZipError -> String
displayException (ZipError String
e) = String
"ZipError: " forall a. [a] -> [a] -> [a]
++ String
e
data ZipInfo = ZipInfo
{ :: ByteString
} deriving (ZipInfo -> ZipInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZipInfo -> ZipInfo -> Bool
$c/= :: ZipInfo -> ZipInfo -> Bool
== :: ZipInfo -> ZipInfo -> Bool
$c== :: ZipInfo -> ZipInfo -> Bool
Eq, Int -> ZipInfo -> ShowS
[ZipInfo] -> ShowS
ZipInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipInfo] -> ShowS
$cshowList :: [ZipInfo] -> ShowS
show :: ZipInfo -> String
$cshow :: ZipInfo -> String
showsPrec :: Int -> ZipInfo -> ShowS
$cshowsPrec :: Int -> ZipInfo -> ShowS
Show)
data ZipEntry = ZipEntry
{ ZipEntry -> Either Text ByteString
zipEntryName :: Either T.Text ByteString
, ZipEntry -> LocalTime
zipEntryTime :: LocalTime
, ZipEntry -> Maybe Word64
zipEntrySize :: Maybe Word64
, ZipEntry -> Maybe Word32
zipEntryExternalAttributes :: Maybe Word32
} deriving (ZipEntry -> ZipEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZipEntry -> ZipEntry -> Bool
$c/= :: ZipEntry -> ZipEntry -> Bool
== :: ZipEntry -> ZipEntry -> Bool
$c== :: ZipEntry -> ZipEntry -> Bool
Eq, Int -> ZipEntry -> ShowS
[ZipEntry] -> ShowS
ZipEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZipEntry] -> ShowS
$cshowList :: [ZipEntry] -> ShowS
show :: ZipEntry -> String
$cshow :: ZipEntry -> String
showsPrec :: Int -> ZipEntry -> ShowS
$cshowsPrec :: Int -> ZipEntry -> ShowS
Show)
data ZipData m
= ZipDataByteString BSL.ByteString
| ZipDataSource (C.ConduitM () ByteString m ())
instance Monad m => Semigroup (ZipData m) where
ZipDataByteString ByteString
a <> :: ZipData m -> ZipData m -> ZipData m
<> ZipDataByteString ByteString
b = forall (m :: * -> *). ByteString -> ZipData m
ZipDataByteString forall a b. (a -> b) -> a -> b
$ forall a. Monoid a => a -> a -> a
mappend ByteString
a ByteString
b
ZipData m
a <> ZipData m
b = forall (m :: * -> *). ConduitM () ByteString m () -> ZipData m
ZipDataSource forall a b. (a -> b) -> a -> b
$ forall a. Monoid a => a -> a -> a
mappend (forall (m :: * -> *).
Monad m =>
ZipData m -> ConduitM () ByteString m ()
sourceZipData ZipData m
a) (forall (m :: * -> *).
Monad m =>
ZipData m -> ConduitM () ByteString m ()
sourceZipData ZipData m
b)
instance Monad m => Monoid (ZipData m) where
mempty :: ZipData m
mempty = forall (m :: * -> *). ByteString -> ZipData m
ZipDataByteString ByteString
BSL.empty
mappend :: ZipData m -> ZipData m -> ZipData m
mappend = forall a. Semigroup a => a -> a -> a
(<>)
sourceZipData :: Monad m => ZipData m -> C.ConduitM () ByteString m ()
sourceZipData :: forall (m :: * -> *).
Monad m =>
ZipData m -> ConduitM () ByteString m ()
sourceZipData (ZipDataByteString ByteString
b) = forall (m :: * -> *) i.
Monad m =>
ByteString -> ConduitT i ByteString m ()
sourceLbs ByteString
b
sourceZipData (ZipDataSource ConduitM () ByteString m ()
s) = ConduitM () ByteString m ()
s