-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings for libmdbx, an embedded key/value store -- -- Haskell bindings for libmdbx. -- -- See documentation in the main module or check the README on -- GitHub. @package libmdbx @version 0.2.0.0 -- | Low level bindings to libmdbx functions. module Mdbx.FFI -- | Flags for opening an environment. data MdbxEnvFlags MdbxEnvDefaults :: MdbxEnvFlags MdbxSyncDurable :: MdbxEnvFlags MdbxNosubdir :: MdbxEnvFlags MdbxSafeNosync :: MdbxEnvFlags MdbxMapasync :: MdbxEnvFlags MdbxRdonly :: MdbxEnvFlags MdbxNometasync :: MdbxEnvFlags MdbxWritemap :: MdbxEnvFlags MdbxUtterlyNosync :: MdbxEnvFlags MdbxNotls :: MdbxEnvFlags MdbxExclusive :: MdbxEnvFlags MdbxNordahead :: MdbxEnvFlags MdbxNomeminit :: MdbxEnvFlags MdbxCoalesce :: MdbxEnvFlags MdbxLiforeclaim :: MdbxEnvFlags MdbxPageperturb :: MdbxEnvFlags MdbxAccede :: MdbxEnvFlags -- | Environment object, needed for all the operations. newtype MdbxEnv MdbxEnv :: Ptr MdbxEnv -> MdbxEnv -- | UNIX permissions to set on created files. Zero value means to open -- existing, but do not create. type MdbxEnvMode = (CUInt) -- | Creates an environment. Represents a database in the file system. mdbx_env_create :: IO (Int, MdbxEnv) -- | Sets geometry of an environment. All the parameters can receive -1 to -- keep the current value. Receives (expressed in bytes): size_lower, -- size_now, size_upper, growth_step, shrink_threshold, pagesize. mdbx_env_set_geometry :: MdbxEnv -> Int -> Int -> Int -> Int -> Int -> Int -> IO Int -- | Opens an environment. Receives name, flags and mode. mdbx_env_open :: MdbxEnv -> String -> [MdbxEnvFlags] -> MdbxEnvMode -> IO Int -- | Closes an environment. mdbx_env_close :: MdbxEnv -> IO Int -- | Flags for a transaction. data MdbxTxnFlags MdbxTxnReadwrite :: MdbxTxnFlags MdbxTxnNosync :: MdbxTxnFlags MdbxTxnRdonly :: MdbxTxnFlags MdbxTxnNometasync :: MdbxTxnFlags MdbxTxnRdonlyPrepare :: MdbxTxnFlags MdbxTxnTry :: MdbxTxnFlags -- | Transaction instance. Needed for all operations with data, even -- reading. newtype MdbxTxn MdbxTxn :: Ptr MdbxTxn -> MdbxTxn -- | Begins a new transaction. -- -- Arguments: -- -- mdbx_txn_begin :: MdbxEnv -> Maybe MdbxTxn -> [MdbxTxnFlags] -> IO (Int, MdbxTxn) -- | Commits a transaction. mdbx_txn_commit :: MdbxTxn -> IO Int -- | Aborts a transaction. mdbx_txn_abort :: MdbxTxn -> IO Int -- | Gets the environment from a transaction. mdbx_txn_env :: MdbxTxn -> IO MdbxEnv -- | Flags for a database. data MdbxDbFlags MdbxDbDefaults :: MdbxDbFlags MdbxReversekey :: MdbxDbFlags MdbxDupsort :: MdbxDbFlags MdbxIntegerkey :: MdbxDbFlags MdbxDupfixed :: MdbxDbFlags MdbxIntegerdup :: MdbxDbFlags MdbxReversedup :: MdbxDbFlags MdbxCreate :: MdbxDbFlags MdbxDbAccede :: MdbxDbFlags -- | Database instance. Represents a logical table in the database. type MdbxDbi = (CUInt) -- | Opens a database. -- -- Arguments: -- -- mdbx_dbi_open :: MdbxTxn -> Maybe String -> [MdbxDbFlags] -> IO (Int, MdbxDbi) -- | Closes a database. mdbx_dbi_close :: MdbxEnv -> MdbxDbi -> IO Int -- | Binary blob representing a key or value in the database. data MdbxVal MdbxVal :: {-# UNPACK #-} !CULong -> {-# UNPACK #-} !Ptr () -> MdbxVal [mvlSize] :: MdbxVal -> {-# UNPACK #-} !CULong [mvlData] :: MdbxVal -> {-# UNPACK #-} !Ptr () -- | Sample empty value emptyMdbxVal :: MdbxVal -- | Flags for all data related operations. data MdbxPutFlags MdbxUpsert :: MdbxPutFlags MdbxNooverwrite :: MdbxPutFlags MdbxNodupdata :: MdbxPutFlags MdbxCurrent :: MdbxPutFlags MdbxAlldups :: MdbxPutFlags MdbxReserve :: MdbxPutFlags MdbxAppend :: MdbxPutFlags MdbxAppenddup :: MdbxPutFlags MdbxMultiple :: MdbxPutFlags -- | Stores a key/value pair. -- -- Arguments: -- -- mdbx_put :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int -- | Gets a value with the given key. -- -- Arguments: -- -- mdbx_get :: MdbxTxn -> MdbxDbi -> MdbxVal -> IO (Int, MdbxVal) -- | Gets a value with the given key. -- -- Arguments: -- -- mdbx_del :: MdbxTxn -> MdbxDbi -> MdbxVal -> Maybe MdbxVal -> IO Int -- | Flags for cursor operations. data MdbxCursorOp MdbxFirst :: MdbxCursorOp MdbxFirstDup :: MdbxCursorOp MdbxGetBoth :: MdbxCursorOp MdbxGetBothRange :: MdbxCursorOp MdbxGetCurrent :: MdbxCursorOp MdbxGetMultiple :: MdbxCursorOp MdbxLast :: MdbxCursorOp MdbxLastDup :: MdbxCursorOp MdbxNext :: MdbxCursorOp MdbxNextDup :: MdbxCursorOp MdbxNextMultiple :: MdbxCursorOp MdbxNextNodup :: MdbxCursorOp MdbxPrev :: MdbxCursorOp MdbxPrevDup :: MdbxCursorOp MdbxPrevNodup :: MdbxCursorOp MdbxSet :: MdbxCursorOp MdbxSetKey :: MdbxCursorOp MdbxSetRange :: MdbxCursorOp MdbxPrevMultiple :: MdbxCursorOp MdbxSetLowerbound :: MdbxCursorOp -- | Cursor instance. Used for efficient navigation in a database. newtype MdbxCursor MdbxCursor :: Ptr MdbxCursor -> MdbxCursor -- | Opens a new cursor. -- -- Arguments: -- -- mdbx_cursor_open :: MdbxTxn -> MdbxDbi -> IO (Int, MdbxCursor) -- | Closes a cursor. mdbx_cursor_close :: MdbxCursor -> IO () -- | Removes the current key/value pair. mdbx_cursor_del :: MdbxCursor -> [MdbxPutFlags] -> IO Int -- | Returns the current key/value pair. mdbx_cursor_get :: MdbxCursor -> MdbxVal -> MdbxCursorOp -> IO (Int, MdbxVal, MdbxVal) -- | Sets the value for the current key. -- -- Arguments: -- -- mdbx_cursor_put :: MdbxCursor -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> IO Int -- | Returns the count of duplicates in the current key. mdbx_cursor_count :: MdbxCursor -> IO (Int, CSize) -- | Returns the description of a given error number. mdbx_strerror :: Int -> IO String -- | Compares two values as a binary blob. mdbx_cmp :: MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> IO Int -- | Error codes for the different operations. data MdbxError MdbxKeyexist :: MdbxError MdbxFirstLmdbErrcode :: MdbxError MdbxNotfound :: MdbxError MdbxPageNotfound :: MdbxError MdbxCorrupted :: MdbxError MdbxPanic :: MdbxError MdbxVersionMismatch :: MdbxError MdbxInvalid :: MdbxError MdbxMapFull :: MdbxError MdbxDbsFull :: MdbxError MdbxReadersFull :: MdbxError MdbxTxnFull :: MdbxError MdbxCursorFull :: MdbxError MdbxPageFull :: MdbxError MdbxUnableExtendMapsize :: MdbxError MdbxIncompatible :: MdbxError MdbxBadRslot :: MdbxError MdbxBadTxn :: MdbxError MdbxBadValsize :: MdbxError MdbxBadDbi :: MdbxError MdbxProblem :: MdbxError MdbxLastLmdbErrcode :: MdbxError MdbxBusy :: MdbxError MdbxFirstAddedErrcode :: MdbxError MdbxEmultival :: MdbxError MdbxEbadsign :: MdbxError MdbxWannaRecovery :: MdbxError MdbxEkeymismatch :: MdbxError MdbxTooLarge :: MdbxError MdbxThreadMismatch :: MdbxError MdbxTxnOverlapping :: MdbxError MdbxLastAddedErrcode :: MdbxError MdbxResultTrue :: MdbxError MdbxSuccess :: MdbxError MdbxResultFalse :: MdbxError MdbxEperm :: MdbxError MdbxEnofile :: MdbxError MdbxEintr :: MdbxError MdbxEio :: MdbxError MdbxEnomem :: MdbxError MdbxEaccess :: MdbxError MdbxEremote :: MdbxError MdbxEinval :: MdbxError MdbxErofs :: MdbxError MdbxEnosys :: MdbxError MdbxEnodata :: MdbxError -- | Converts a Double value to an unsigned Word that can be used by -- libmdbx's compare function. -- -- Converts a Float value to an unsigned Word that can be used by -- libmdbx's compare function. mdbx_key_from_float :: Float -> Word32 -- | Converts a 32bits signed Int value to an unsigned Word that can be -- used by libmdbx's compare function. mdbx_key_from_double :: Double -> Word64 -- | Converts a 64bits signed Int value to an unsigned Word that can be -- used by libmdbx's compare function. mdbx_key_from_int32 :: Int32 -> Word32 mdbx_key_from_int64 :: Int64 -> Word64 -- | Converts an unsigned Word to a Float value. mdbx_float_from_key :: Word32 -> Float -- | Converts an unsigned Word to a Double value. mdbx_double_from_key :: Word64 -> Double -- | Converts an unsigned Word value to a 32bits signed Int. mdbx_int32_from_key :: Word32 -> Int32 -- | Converts an unsigned Word value to a 64bits signed Int. mdbx_int64_from_key :: Word64 -> Int64 instance GHC.Classes.Ord Mdbx.FFI.MdbxError instance GHC.Classes.Eq Mdbx.FFI.MdbxError instance GHC.Show.Show Mdbx.FFI.MdbxError instance GHC.Classes.Ord Mdbx.FFI.MdbxEnvFlags instance GHC.Classes.Eq Mdbx.FFI.MdbxEnvFlags instance GHC.Show.Show Mdbx.FFI.MdbxEnvFlags instance GHC.Classes.Ord Mdbx.FFI.MdbxTxnFlags instance GHC.Classes.Eq Mdbx.FFI.MdbxTxnFlags instance GHC.Show.Show Mdbx.FFI.MdbxTxnFlags instance GHC.Classes.Ord Mdbx.FFI.MdbxDbFlags instance GHC.Classes.Eq Mdbx.FFI.MdbxDbFlags instance GHC.Show.Show Mdbx.FFI.MdbxDbFlags instance GHC.Show.Show Mdbx.FFI.MdbxVal instance GHC.Classes.Eq Mdbx.FFI.MdbxVal instance GHC.Classes.Ord Mdbx.FFI.MdbxPutFlags instance GHC.Classes.Eq Mdbx.FFI.MdbxPutFlags instance GHC.Show.Show Mdbx.FFI.MdbxPutFlags instance GHC.Enum.Enum Mdbx.FFI.MdbxCursorOp instance GHC.Classes.Ord Mdbx.FFI.MdbxCursorOp instance GHC.Classes.Eq Mdbx.FFI.MdbxCursorOp instance GHC.Show.Show Mdbx.FFI.MdbxCursorOp instance Foreign.Storable.Storable Mdbx.FFI.MdbxEnv instance Foreign.Storable.Storable Mdbx.FFI.MdbxTxn instance Foreign.Storable.Storable Mdbx.FFI.MdbxCursor instance GHC.Enum.Enum Mdbx.FFI.MdbxPutFlags instance Foreign.Storable.Storable Mdbx.FFI.MdbxVal instance GHC.Enum.Enum Mdbx.FFI.MdbxDbFlags instance GHC.Enum.Enum Mdbx.FFI.MdbxTxnFlags instance GHC.Enum.Enum Mdbx.FFI.MdbxEnvFlags instance GHC.Enum.Enum Mdbx.FFI.MdbxError -- | Types used by the library. Mainly re exports the types generated by -- c2hs in the FFI module, while it also adds some types used by the high -- level interface. module Mdbx.Types -- | Environment object, needed for all the operations. data MdbxEnv -- | Transaction instance. Needed for all operations with data, even -- reading. data MdbxTxn -- | Database instance. Represents a logical table in the database. type MdbxDbi = (CUInt) -- | Binary blob representing a key or value in the database. data MdbxVal MdbxVal :: {-# UNPACK #-} !CULong -> {-# UNPACK #-} !Ptr () -> MdbxVal [mvlSize] :: MdbxVal -> {-# UNPACK #-} !CULong [mvlData] :: MdbxVal -> {-# UNPACK #-} !Ptr () -- | UNIX permissions to set on created files. Zero value means to open -- existing, but do not create. type MdbxEnvMode = (CUInt) -- | Flags for opening an environment. data MdbxEnvFlags MdbxEnvDefaults :: MdbxEnvFlags MdbxSyncDurable :: MdbxEnvFlags MdbxNosubdir :: MdbxEnvFlags MdbxSafeNosync :: MdbxEnvFlags MdbxMapasync :: MdbxEnvFlags MdbxRdonly :: MdbxEnvFlags MdbxNometasync :: MdbxEnvFlags MdbxWritemap :: MdbxEnvFlags MdbxUtterlyNosync :: MdbxEnvFlags MdbxNotls :: MdbxEnvFlags MdbxExclusive :: MdbxEnvFlags MdbxNordahead :: MdbxEnvFlags MdbxNomeminit :: MdbxEnvFlags MdbxCoalesce :: MdbxEnvFlags MdbxLiforeclaim :: MdbxEnvFlags MdbxPageperturb :: MdbxEnvFlags MdbxAccede :: MdbxEnvFlags -- | Flags for a transaction. data MdbxTxnFlags MdbxTxnReadwrite :: MdbxTxnFlags MdbxTxnNosync :: MdbxTxnFlags MdbxTxnRdonly :: MdbxTxnFlags MdbxTxnNometasync :: MdbxTxnFlags MdbxTxnRdonlyPrepare :: MdbxTxnFlags MdbxTxnTry :: MdbxTxnFlags -- | Flags for a database. data MdbxDbFlags MdbxDbDefaults :: MdbxDbFlags MdbxReversekey :: MdbxDbFlags MdbxDupsort :: MdbxDbFlags MdbxIntegerkey :: MdbxDbFlags MdbxDupfixed :: MdbxDbFlags MdbxIntegerdup :: MdbxDbFlags MdbxReversedup :: MdbxDbFlags MdbxCreate :: MdbxDbFlags MdbxDbAccede :: MdbxDbFlags -- | Flags for all data related operations. data MdbxPutFlags MdbxUpsert :: MdbxPutFlags MdbxNooverwrite :: MdbxPutFlags MdbxNodupdata :: MdbxPutFlags MdbxCurrent :: MdbxPutFlags MdbxAlldups :: MdbxPutFlags MdbxReserve :: MdbxPutFlags MdbxAppend :: MdbxPutFlags MdbxAppenddup :: MdbxPutFlags MdbxMultiple :: MdbxPutFlags -- | Flags for cursor operations. data MdbxCursorOp MdbxFirst :: MdbxCursorOp MdbxFirstDup :: MdbxCursorOp MdbxGetBoth :: MdbxCursorOp MdbxGetBothRange :: MdbxCursorOp MdbxGetCurrent :: MdbxCursorOp MdbxGetMultiple :: MdbxCursorOp MdbxLast :: MdbxCursorOp MdbxLastDup :: MdbxCursorOp MdbxNext :: MdbxCursorOp MdbxNextDup :: MdbxCursorOp MdbxNextMultiple :: MdbxCursorOp MdbxNextNodup :: MdbxCursorOp MdbxPrev :: MdbxCursorOp MdbxPrevDup :: MdbxCursorOp MdbxPrevNodup :: MdbxCursorOp MdbxSet :: MdbxCursorOp MdbxSetKey :: MdbxCursorOp MdbxSetRange :: MdbxCursorOp MdbxPrevMultiple :: MdbxCursorOp MdbxSetLowerbound :: MdbxCursorOp -- | Geometry of the database. The most important parameter is the maximum -- size, that defaults to 1024Mb. All other values default to -1, meaning -- the current value will be kept. data MdbxEnvGeometry MdbxEnvGeometry :: Int -> Int -> Int -> Int -> Int -> Int -> MdbxEnvGeometry -- | Minimum DB size in bytes. [envSizeMin] :: MdbxEnvGeometry -> Int -- | Current DB size in bytes. [envSizeNow] :: MdbxEnvGeometry -> Int -- | Maximum DB size in bytes. [envSizeMax] :: MdbxEnvGeometry -> Int -- | Step growth size of the database in bytes. Must be greater than zero -- to allow for growth. [envGrowthStep] :: MdbxEnvGeometry -> Int -- | Step shrink size of the database in bytes. Must be greater than zero -- to allow for shrinkage and lower than envGrowthStep to avoid immediate -- shrinking after growth. [envShrinkThreshold] :: MdbxEnvGeometry -> Int -- | Page size of the database in bytes. In general it should not be -- changed after the database was created. [envPageSize] :: MdbxEnvGeometry -> Int -- | Converts an instance to/from the representation needed by libmdbx. -- This type is used for both keys and values. The fields on the type -- must be strict, otherwise unexpected crashes due to lazy IO delaying -- low level memory access may happen. -- -- Only ByteString, Text instances are provided, since they -- are commonly used as the key when storing/retrieving a value. -- -- For your own types, in general, you will want to use a serialization -- library such as binary, and apply the newtype deriving via -- trick. -- -- MdbxItemBinary is provided to simplify using Binary -- instances as keys or values with libmdbx, while MdbxItemStore -- provides the same functionality for Store instances. With those -- helpers, creating custom types compatible with libmdbx is easy: -- --
--   data User = User {
--     _username :: !Text,
--     _password :: !Text
--   } deriving (Eq, Show, Generic, Store)
--   
--   deriving via (MdbxItemBinary User) instance MdbxItem User
--   
-- -- Note 1: if you plan on using a custom type as the key, be -- careful if it contains Text or ByteString instances, -- since these types have a length field which is serialized before the -- data. This causes issues when using libmdbx, since it depends on key -- ordering and the length field will make shorter instances lower than -- longer ones, even if the content indicates the opposite. You can use -- the provided NullByteString or NullText types if your -- data type is an instance of Binary or Store. Otherwise, -- it is simpler to use Text or ByteString as the key. -- -- Note 2: If your key type contains Word16 or longer fields, you -- should make it an instance of Binary, not Store, since -- Store uses platform dependent endianess and this affects libmdbx's -- comparison functions. Given Binary uses network order (big endian) for -- encoding, the comparison functions will work as expected. Failing to -- do this may cause unexpected issues when retrieving data, in -- particular when using cursors. -- -- Note 3: The behavior when using signed integers or floating -- point numbers as part of the key is undefined. To be able to use these -- types in the key, you should store them as a Word of the appropriate -- size and convert them with the conversion functions included in -- API. class MdbxItem i -- | Converts a block of memory provided by libmdbx to a user data type. -- There are no guarantees provided by the library that the block of -- memory matches the expected type; a crash can happen when trying to -- deserialize an incorrect type. fromMdbxVal :: MdbxItem i => MdbxVal -> IO i -- | Converts a user data type to a block of memory. toMdbxVal :: MdbxItem i => i -> (MdbxVal -> IO b) -> IO b -- | Newtype wrapping a ByteString that provides a Binary -- instance using NULL terminated C strings, which allows for using them -- as part of a custom data type representing a key. -- -- This is not possible with regular ByteString and Text -- instances since their Binary instances are serialized with the -- size field first. Given that libmdbx compares keys as an unstructured -- sequence of bytes, this can cause issues since longer strings are -- considered greater than shorter ones, even if their content indicates -- otherwise. newtype NullByteString NullByteString :: ShortByteString -> NullByteString [unNullByteString] :: NullByteString -> ShortByteString -- | Newtype wrapping a Text that provides a Binary instance -- using NULL terminated C strings, which allows for using them as part -- of a custom data type representing a key. -- -- Check NullByteString for the rationale. newtype NullText NullText :: Text -> NullText [unNullText] :: NullText -> Text instance GHC.Show.Show Mdbx.Types.MdbxEnvGeometry instance GHC.Classes.Eq Mdbx.Types.MdbxEnvGeometry instance GHC.Classes.Ord Mdbx.Types.NullByteString instance GHC.Classes.Eq Mdbx.Types.NullByteString instance GHC.Classes.Ord Mdbx.Types.NullText instance GHC.Classes.Eq Mdbx.Types.NullText instance GHC.Show.Show Mdbx.Types.NullText instance Data.String.IsString Mdbx.Types.NullText instance GHC.Show.Show Mdbx.Types.NullByteString instance Data.String.IsString Mdbx.Types.NullByteString instance Mdbx.Types.MdbxItem Data.Text.Internal.Text instance Mdbx.Types.MdbxItem Data.ByteString.Internal.ByteString instance Data.Default.Class.Default Mdbx.Types.MdbxEnvGeometry -- | Instances and helpers to derive MdbxItem for Store -- instances. module Mdbx.Store -- | Helper type to derive MdbxItem instances for types implementing -- Store using the newtype deriving trick. newtype MdbxItemStore a MdbxItemStore :: a -> MdbxItemStore a [unwrapStore] :: MdbxItemStore a -> a -- | Deserializes a Store instance from an MdbxVal. fromMdbxStore :: Store v => MdbxVal -> IO v -- | Serializes a Store instance to MdbxVal, and passes it to -- a callback. withMdbxStore :: Store v => v -> (MdbxVal -> IO a) -> IO a instance Data.Store.Impl.Store a => Mdbx.Types.MdbxItem (Mdbx.Store.MdbxItemStore a) instance Data.Store.Impl.Store Mdbx.Types.NullByteString instance Data.Store.Impl.Store Mdbx.Types.NullText -- | Instances and helpers to derive MdbxItem for Binary -- instances. module Mdbx.Binary -- | Helper type to derive MdbxItem instances for types implementing -- Binary using the newtype deriving trick. newtype MdbxItemBinary a MdbxItemBinary :: a -> MdbxItemBinary a [unwrapBinary] :: MdbxItemBinary a -> a instance Mdbx.Types.MdbxItem Mdbx.Types.NullByteString instance Mdbx.Types.MdbxItem Mdbx.Types.NullText instance Data.Binary.Class.Binary a => Mdbx.Types.MdbxItem (Mdbx.Binary.MdbxItemBinary a) instance Data.Binary.Class.Binary Mdbx.Types.NullByteString instance Data.Binary.Class.Binary Mdbx.Types.NullText -- | Thin wrappers over the low level API to provide MonadIO support and -- exception based error handling. module Mdbx.API -- | Compares two keys and returns -1, 0 or 1 if key1 is lower, equal or -- greater than key2. keyCmp :: MonadIO m => MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> m Int -- | Opens an environment. envOpen :: (MonadIO m, MonadFail m) => String -> MdbxEnvGeometry -> [MdbxEnvFlags] -> m MdbxEnv -- | Close an environment. envClose :: (MonadIO m, MonadFail m) => MdbxEnv -> m () -- | Begins a transaction. txnBegin :: (MonadIO m, MonadFail m) => MdbxEnv -> Maybe MdbxTxn -> [MdbxTxnFlags] -> m MdbxTxn -- | Commits a transaction. txnCommit :: (MonadIO m, MonadFail m) => MdbxTxn -> m () -- | Aborts a transaction. txnAbort :: (MonadIO m, MonadFail m) => MdbxTxn -> m () -- | Opens a database (table). dbiOpen :: (MonadIO m, MonadFail m) => MdbxEnv -> Maybe String -> [MdbxDbFlags] -> m MdbxDbi -- | Closes a database. dbiClose :: (MonadIO m, MonadFail m) => MdbxEnv -> MdbxDbi -> m () -- | Saves the provided key/value pair. itemPut :: (MonadIO m, MonadFail m) => MdbxTxn -> MdbxDbi -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> m () -- | Returns the value associated to the given key, if any. itemGet :: (MonadIO m, MonadFail m) => MdbxTxn -> MdbxDbi -> MdbxVal -> m (Maybe MdbxVal) -- | Deletes the value associated with the given key, if any. itemDel :: (MonadIO m, MonadFail m) => MdbxTxn -> MdbxDbi -> MdbxVal -> Maybe MdbxVal -> m () -- | Opens a cursor. cursorOpen :: (MonadIO m, MonadFail m) => MdbxTxn -> MdbxDbi -> m MdbxCursor -- | Closes a cursor. cursorClose :: (MonadIO m, MonadFail m) => MdbxCursor -> m () -- | Stores the provided value at the given key, positioning the cursor on -- it. cursorPut :: (MonadIO m, MonadFail m) => MdbxCursor -> MdbxVal -> MdbxVal -> [MdbxPutFlags] -> m () -- | Deletes the value at the current position. cursorDel :: (MonadIO m, MonadFail m) => MdbxCursor -> [MdbxPutFlags] -> m () -- | Moves to the first key on the database. cursorFirst :: (MonadIO m, MonadFail m) => MdbxCursor -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves to the last key on the database. cursorLast :: (MonadIO m, MonadFail m) => MdbxCursor -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves to the given key. cursorAt :: (MonadIO m, MonadFail m) => MdbxCursor -> MdbxVal -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves to the given key or first greater than it. Useful for searching. cursorRange :: (MonadIO m, MonadFail m) => MdbxCursor -> MdbxVal -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves to the next key. cursorNext :: (MonadIO m, MonadFail m) => MdbxCursor -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves to the previous key. cursorPrev :: (MonadIO m, MonadFail m) => MdbxCursor -> m (Maybe (MdbxVal, MdbxVal)) -- | Moves the cursor using the provided operation. cursorMove :: (MonadIO m, MonadFail m) => MdbxCursor -> MdbxVal -> MdbxCursorOp -> m (Maybe (MdbxVal, MdbxVal)) -- | Converts a Float value to an unsigned Word that can be used by -- libmdbx's compare function. keyFromFloat :: Float -> Word32 -- | Converts a Double value to an unsigned Word that can be used by -- libmdbx's compare function. keyFromDouble :: Double -> Word64 -- | Converts a 32bits signed Int value to an unsigned Word that can be -- used by libmdbx's compare function. keyFromInt32 :: Int32 -> Word32 -- | Converts a 64bits signed Int value to an unsigned Word that can be -- used by libmdbx's compare function. keyFromInt64 :: Int64 -> Word64 -- | Converts an unsigned Word to a Float value. floatFromKey :: Word32 -> Float -- | Converts an unsigned Word to a Double value. doubleFromKey :: Word64 -> Double -- | Converts an unsigned Word value to a 32bits signed Int. int32FromKey :: Word32 -> Int32 -- | Converts an unsigned Word value to a 64bits signed Int. int64FromKey :: Word64 -> Int64 -- | High level API to create, update, delete and query an MDBX database. module Mdbx.Database -- | Returns the value associated with the given key, if any. getItem :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> k -> m (Maybe v) -- | Returns the values associated to a list of keys. Returned length may -- not match that of provided keys in case some of them are not found. getItems :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> [k] -> m [v] -- | Returns the list of values whose keys lie between the provided range. getRange :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> k -> k -> m [v] -- | Returns the list of key/value pairs whose keys lie between the -- provided range. getRangePairs :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> k -> k -> m [(k, v)] -- | Saves the given key/value pair. putItem :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> k -> v -> m () -- | Saves the given key/value pairs. Runs in a single transaction. putItems :: (MonadIO m, MonadFail m, MdbxItem k, MdbxItem v) => MdbxEnv -> MdbxDbi -> [(k, v)] -> m () -- | Deletes the item associated with the given key, if any. delItem :: (MonadIO m, MonadFail m, MdbxItem k) => MdbxEnv -> MdbxDbi -> k -> m () -- | Deletes the items associated with the given keys, if any. Runs in a -- single transaction. delItems :: (MonadIO m, MonadFail m, MdbxItem k) => MdbxEnv -> MdbxDbi -> [k] -> m () -- | Deletes the values whose keys lie between the provided range. delRange :: (MonadIO m, MonadFail m, MdbxItem k) => MdbxEnv -> MdbxDbi -> k -> k -> m () -- | Bindings for libmdbx, a high-performance, in-process, key-value store. -- -- This is the module most applications should import. -- -- See the Mdbx.Types module for details on how to make your data -- types work with libmdbx. It is recommended to use a serialization -- library such as binary to simplify this task. -- -- For the high level API, see the Mdbx.Database module. -- -- For the low level API, or if you want to use cursors, see -- Mdbx.API. -- -- Mdbx.FFI (not exported by this module) provides direct, low -- level, bindings to libmdbx. module Mdbx