Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.Snapshot.Codec
Description
Encoders and decoders for snapshot metadata
Synopsis
- data SnapshotVersion = V0
- prettySnapshotVersion :: SnapshotVersion -> String
- currentSnapshotVersion :: SnapshotVersion
- writeFileSnapshotMetaData :: MonadThrow m => HasFS m h -> FsPath -> FsPath -> SnapshotMetaData -> m ()
- readFileSnapshotMetaData :: MonadThrow m => HasFS m h -> FsPath -> FsPath -> m SnapshotMetaData
- encodeSnapshotMetaData :: SnapshotMetaData -> ByteString
- class Encode a where
- class Decode a where
- class DecodeVersioned a where
- decodeVersioned :: SnapshotVersion -> Decoder s a
- newtype Versioned a = Versioned {
- getVersioned :: a
Versioning
data SnapshotVersion Source #
The version of a snapshot.
A snapshot format version is a number. Version numbers are consecutive and increasing. A single release of the library may support several older snapshot format versions, and thereby provide backwards compatibility. Support for old versions is not guaranteed indefinitely, but backwards compatibility is guaranteed for at least the previous version, and preferably for more. Forwards compatibility is not provided at all: snapshots with a later version than the current version for the library release will always fail.
Constructors
V0 |
Instances
Show SnapshotVersion Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods showsPrec :: Int -> SnapshotVersion -> ShowS # show :: SnapshotVersion -> String # showList :: [SnapshotVersion] -> ShowS # | |
Eq SnapshotVersion Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods (==) :: SnapshotVersion -> SnapshotVersion -> Bool # (/=) :: SnapshotVersion -> SnapshotVersion -> Bool # | |
Decode SnapshotVersion Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decode :: Decoder s SnapshotVersion Source # | |
Encode SnapshotVersion Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods encode :: SnapshotVersion -> Encoding Source # |
Writing and reading files
writeFileSnapshotMetaData Source #
Arguments
:: MonadThrow m | |
=> HasFS m h | |
-> FsPath | Target file for snapshot metadata |
-> FsPath | Target file for checksum |
-> SnapshotMetaData | |
-> m () |
Encode SnapshotMetaData
and write it to SnapshotMetaDataFile
.
In the presence of exceptions, newly created files will not be removed. It is up to the user of this function to clean up the files.
readFileSnapshotMetaData Source #
Arguments
:: MonadThrow m | |
=> HasFS m h | |
-> FsPath | Source file for snapshot metadata |
-> FsPath | Source file for checksum |
-> m SnapshotMetaData |
Read from SnapshotMetaDataFile
and attempt to decode it to
SnapshotMetaData
.
Encoding and decoding
Instances
Decoder that is not parameterised by a SnapshotVersion
.
Used only for SnapshotVersion
and Versioned
, which live outside the
SnapshotMetaData
type hierarchy.
Instances
Decode SnapshotVersion Source # | |
Defined in Database.LSMTree.Internal.Snapshot.Codec Methods decode :: Decoder s SnapshotVersion Source # | |
DecodeVersioned a => Decode (Versioned a) Source # | Decodes a |
class DecodeVersioned a where Source #
Decoder parameterised by a SnapshotVersion
.
Used for every type in the SnapshotMetaData
type hierarchy.
Methods
decodeVersioned :: SnapshotVersion -> Decoder s a Source #
Instances
Constructors
Versioned | |
Fields
|