{-|
  Module      : OpenDHT
  Description : Main OpenDHT interface
  Copyright   : (c) Simon Désaulniers, 2025
  License     : GPL-3

  Maintainer  : sim.desaulniers@gmail.com
-}

module OpenDHT ( version
               ) where

import Control.Monad.IO.Class

import Foreign.Ptr
import Foreign.C.Types
import Foreign.C.String

import OpenDHT.Types

foreign import ccall "dht_version" dhtVersionC :: IO (Ptr CChar)

{-| Yields the version string of OpenDHT.

   > unDht version
   > "3.2.0"
-}
version :: Dht String
version :: Dht String
version = IO String -> Dht String
forall a. IO a -> Dht a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> Dht String) -> IO String -> Dht String
forall a b. (a -> b) -> a -> b
$ IO (Ptr CChar)
dhtVersionC IO (Ptr CChar) -> (Ptr CChar -> IO String) -> IO String
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr CChar -> IO String
peekCString

-- vim: set sts=2 ts=2 sw=2 tw=120 et :