foundationdb-haskell-0.1.0.0: FoundationDB C client bindings
Safe HaskellNone
LanguageHaskell2010

FoundationDB.Layer.Directory.Internal

Description

This module is a relatively direct translation of the official directory layer code in Python and Go.

Synopsis

Documentation

data DirectoryLayer Source #

Represents a directory tree. A value of this type must be supplied to all functions in this module.

Constructors

DirectoryLayer 

Fields

type Path = [Text] Source #

A path is a list of unicode strings.

dirSubspace :: Directory -> Subspace Source #

Gets the content subspace of a directory, which can be used to store tuple-based keys.

dirPath :: Directory -> Path Source #

Gets the path of a directory.

dirLayer :: Directory -> ByteString Source #

Gets the layer tag that was specified when the directory was created.

newDirectoryLayer Source #

Arguments

:: 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.

open' Source #

Arguments

:: 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.

createOrOpen' Source #

Arguments

:: 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.

data MoveError Source #

Represents all ways move may fail.

Constructors

SelfSubDir

returned by move if you attempt to move a directory into a subdirectory of itself.

SourceDoesNotExist

Returned by move if the source subdirectory does not exist.

MoveBetweenPartitions

Returned by move if you attempt to move a directory from one partition to another.

DestinationAlreadyExists

Returned by move if the destination directory already exists.

DestinationParentDoesNotExist

Returned by move if the parent of the destination directory doesn't already exist.

CannotMoveToRoot

Returned by move if the destination path is the root path.

move Source #

Arguments

:: 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.

removeRecursive Source #

Arguments

:: 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.

find :: DirectoryLayer -> Path -> Transaction (Maybe FoundNode) Source #

Returns the longest prefix of path that doesn't exist. If the entire path exists, returns it.