ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.FS.API

Description

An abstract view over the filesystem.

Synopsis

Documentation

data HasFS m h Source #

Constructors

HasFS 

Fields

Instances

Instances details
NoThunks (HasFS m h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API

data Handle h Source #

Constructors

Handle 

Fields

  • handleRaw :: !h

    The raw underlying handle

  • handlePath :: !FsPath

    The path corresponding to this handle

    This is primarily useful for error reporting.

Instances

Instances details
Eq h => Eq (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Methods

(==) :: Handle h -> Handle h -> Bool #

(/=) :: Handle h -> Handle h -> Bool #

Show (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Methods

showsPrec :: Int -> Handle h -> ShowS #

show :: Handle h -> String #

showList :: [Handle h] -> ShowS #

Generic (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Associated Types

type Rep (Handle h) :: Type -> Type #

Methods

from :: Handle h -> Rep (Handle h) x #

to :: Rep (Handle h) x -> Handle h #

NoThunks (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Condense (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Methods

condense :: Handle h -> String Source #

type Rep (Handle h) Source # 
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

type Rep (Handle h) = D1 ('MetaData "Handle" "Ouroboros.Consensus.Storage.FS.API.Types" "ouroboros-consensus-0.1.0.0-GfJNvFcM6lj2s5utKAUPEp" 'False) (C1 ('MetaCons "Handle" 'PrefixI 'True) (S1 ('MetaSel ('Just "handleRaw") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 h) :*: S1 ('MetaSel ('Just "handlePath") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FsPath)))

hGetExactly :: forall m h. (HasCallStack, MonadThrow m) => HasFS m h -> Handle h -> Word64 -> m ByteString Source #

Makes sure it reads all requested bytes. If eof is found before all bytes are read, it throws an exception.

hGetExactlyAt Source #

Arguments

:: forall m h. (HasCallStack, MonadThrow m) 
=> HasFS m h 
-> Handle h 
-> Word64

The number of bytes to read.

-> AbsOffset

The offset at which to read.

-> m ByteString 

Like hGetExactly, but is thread safe since it does not change or depend on the file offset. pread syscall is used internally.

hGetAll :: Monad m => HasFS m h -> Handle h -> m ByteString Source #

Read all the data from the given file handle 64kB at a time.

Stops when EOF is reached.

hGetAllAt Source #

Arguments

:: Monad m 
=> HasFS m h 
-> Handle h 
-> AbsOffset

The offset at which to read.

-> m ByteString 

Like hGetAll, but is thread safe since it does not change or depend on the file offset. pread syscall is used internally.

hPut :: forall m h. (HasCallStack, Monad m) => HasFS m h -> Handle h -> Builder -> m Word64 Source #

This function makes sure that the whole Builder is written.

The chunk size of the resulting ByteString determines how much memory will be used while writing to the handle.

hPutAll :: forall m h. (HasCallStack, Monad m) => HasFS m h -> Handle h -> ByteString -> m Word64 Source #

This function makes sure that the whole ByteString is written.

hPutAllStrict :: forall m h. (HasCallStack, Monad m) => HasFS m h -> Handle h -> ByteString -> m Word64 Source #

This function makes sure that the whole ByteString is written.

withFile :: (HasCallStack, MonadThrow m) => HasFS m h -> FsPath -> OpenMode -> (Handle h -> m a) -> m a Source #

hClose' :: (HasCallStack, Monad m) => HasFS m h -> Handle h -> m Bool Source #

Returns True when the handle was still open.

data SomeHasFS m where Source #

It is often inconvenient to have to parameterise over h. One often makes it existential, losing the ability to use derive Generic and NoThunks. This data type hides an existential h parameter of a HasFS and provides a NoThunks thunks instance.

Constructors

SomeHasFS :: Eq h => HasFS m h -> SomeHasFS m