{-# LANGUAGE DeriveAnyClass #-}

module Hercules.Agent.WorkerProtocol.Event.BuildResult where

import Data.Binary
import Protolude

data BuildResult
  = BuildFailure {BuildResult -> Text
errorMessage :: Text}
  | BuildSuccess {BuildResult -> [OutputInfo]
outputs :: [OutputInfo]}
  deriving ((forall x. BuildResult -> Rep BuildResult x)
-> (forall x. Rep BuildResult x -> BuildResult)
-> Generic BuildResult
forall x. Rep BuildResult x -> BuildResult
forall x. BuildResult -> Rep BuildResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildResult x -> BuildResult
$cfrom :: forall x. BuildResult -> Rep BuildResult x
Generic, Get BuildResult
[BuildResult] -> Put
BuildResult -> Put
(BuildResult -> Put)
-> Get BuildResult -> ([BuildResult] -> Put) -> Binary BuildResult
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [BuildResult] -> Put
$cputList :: [BuildResult] -> Put
get :: Get BuildResult
$cget :: Get BuildResult
put :: BuildResult -> Put
$cput :: BuildResult -> Put
Binary, Int -> BuildResult -> ShowS
[BuildResult] -> ShowS
BuildResult -> String
(Int -> BuildResult -> ShowS)
-> (BuildResult -> String)
-> ([BuildResult] -> ShowS)
-> Show BuildResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildResult] -> ShowS
$cshowList :: [BuildResult] -> ShowS
show :: BuildResult -> String
$cshow :: BuildResult -> String
showsPrec :: Int -> BuildResult -> ShowS
$cshowsPrec :: Int -> BuildResult -> ShowS
Show, BuildResult -> BuildResult -> Bool
(BuildResult -> BuildResult -> Bool)
-> (BuildResult -> BuildResult -> Bool) -> Eq BuildResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildResult -> BuildResult -> Bool
$c/= :: BuildResult -> BuildResult -> Bool
== :: BuildResult -> BuildResult -> Bool
$c== :: BuildResult -> BuildResult -> Bool
Eq)

data OutputInfo = OutputInfo
  { -- | e.g. out, dev
    OutputInfo -> ByteString
name :: ByteString,
    -- | store path
    OutputInfo -> ByteString
path :: ByteString,
    -- | typically sha256:...
    OutputInfo -> ByteString
hash :: ByteString,
    -- | nar size in bytes
    OutputInfo -> Int64
size :: Int64
  }
  deriving ((forall x. OutputInfo -> Rep OutputInfo x)
-> (forall x. Rep OutputInfo x -> OutputInfo) -> Generic OutputInfo
forall x. Rep OutputInfo x -> OutputInfo
forall x. OutputInfo -> Rep OutputInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputInfo x -> OutputInfo
$cfrom :: forall x. OutputInfo -> Rep OutputInfo x
Generic, Get OutputInfo
[OutputInfo] -> Put
OutputInfo -> Put
(OutputInfo -> Put)
-> Get OutputInfo -> ([OutputInfo] -> Put) -> Binary OutputInfo
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [OutputInfo] -> Put
$cputList :: [OutputInfo] -> Put
get :: Get OutputInfo
$cget :: Get OutputInfo
put :: OutputInfo -> Put
$cput :: OutputInfo -> Put
Binary, Int -> OutputInfo -> ShowS
[OutputInfo] -> ShowS
OutputInfo -> String
(Int -> OutputInfo -> ShowS)
-> (OutputInfo -> String)
-> ([OutputInfo] -> ShowS)
-> Show OutputInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputInfo] -> ShowS
$cshowList :: [OutputInfo] -> ShowS
show :: OutputInfo -> String
$cshow :: OutputInfo -> String
showsPrec :: Int -> OutputInfo -> ShowS
$cshowsPrec :: Int -> OutputInfo -> ShowS
Show, OutputInfo -> OutputInfo -> Bool
(OutputInfo -> OutputInfo -> Bool)
-> (OutputInfo -> OutputInfo -> Bool) -> Eq OutputInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputInfo -> OutputInfo -> Bool
$c/= :: OutputInfo -> OutputInfo -> Bool
== :: OutputInfo -> OutputInfo -> Bool
$c== :: OutputInfo -> OutputInfo -> Bool
Eq)