Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module is a relatively direct translation of the official directory layer code in Python and Go.
Synopsis
- _SUBDIRS :: Integer
- majorVersion :: Word32
- minorVersion :: Word32
- microVersion :: Word32
- throwing :: String -> Either a b -> Transaction b
- data DirectoryLayer = DirectoryLayer {}
- type Path = [Text]
- data Directory = Directory {}
- dirSubspace :: Directory -> Subspace
- dirPath :: Directory -> Path
- dirLayer :: Directory -> ByteString
- data DirPartition = DirPartition {}
- newDirectoryLayer :: Subspace -> Subspace -> Bool -> DirectoryLayer
- defaultDirLayer :: DirectoryLayer
- open :: DirectoryLayer -> Path -> Transaction (Maybe Directory)
- createOrOpen :: DirectoryLayer -> Path -> Transaction Directory
- open' :: DirectoryLayer -> Path -> ByteString -> Maybe ByteString -> Transaction (Maybe Directory)
- createOrOpen' :: DirectoryLayer -> Path -> ByteString -> Maybe ByteString -> Transaction Directory
- exists :: DirectoryLayer -> Path -> Transaction Bool
- list :: DirectoryLayer -> Path -> Transaction (Seq Text)
- data MoveError
- move :: DirectoryLayer -> Path -> Path -> Transaction (Maybe MoveError)
- remove :: DirectoryLayer -> Path -> Transaction Bool
- removeRecursive :: DirectoryLayer -> Subspace -> Transaction ()
- removeFromParent :: DirectoryLayer -> Path -> Transaction ()
- subdirNameNodes :: DirectoryLayer -> Subspace -> Transaction (Seq (Text, Subspace))
- subdirNames :: DirectoryLayer -> Subspace -> Transaction (Seq Text)
- subdirNodes :: DirectoryLayer -> Subspace -> Transaction (Seq Subspace)
- nodeContainingKey :: DirectoryLayer -> ByteString -> Transaction (Maybe Subspace)
- isPrefixFree :: DirectoryLayer -> ByteString -> Transaction Bool
- checkVersion :: DirectoryLayer -> Transaction ()
- initializeDirectory :: DirectoryLayer -> Transaction ()
- nodeWithPrefix :: DirectoryLayer -> ByteString -> Subspace
- find :: DirectoryLayer -> Path -> Transaction (Maybe FoundNode)
- contentsOfNodePartition :: DirectoryLayer -> Subspace -> Path -> Transaction DirPartition
- contentsOfNodeSubspace :: DirectoryLayer -> Subspace -> Path -> ByteString -> Transaction Directory
Documentation
data DirectoryLayer Source #
Represents a directory tree. A value of this type must be supplied to all functions in this module.
Instances
Eq DirectoryLayer Source # | |
Defined in FoundationDB.Layer.Directory.Internal (==) :: DirectoryLayer -> DirectoryLayer -> Bool # (/=) :: DirectoryLayer -> DirectoryLayer -> Bool # | |
Ord DirectoryLayer Source # | |
Defined in FoundationDB.Layer.Directory.Internal compare :: DirectoryLayer -> DirectoryLayer -> Ordering # (<) :: DirectoryLayer -> DirectoryLayer -> Bool # (<=) :: DirectoryLayer -> DirectoryLayer -> Bool # (>) :: DirectoryLayer -> DirectoryLayer -> Bool # (>=) :: DirectoryLayer -> DirectoryLayer -> Bool # max :: DirectoryLayer -> DirectoryLayer -> DirectoryLayer # min :: DirectoryLayer -> DirectoryLayer -> DirectoryLayer # | |
Show DirectoryLayer Source # | |
Defined in FoundationDB.Layer.Directory.Internal showsPrec :: Int -> DirectoryLayer -> ShowS # show :: DirectoryLayer -> String # showList :: [DirectoryLayer] -> ShowS # |
Represents a single directory.
dirSubspace :: Directory -> Subspace Source #
Gets the content subspace of a directory, which can be used to store tuple-based keys.
dirLayer :: Directory -> ByteString Source #
Gets the layer tag that was specified when the directory was created.
data DirPartition Source #
Instances
Eq DirPartition Source # | |
Defined in FoundationDB.Layer.Directory.Internal (==) :: DirPartition -> DirPartition -> Bool # (/=) :: DirPartition -> DirPartition -> Bool # | |
Ord DirPartition Source # | |
Defined in FoundationDB.Layer.Directory.Internal compare :: DirPartition -> DirPartition -> Ordering # (<) :: DirPartition -> DirPartition -> Bool # (<=) :: DirPartition -> DirPartition -> Bool # (>) :: DirPartition -> DirPartition -> Bool # (>=) :: DirPartition -> DirPartition -> Bool # max :: DirPartition -> DirPartition -> DirPartition # min :: DirPartition -> DirPartition -> DirPartition # | |
Show DirPartition Source # | |
Defined in FoundationDB.Layer.Directory.Internal showsPrec :: Int -> DirPartition -> ShowS # show :: DirPartition -> String # showList :: [DirPartition] -> ShowS # |
:: Subspace | node subspace for directory metadata |
-> Subspace | content subspace |
-> Bool | allow manual prefixes |
-> DirectoryLayer |
Creates a new directory layer, containing a hierarchy of directories.
defaultDirLayer :: DirectoryLayer Source #
The default directory layer has node subspace prefix 0xfe
.
This corresponds to using the defaults for all arguments to the
DirectoryLayer
constructor in other languages' bindings.
open :: DirectoryLayer -> Path -> Transaction (Maybe Directory) Source #
Tries to open a directory at the given path.
If the directory exists, returns it. Otherwise, returns Nothing
.
createOrOpen :: DirectoryLayer -> Path -> Transaction Directory Source #
Opens a directory at the given path. If the directory does not exist, it is created.
:: DirectoryLayer | |
-> Path | |
-> ByteString | layer |
-> Maybe ByteString | optional custom prefix |
-> Transaction (Maybe Directory) |
Open a directory, with optional custom prefix and layer.
Returns Nothing
if the directory doesn't exist.
:: DirectoryLayer | |
-> Path | |
-> ByteString | layer |
-> Maybe ByteString | optional custom prefix |
-> Transaction Directory |
Opens a directory at the given path, with optional custom prefix and layer.
exists :: DirectoryLayer -> Path -> Transaction Bool Source #
Returns True
iff the given path exists.
list :: DirectoryLayer -> Path -> Transaction (Seq Text) Source #
List the names of the immediate subdirectories of a directory. Returns an empty list if the directory does not exist.
Represents all ways move
may fail.
SelfSubDir | returned by |
SourceDoesNotExist | Returned by |
MoveBetweenPartitions | Returned by |
DestinationAlreadyExists | Returned by |
DestinationParentDoesNotExist | Returned by |
CannotMoveToRoot | Returned by |
:: DirectoryLayer | |
-> Path | from path |
-> Path | to path |
-> Transaction (Maybe MoveError) |
Move a directory from one path to another. Returns Just err
if an error
occurred. If an error is returned, the directory structure is left
unchanged.
remove :: DirectoryLayer -> Path -> Transaction Bool Source #
Remove a directory path, its contents, and all subdirectories.
Returns True
if removal succeeds. Fails for nonexistent paths and the root
directory. In cases of failure, the directory structure is unchanged.
:: DirectoryLayer | |
-> Subspace | node |
-> Transaction () |
Internal helper function that removes all subdirectories of the given node subspace. Does not remove the given node from its parent.
removeFromParent :: DirectoryLayer -> Path -> Transaction () Source #
Internal helper function that removes a path from its parent. Does not remove the children of the removed path.
:: DirectoryLayer | |
-> Subspace | node |
-> Transaction (Seq (Text, Subspace)) |
subdirNames :: DirectoryLayer -> Subspace -> Transaction (Seq Text) Source #
subdirNodes :: DirectoryLayer -> Subspace -> Transaction (Seq Subspace) Source #
nodeContainingKey :: DirectoryLayer -> ByteString -> Transaction (Maybe Subspace) Source #
isPrefixFree :: DirectoryLayer -> ByteString -> Transaction Bool Source #
checkVersion :: DirectoryLayer -> Transaction () Source #
initializeDirectory :: DirectoryLayer -> Transaction () Source #
nodeWithPrefix :: DirectoryLayer -> ByteString -> Subspace Source #
find :: DirectoryLayer -> Path -> Transaction (Maybe FoundNode) Source #
Returns the longest prefix of path
that doesn't exist. If the entire
path exists, returns it.
contentsOfNodePartition Source #
:: DirectoryLayer | |
-> Subspace | node |
-> Path | |
-> Transaction DirPartition |
contentsOfNodeSubspace :: DirectoryLayer -> Subspace -> Path -> ByteString -> Transaction Directory Source #