| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Api.IO
Synopsis
- readByteStringFile :: MonadIO m => File content 'In -> m (Either (FileError e) ByteString)
- readLazyByteStringFile :: MonadIO m => File content 'In -> m (Either (FileError e) ByteString)
- readTextFile :: MonadIO m => File content 'In -> m (Either (FileError e) Text)
- readFileBlocking :: FilePath -> IO ByteString
- writeByteStringFileWithOwnerPermissions :: MonadIO m => FilePath -> ByteString -> m (Either (FileError e) ())
- writeByteStringFile :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ())
- writeByteStringOutput :: MonadIO m => Maybe (File content 'Out) -> ByteString -> m (Either (FileError e) ())
- writeLazyByteStringFileWithOwnerPermissions :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ())
- writeLazyByteStringFile :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ())
- writeLazyByteStringOutput :: MonadIO m => Maybe (File content 'Out) -> ByteString -> m (Either (FileError e) ())
- writeTextFileWithOwnerPermissions :: MonadIO m => File content 'Out -> Text -> m (Either (FileError e) ())
- writeTextFile :: MonadIO m => File content 'Out -> Text -> m (Either (FileError e) ())
- writeTextOutput :: MonadIO m => Maybe (File content 'Out) -> Text -> m (Either (FileError e) ())
- newtype File content (direction :: FileDirection) = File {}
- data FileDirection
- type SocketPath = File Socket 'InOut
- mapFile :: forall content (direction :: FileDirection). (FilePath -> FilePath) -> File content direction -> File content direction
- onlyIn :: File content 'InOut -> File content 'In
- onlyOut :: File content 'InOut -> File content 'Out
- intoFile :: File content 'Out -> content -> (File content 'Out -> stream -> result) -> (content -> stream) -> result
- checkVrfFilePermissions :: forall content (direction :: FileDirection). File content direction -> ExceptT VRFPrivateKeyFilePermissionError IO ()
- writeSecrets :: (HasCallStack, MonadIO m) => FilePath -> [Char] -> [Char] -> (a -> ByteString) -> [a] -> m ()
Documentation
readByteStringFile :: MonadIO m => File content 'In -> m (Either (FileError e) ByteString) Source #
readLazyByteStringFile :: MonadIO m => File content 'In -> m (Either (FileError e) ByteString) Source #
readFileBlocking :: FilePath -> IO ByteString Source #
writeByteStringFileWithOwnerPermissions :: MonadIO m => FilePath -> ByteString -> m (Either (FileError e) ()) Source #
Like writeByteStringFile, but the file is created readable and
writable only by its owner (0600 on POSIX), and it is replaced
atomically: the contents are written to a temporary file which is then
renamed over the target path, so a failed write never destroys the
previous contents. The detailed per-platform guarantees are documented on
writeFileTextEnvelopeWithOwnerPermissions in
Cardano.Api.Serialise.TextEnvelope.
writeByteStringFile :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ()) Source #
writeByteStringOutput :: MonadIO m => Maybe (File content 'Out) -> ByteString -> m (Either (FileError e) ()) Source #
writeLazyByteStringFileWithOwnerPermissions :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ()) Source #
Like writeLazyByteStringFile, but with the same owner-only
permissions and atomic replacement as
writeByteStringFileWithOwnerPermissions.
writeLazyByteStringFile :: MonadIO m => File content 'Out -> ByteString -> m (Either (FileError e) ()) Source #
writeLazyByteStringOutput :: MonadIO m => Maybe (File content 'Out) -> ByteString -> m (Either (FileError e) ()) Source #
writeTextFileWithOwnerPermissions :: MonadIO m => File content 'Out -> Text -> m (Either (FileError e) ()) Source #
Like writeTextFile, but with the same owner-only permissions and
atomic replacement as writeByteStringFileWithOwnerPermissions.
writeTextOutput :: MonadIO m => Maybe (File content 'Out) -> Text -> m (Either (FileError e) ()) Source #
newtype File content (direction :: FileDirection) Source #
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.
Instances
| FromJSON (File content direction) Source # | |
Defined in Cardano.Api.IO.Internal.Base Methods parseJSON :: Value -> Parser (File content direction) # parseJSONList :: Value -> Parser [File content direction] # omittedField :: Maybe (File content direction) # | |
| ToJSON (File content direction) Source # | |
Defined in Cardano.Api.IO.Internal.Base | |
| Eq (File content direction) Source # | |
| Ord (File content direction) Source # | |
Defined in Cardano.Api.IO.Internal.Base Methods compare :: File content direction -> File content direction -> Ordering Source # (<) :: File content direction -> File content direction -> Bool Source # (<=) :: File content direction -> File content direction -> Bool Source # (>) :: File content direction -> File content direction -> Bool Source # (>=) :: File content direction -> File content direction -> Bool Source # max :: File content direction -> File content direction -> File content direction Source # min :: File content direction -> File content direction -> File content direction Source # | |
| IsString (File content direction) Source # | |
Defined in Cardano.Api.IO.Internal.Base Methods fromString :: String -> File content direction Source # | |
| Read (File content direction) Source # | |
| Show (File content direction) Source # | |
data FileDirection Source #
type SocketPath = File Socket 'InOut Source #
mapFile :: forall content (direction :: FileDirection). (FilePath -> FilePath) -> File content direction -> File content direction Source #
intoFile :: File content 'Out -> content -> (File content 'Out -> stream -> result) -> (content -> stream) -> result Source #
Given a way to serialise a value and a way to write the stream to a file, serialise a value into a stream, and write it to a file.
Whilst it is possible to call the serialisation and writing functions separately, doing so means the compiler is unable to match the content type of the file with the type of the content being serialised.
Using this function ensures that the content type of the file always matches with the content value and prevents any type mismatches.
checkVrfFilePermissions :: forall content (direction :: FileDirection). File content direction -> ExceptT VRFPrivateKeyFilePermissionError IO () Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => FilePath | Output directory |
| -> [Char] | Filename prefix |
| -> [Char] | Filename suffix |
| -> (a -> ByteString) | Serialisation function for the secrets |
| -> [a] | Secrets to write, one file each |
| -> m () |
Write a list of secrets to individual files in the given directory, as
<prefix>.<3-digit index>.<suffix>. Each file is written atomically
(the contents go to a temporary file which is then renamed into place) and
ends up readable only by its owner.