{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.OSTree.Interfaces.BlobReader
(
BlobReader(..) ,
IsBlobReader ,
toBlobReader ,
#if defined(ENABLE_OVERLOADING)
ResolveBlobReaderMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
BlobReaderReadBlobMethodInfo ,
#endif
blobReaderReadBlob ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
#else
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
#endif
newtype BlobReader = BlobReader (SP.ManagedPtr BlobReader)
deriving (BlobReader -> BlobReader -> Bool
(BlobReader -> BlobReader -> Bool)
-> (BlobReader -> BlobReader -> Bool) -> Eq BlobReader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BlobReader -> BlobReader -> Bool
== :: BlobReader -> BlobReader -> Bool
$c/= :: BlobReader -> BlobReader -> Bool
/= :: BlobReader -> BlobReader -> Bool
Eq)
instance SP.ManagedPtrNewtype BlobReader where
toManagedPtr :: BlobReader -> ManagedPtr BlobReader
toManagedPtr (BlobReader ManagedPtr BlobReader
p) = ManagedPtr BlobReader
p
foreign import ccall "ostree_blob_reader_get_type"
c_ostree_blob_reader_get_type :: IO B.Types.GType
instance B.Types.TypedObject BlobReader where
glibType :: IO GType
glibType = IO GType
c_ostree_blob_reader_get_type
instance B.Types.GObject BlobReader
class (SP.GObject o, O.IsDescendantOf BlobReader o) => IsBlobReader o
instance (SP.GObject o, O.IsDescendantOf BlobReader o) => IsBlobReader o
instance O.HasParentTypes BlobReader
type instance O.ParentTypes BlobReader = '[GObject.Object.Object]
toBlobReader :: (MIO.MonadIO m, IsBlobReader o) => o -> m BlobReader
toBlobReader :: forall (m :: * -> *) o.
(MonadIO m, IsBlobReader o) =>
o -> m BlobReader
toBlobReader = IO BlobReader -> m BlobReader
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO BlobReader -> m BlobReader)
-> (o -> IO BlobReader) -> o -> m BlobReader
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr BlobReader -> BlobReader) -> o -> IO BlobReader
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr BlobReader -> BlobReader
BlobReader
instance B.GValue.IsGValue (Maybe BlobReader) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_ostree_blob_reader_get_type
gvalueSet_ :: Ptr GValue -> Maybe BlobReader -> IO ()
gvalueSet_ Ptr GValue
gv Maybe BlobReader
P.Nothing = Ptr GValue -> Ptr BlobReader -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr BlobReader
forall a. Ptr a
FP.nullPtr :: FP.Ptr BlobReader)
gvalueSet_ Ptr GValue
gv (P.Just BlobReader
obj) = BlobReader -> (Ptr BlobReader -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr BlobReader
obj (Ptr GValue -> Ptr BlobReader -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe BlobReader)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr BlobReader)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr BlobReader)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject BlobReader ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList BlobReader
type instance O.AttributeList BlobReader = BlobReaderAttributeList
type BlobReaderAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveBlobReaderMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveBlobReaderMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveBlobReaderMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveBlobReaderMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveBlobReaderMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveBlobReaderMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveBlobReaderMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveBlobReaderMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveBlobReaderMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveBlobReaderMethod "readBlob" o = BlobReaderReadBlobMethodInfo
ResolveBlobReaderMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveBlobReaderMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveBlobReaderMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveBlobReaderMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveBlobReaderMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveBlobReaderMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveBlobReaderMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveBlobReaderMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveBlobReaderMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveBlobReaderMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveBlobReaderMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveBlobReaderMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveBlobReaderMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveBlobReaderMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveBlobReaderMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBlobReaderMethod t BlobReader, O.OverloadedMethod info BlobReader p) => OL.IsLabel t (BlobReader -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveBlobReaderMethod t BlobReader, O.OverloadedMethod info BlobReader p, R.HasField t BlobReader p) => R.HasField t BlobReader p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveBlobReaderMethod t BlobReader, O.OverloadedMethodInfo info BlobReader) => OL.IsLabel t (O.MethodProxy info BlobReader) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "ostree_blob_reader_read_blob" ostree_blob_reader_read_blob ::
Ptr BlobReader ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO (Ptr GLib.Bytes.Bytes)
blobReaderReadBlob ::
(B.CallStack.HasCallStack, MonadIO m, IsBlobReader a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m (Maybe GLib.Bytes.Bytes)
blobReaderReadBlob :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsBlobReader a, IsCancellable b) =>
a -> Maybe b -> m (Maybe Bytes)
blobReaderReadBlob a
self Maybe b
cancellable = IO (Maybe Bytes) -> m (Maybe Bytes)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Bytes) -> m (Maybe Bytes))
-> IO (Maybe Bytes) -> m (Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ do
self' <- a -> IO (Ptr BlobReader)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
maybeCancellable <- case cancellable of
Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just b
jCancellable -> do
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
return jCancellable'
onException (do
result <- propagateGError $ ostree_blob_reader_read_blob self' maybeCancellable
maybeResult <- convertIfNonNull result $ \Ptr Bytes
result' -> do
result'' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result'
return result''
touchManagedPtr self
whenJust cancellable touchManagedPtr
return maybeResult
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data BlobReaderReadBlobMethodInfo
instance (signature ~ (Maybe (b) -> m (Maybe GLib.Bytes.Bytes)), MonadIO m, IsBlobReader a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod BlobReaderReadBlobMethodInfo a signature where
overloadedMethod = blobReaderReadBlob
instance O.OverloadedMethodInfo BlobReaderReadBlobMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.OSTree.Interfaces.BlobReader.blobReaderReadBlob",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-ostree-1.0.19/docs/GI-OSTree-Interfaces-BlobReader.html#v:blobReaderReadBlob"
})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList BlobReader = BlobReaderSignalList
type BlobReaderSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif