{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.Api.IO.Base
  ( FileDirection (..)
  , File (..)
  , Socket
  , SocketPath
  , VRFPrivateKeyFilePermissionError (..)
  )
where

import           Data.Aeson (FromJSON, ToJSON)
import           Data.String (IsString)

data FileDirection
  = -- | Indicate the file is to be used for reading.
    In
  | -- | Indicate the file is to be used for writing.
    Out
  | -- | Indicate the file is to be used for both reading and writing.
    InOut

-- | A file path with additional type information to indicate what the file is meant to
-- contain and whether it is to be used for reading or writing.
newtype File content (direction :: FileDirection) = File
  { forall content (direction :: FileDirection).
File content direction -> FilePath
unFile :: FilePath
  }
  deriving newtype (File content direction -> File content direction -> Bool
(File content direction -> File content direction -> Bool)
-> (File content direction -> File content direction -> Bool)
-> Eq (File content direction)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
$c== :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
== :: File content direction -> File content direction -> Bool
$c/= :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
/= :: File content direction -> File content direction -> Bool
Eq, Eq (File content direction)
Eq (File content direction) =>
(File content direction -> File content direction -> Ordering)
-> (File content direction -> File content direction -> Bool)
-> (File content direction -> File content direction -> Bool)
-> (File content direction -> File content direction -> Bool)
-> (File content direction -> File content direction -> Bool)
-> (File content direction
    -> File content direction -> File content direction)
-> (File content direction
    -> File content direction -> File content direction)
-> Ord (File content direction)
File content direction -> File content direction -> Bool
File content direction -> File content direction -> Ordering
File content direction
-> File content direction -> File content direction
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall content (direction :: FileDirection).
Eq (File content direction)
forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
forall content (direction :: FileDirection).
File content direction -> File content direction -> Ordering
forall content (direction :: FileDirection).
File content direction
-> File content direction -> File content direction
$ccompare :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Ordering
compare :: File content direction -> File content direction -> Ordering
$c< :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
< :: File content direction -> File content direction -> Bool
$c<= :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
<= :: File content direction -> File content direction -> Bool
$c> :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
> :: File content direction -> File content direction -> Bool
$c>= :: forall content (direction :: FileDirection).
File content direction -> File content direction -> Bool
>= :: File content direction -> File content direction -> Bool
$cmax :: forall content (direction :: FileDirection).
File content direction
-> File content direction -> File content direction
max :: File content direction
-> File content direction -> File content direction
$cmin :: forall content (direction :: FileDirection).
File content direction
-> File content direction -> File content direction
min :: File content direction
-> File content direction -> File content direction
Ord, ReadPrec [File content direction]
ReadPrec (File content direction)
Int -> ReadS (File content direction)
ReadS [File content direction]
(Int -> ReadS (File content direction))
-> ReadS [File content direction]
-> ReadPrec (File content direction)
-> ReadPrec [File content direction]
-> Read (File content direction)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall content (direction :: FileDirection).
ReadPrec [File content direction]
forall content (direction :: FileDirection).
ReadPrec (File content direction)
forall content (direction :: FileDirection).
Int -> ReadS (File content direction)
forall content (direction :: FileDirection).
ReadS [File content direction]
$creadsPrec :: forall content (direction :: FileDirection).
Int -> ReadS (File content direction)
readsPrec :: Int -> ReadS (File content direction)
$creadList :: forall content (direction :: FileDirection).
ReadS [File content direction]
readList :: ReadS [File content direction]
$creadPrec :: forall content (direction :: FileDirection).
ReadPrec (File content direction)
readPrec :: ReadPrec (File content direction)
$creadListPrec :: forall content (direction :: FileDirection).
ReadPrec [File content direction]
readListPrec :: ReadPrec [File content direction]
Read, Int -> File content direction -> FilePath -> FilePath
[File content direction] -> FilePath -> FilePath
File content direction -> FilePath
(Int -> File content direction -> FilePath -> FilePath)
-> (File content direction -> FilePath)
-> ([File content direction] -> FilePath -> FilePath)
-> Show (File content direction)
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
forall content (direction :: FileDirection).
Int -> File content direction -> FilePath -> FilePath
forall content (direction :: FileDirection).
[File content direction] -> FilePath -> FilePath
forall content (direction :: FileDirection).
File content direction -> FilePath
$cshowsPrec :: forall content (direction :: FileDirection).
Int -> File content direction -> FilePath -> FilePath
showsPrec :: Int -> File content direction -> FilePath -> FilePath
$cshow :: forall content (direction :: FileDirection).
File content direction -> FilePath
show :: File content direction -> FilePath
$cshowList :: forall content (direction :: FileDirection).
[File content direction] -> FilePath -> FilePath
showList :: [File content direction] -> FilePath -> FilePath
Show, FilePath -> File content direction
(FilePath -> File content direction)
-> IsString (File content direction)
forall a. (FilePath -> a) -> IsString a
forall content (direction :: FileDirection).
FilePath -> File content direction
$cfromString :: forall content (direction :: FileDirection).
FilePath -> File content direction
fromString :: FilePath -> File content direction
IsString, Maybe (File content direction)
Value -> Parser [File content direction]
Value -> Parser (File content direction)
(Value -> Parser (File content direction))
-> (Value -> Parser [File content direction])
-> Maybe (File content direction)
-> FromJSON (File content direction)
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
forall content (direction :: FileDirection).
Maybe (File content direction)
forall content (direction :: FileDirection).
Value -> Parser [File content direction]
forall content (direction :: FileDirection).
Value -> Parser (File content direction)
$cparseJSON :: forall content (direction :: FileDirection).
Value -> Parser (File content direction)
parseJSON :: Value -> Parser (File content direction)
$cparseJSONList :: forall content (direction :: FileDirection).
Value -> Parser [File content direction]
parseJSONList :: Value -> Parser [File content direction]
$comittedField :: forall content (direction :: FileDirection).
Maybe (File content direction)
omittedField :: Maybe (File content direction)
FromJSON, [File content direction] -> Value
[File content direction] -> Encoding
File content direction -> Bool
File content direction -> Value
File content direction -> Encoding
(File content direction -> Value)
-> (File content direction -> Encoding)
-> ([File content direction] -> Value)
-> ([File content direction] -> Encoding)
-> (File content direction -> Bool)
-> ToJSON (File content direction)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
forall content (direction :: FileDirection).
[File content direction] -> Value
forall content (direction :: FileDirection).
[File content direction] -> Encoding
forall content (direction :: FileDirection).
File content direction -> Bool
forall content (direction :: FileDirection).
File content direction -> Value
forall content (direction :: FileDirection).
File content direction -> Encoding
$ctoJSON :: forall content (direction :: FileDirection).
File content direction -> Value
toJSON :: File content direction -> Value
$ctoEncoding :: forall content (direction :: FileDirection).
File content direction -> Encoding
toEncoding :: File content direction -> Encoding
$ctoJSONList :: forall content (direction :: FileDirection).
[File content direction] -> Value
toJSONList :: [File content direction] -> Value
$ctoEncodingList :: forall content (direction :: FileDirection).
[File content direction] -> Encoding
toEncodingList :: [File content direction] -> Encoding
$comitField :: forall content (direction :: FileDirection).
File content direction -> Bool
omitField :: File content direction -> Bool
ToJSON)

data Socket

type SocketPath = File Socket 'InOut

data VRFPrivateKeyFilePermissionError
  = OtherPermissionsExist FilePath
  | GroupPermissionsExist FilePath
  | GenericPermissionsExist FilePath
  deriving Int -> VRFPrivateKeyFilePermissionError -> FilePath -> FilePath
[VRFPrivateKeyFilePermissionError] -> FilePath -> FilePath
VRFPrivateKeyFilePermissionError -> FilePath
(Int -> VRFPrivateKeyFilePermissionError -> FilePath -> FilePath)
-> (VRFPrivateKeyFilePermissionError -> FilePath)
-> ([VRFPrivateKeyFilePermissionError] -> FilePath -> FilePath)
-> Show VRFPrivateKeyFilePermissionError
forall a.
(Int -> a -> FilePath -> FilePath)
-> (a -> FilePath) -> ([a] -> FilePath -> FilePath) -> Show a
$cshowsPrec :: Int -> VRFPrivateKeyFilePermissionError -> FilePath -> FilePath
showsPrec :: Int -> VRFPrivateKeyFilePermissionError -> FilePath -> FilePath
$cshow :: VRFPrivateKeyFilePermissionError -> FilePath
show :: VRFPrivateKeyFilePermissionError -> FilePath
$cshowList :: [VRFPrivateKeyFilePermissionError] -> FilePath -> FilePath
showList :: [VRFPrivateKeyFilePermissionError] -> FilePath -> FilePath
Show