{-# LINE 1 "src/Database/EJDB2/WAL.hsc" #-}
{-# LANGUAGE CPP #-}
module Database.EJDB2.WAL (Options(..), zero) where
import Foreign
import Foreign.C.String
import Foreign.C.Types
import Database.EJDB2.Result
data Options = Options { enabled :: !Bool
, checkCRCOnCheckpoint :: !Bool
, savepointTimeoutSec :: !Word32
, checkpointTimeoutSec :: !Word32
, walBufferSz :: !Word64
, checkpointBufferSz :: !Word8
, walLockInterceptor :: !(FunPtr (CBool -> Ptr () -> IO RC))
, walLockInterceptorOpaque :: !(Ptr ())
}
zero :: Options
zero = Options { enabled = False
, checkCRCOnCheckpoint = False
, savepointTimeoutSec = 0
, checkpointTimeoutSec = 0
, walBufferSz = 0
, checkpointBufferSz = 0
, walLockInterceptor = nullFunPtr
, walLockInterceptorOpaque = nullPtr
}
instance Storable Options where
sizeOf _ = (48)
{-# LINE 41 "src/Database/EJDB2/WAL.hsc" #-}
alignment _ = 8
{-# LINE 42 "src/Database/EJDB2/WAL.hsc" #-}
peek ptr = do
enabled <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 44 "src/Database/EJDB2/WAL.hsc" #-}
check_crc_on_checkpoint <- (\hsc_ptr -> peekByteOff hsc_ptr 1) ptr
{-# LINE 45 "src/Database/EJDB2/WAL.hsc" #-}
savepoint_timeout_sec <- (\hsc_ptr -> peekByteOff hsc_ptr 4) ptr
{-# LINE 46 "src/Database/EJDB2/WAL.hsc" #-}
checkpoint_timeout_sec <- (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
{-# LINE 47 "src/Database/EJDB2/WAL.hsc" #-}
wal_buffer_sz <- (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr
{-# LINE 48 "src/Database/EJDB2/WAL.hsc" #-}
checkpoint_buffer_sz <- (\hsc_ptr -> peekByteOff hsc_ptr 24) ptr
{-# LINE 49 "src/Database/EJDB2/WAL.hsc" #-}
wal_lock_interceptor <- (\hsc_ptr -> peekByteOff hsc_ptr 32) ptr
{-# LINE 50 "src/Database/EJDB2/WAL.hsc" #-}
wal_lock_interceptor_opaque <- (\hsc_ptr -> peekByteOff hsc_ptr 40) ptr
{-# LINE 51 "src/Database/EJDB2/WAL.hsc" #-}
return $ Options enabled check_crc_on_checkpoint savepoint_timeout_sec checkpoint_timeout_sec wal_buffer_sz checkpoint_buffer_sz wal_lock_interceptor wal_lock_interceptor_opaque
poke ptr (Options enabled check_crc_on_checkpoint savepoint_timeout_sec checkpoint_timeout_sec wal_buffer_sz checkpoint_buffer_sz wal_lock_interceptor wal_lock_interceptor_opaque) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr enabled
{-# LINE 54 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 1) ptr check_crc_on_checkpoint
{-# LINE 55 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 4) ptr savepoint_timeout_sec
{-# LINE 56 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 8) ptr checkpoint_timeout_sec
{-# LINE 57 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 16) ptr wal_buffer_sz
{-# LINE 58 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 24) ptr checkpoint_buffer_sz
{-# LINE 59 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 32) ptr wal_lock_interceptor
{-# LINE 60 "src/Database/EJDB2/WAL.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 40) ptr wal_lock_interceptor_opaque
{-# LINE 61 "src/Database/EJDB2/WAL.hsc" #-}