{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.OSTree.Functions
    ( 

 -- * Methods
-- ** checksumB64FromBytes #method:checksumB64FromBytes#
    checksumB64FromBytes                    ,


-- ** checksumB64ToBytes #method:checksumB64ToBytes#
    checksumB64ToBytes                      ,


-- ** checksumBytesPeek #method:checksumBytesPeek#
    checksumBytesPeek                       ,


-- ** checksumBytesPeekValidate #method:checksumBytesPeekValidate#
    checksumBytesPeekValidate               ,


-- ** checksumFile #method:checksumFile#
    checksumFile                            ,


-- ** checksumFileAsync #method:checksumFileAsync#
    checksumFileAsync                       ,


-- ** checksumFileAsyncFinish #method:checksumFileAsyncFinish#
    checksumFileAsyncFinish                 ,


-- ** checksumFileFromInput #method:checksumFileFromInput#
    checksumFileFromInput                   ,


-- ** checksumFromBytes #method:checksumFromBytes#
    checksumFromBytes                       ,


-- ** checksumFromBytesV #method:checksumFromBytesV#
    checksumFromBytesV                      ,


-- ** checksumInplaceToBytes #method:checksumInplaceToBytes#
    checksumInplaceToBytes                  ,


-- ** checksumToBytes #method:checksumToBytes#
    checksumToBytes                         ,


-- ** checksumToBytesV #method:checksumToBytesV#
    checksumToBytesV                        ,


-- ** cmd_Private__ #method:cmd_Private__#
    cmd_Private__                           ,


-- ** cmpChecksumBytes #method:cmpChecksumBytes#
    cmpChecksumBytes                        ,


-- ** commitGetParent #method:commitGetParent#
    commitGetParent                         ,


-- ** commitGetTimestamp #method:commitGetTimestamp#
    commitGetTimestamp                      ,


-- ** contentFileParse #method:contentFileParse#
    contentFileParse                        ,


-- ** contentFileParseAt #method:contentFileParseAt#
    contentFileParseAt                      ,


-- ** contentStreamParse #method:contentStreamParse#
    contentStreamParse                      ,


-- ** createDirectoryMetadata #method:createDirectoryMetadata#
    createDirectoryMetadata                 ,


-- ** diffDirs #method:diffDirs#
    diffDirs                                ,


-- ** diffPrint #method:diffPrint#
    diffPrint                               ,


-- ** hashObjectName #method:hashObjectName#
    hashObjectName                          ,


-- ** metadataVariantType #method:metadataVariantType#
    metadataVariantType                     ,


-- ** objectFromString #method:objectFromString#
    objectFromString                        ,


-- ** objectNameDeserialize #method:objectNameDeserialize#
    objectNameDeserialize                   ,


-- ** objectNameSerialize #method:objectNameSerialize#
    objectNameSerialize                     ,


-- ** objectToString #method:objectToString#
    objectToString                          ,


-- ** objectTypeFromString #method:objectTypeFromString#
    objectTypeFromString                    ,


-- ** objectTypeToString #method:objectTypeToString#
    objectTypeToString                      ,


-- ** parseRefspec #method:parseRefspec#
    parseRefspec                            ,


-- ** rawFileToArchiveZ2Stream #method:rawFileToArchiveZ2Stream#
    rawFileToArchiveZ2Stream                ,


-- ** rawFileToArchiveZ2StreamWithOptions #method:rawFileToArchiveZ2StreamWithOptions#
    rawFileToArchiveZ2StreamWithOptions     ,


-- ** rawFileToContentStream #method:rawFileToContentStream#
    rawFileToContentStream                  ,


-- ** validateChecksumString #method:validateChecksumString#
    validateChecksumString                  ,


-- ** validateRev #method:validateRev#
    validateRev                             ,


-- ** validateStructureofChecksumString #method:validateStructureofChecksumString#
    validateStructureofChecksumString       ,


-- ** validateStructureofCommit #method:validateStructureofCommit#
    validateStructureofCommit               ,


-- ** validateStructureofCsumV #method:validateStructureofCsumV#
    validateStructureofCsumV                ,


-- ** validateStructureofDirmeta #method:validateStructureofDirmeta#
    validateStructureofDirmeta              ,


-- ** validateStructureofDirtree #method:validateStructureofDirtree#
    validateStructureofDirtree              ,


-- ** validateStructureofFileMode #method:validateStructureofFileMode#
    validateStructureofFileMode             ,


-- ** validateStructureofObjtype #method:validateStructureofObjtype#
    validateStructureofObjtype              ,




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.VariantType as GLib.VariantType
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.File as Gio.File
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.FileInfo as Gio.FileInfo
import qualified GI.Gio.Objects.InputStream as Gio.InputStream
import {-# SOURCE #-} qualified GI.OSTree.Enums as OSTree.Enums
import {-# SOURCE #-} qualified GI.OSTree.Flags as OSTree.Flags
import {-# SOURCE #-} qualified GI.OSTree.Structs.CmdPrivateVTable as OSTree.CmdPrivateVTable
import {-# SOURCE #-} qualified GI.OSTree.Structs.DiffItem as OSTree.DiffItem

-- function ostree_validate_structureof_objtype
-- Args : [Arg {argCName = "objtype", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_objtype" ostree_validate_structureof_objtype :: 
    Word8 ->                                -- objtype : TBasicType TUInt8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
validateStructureofObjtype ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word8
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofObjtype objtype = liftIO $ do
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_objtype objtype
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_file_mode
-- Args : [Arg {argCName = "mode", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A Unix filesystem mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_file_mode" ostree_validate_structureof_file_mode :: 
    Word32 ->                               -- mode : TBasicType TUInt32
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
validateStructureofFileMode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    {- ^ /@mode@/: A Unix filesystem mode -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofFileMode mode = liftIO $ do
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_file_mode mode
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_dirtree
-- Args : [Arg {argCName = "dirtree", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A dirtree object, %OSTREE_OBJECT_TYPE_DIR_TREE", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_dirtree" ostree_validate_structureof_dirtree :: 
    Ptr GVariant ->                         -- dirtree : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Use this to validate the basic structure of /@dirtree@/, independent of
any other objects it references.
-}
validateStructureofDirtree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@dirtree@/: A dirtree object, 'GI.OSTree.Enums.ObjectTypeDirTree' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofDirtree dirtree = liftIO $ do
    dirtree' <- unsafeManagedPtrGetPtr dirtree
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_dirtree dirtree'
        touchManagedPtr dirtree
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_dirmeta
-- Args : [Arg {argCName = "dirmeta", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A dirmeta object, %OSTREE_OBJECT_TYPE_DIR_META", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_dirmeta" ostree_validate_structureof_dirmeta :: 
    Ptr GVariant ->                         -- dirmeta : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Use this to validate the basic structure of /@dirmeta@/.
-}
validateStructureofDirmeta ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@dirmeta@/: A dirmeta object, 'GI.OSTree.Enums.ObjectTypeDirMeta' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofDirmeta dirmeta = liftIO $ do
    dirmeta' <- unsafeManagedPtrGetPtr dirmeta
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_dirmeta dirmeta'
        touchManagedPtr dirmeta
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_csum_v
-- Args : [Arg {argCName = "checksum", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GVariant of type \"ay\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_csum_v" ostree_validate_structureof_csum_v :: 
    Ptr GVariant ->                         -- checksum : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
validateStructureofCsumV ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@checksum@/: a 'GVariant' of type \"ay\" -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofCsumV checksum = liftIO $ do
    checksum' <- unsafeManagedPtrGetPtr checksum
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_csum_v checksum'
        touchManagedPtr checksum
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_commit
-- Args : [Arg {argCName = "commit", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A commit object, %OSTREE_OBJECT_TYPE_COMMIT", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_commit" ostree_validate_structureof_commit :: 
    Ptr GVariant ->                         -- commit : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Use this to validate the basic structure of /@commit@/, independent of
any other objects it references.
-}
validateStructureofCommit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@commit@/: A commit object, 'GI.OSTree.Enums.ObjectTypeCommit' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofCommit commit = liftIO $ do
    commit' <- unsafeManagedPtrGetPtr commit
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_commit commit'
        touchManagedPtr commit
        return ()
     ) (do
        return ()
     )


-- function ostree_validate_structureof_checksum_string
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an ASCII string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_structureof_checksum_string" ostree_validate_structureof_checksum_string :: 
    CString ->                              -- checksum : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
validateStructureofChecksumString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: an ASCII string -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateStructureofChecksumString checksum = liftIO $ do
    checksum' <- textToCString checksum
    onException (do
        _ <- propagateGError $ ostree_validate_structureof_checksum_string checksum'
        freeMem checksum'
        return ()
     ) (do
        freeMem checksum'
     )


-- function ostree_validate_rev
-- Args : [Arg {argCName = "rev", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A revision string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_rev" ostree_validate_rev :: 
    CString ->                              -- rev : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
validateRev ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@rev@/: A revision string -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateRev rev = liftIO $ do
    rev' <- textToCString rev
    onException (do
        _ <- propagateGError $ ostree_validate_rev rev'
        freeMem rev'
        return ()
     ) (do
        freeMem rev'
     )


-- function ostree_validate_checksum_string
-- Args : [Arg {argCName = "sha256", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "SHA256 hex string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_validate_checksum_string" ostree_validate_checksum_string :: 
    CString ->                              -- sha256 : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Use this function to see if input strings are checksums.
-}
validateChecksumString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@sha256@/: SHA256 hex string -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
validateChecksumString sha256 = liftIO $ do
    sha256' <- textToCString sha256
    onException (do
        _ <- propagateGError $ ostree_validate_checksum_string sha256'
        freeMem sha256'
        return ()
     ) (do
        freeMem sha256'
     )


-- function ostree_raw_file_to_content_stream
-- Args : [Arg {argCName = "input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File raw content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file info", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xattrs", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Optional extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Serialized object stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_raw_file_to_content_stream" ostree_raw_file_to_content_stream :: 
    Ptr Gio.InputStream.InputStream ->      -- input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Gio.FileInfo.FileInfo ->            -- file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr GVariant ->                         -- xattrs : TVariant
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Word64 ->                           -- out_length : TBasicType TUInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Convert from a \"bare\" file representation into an
OSTREE_OBJECT_TYPE_FILE stream.  This is a fundamental operation
for writing data to an 'GI.OSTree.Objects.Repo.Repo'.
-}
rawFileToContentStream ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@input@/: File raw content stream -}
    -> b
    {- ^ /@fileInfo@/: A file info -}
    -> Maybe (GVariant)
    {- ^ /@xattrs@/: Optional extended attributes -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream,Word64)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
rawFileToContentStream input fileInfo xattrs cancellable = liftIO $ do
    input' <- unsafeManagedPtrCastPtr input
    fileInfo' <- unsafeManagedPtrCastPtr fileInfo
    maybeXattrs <- case xattrs of
        Nothing -> return nullPtr
        Just jXattrs -> do
            jXattrs' <- unsafeManagedPtrGetPtr jXattrs
            return jXattrs'
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    outLength <- allocMem :: IO (Ptr Word64)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_raw_file_to_content_stream input' fileInfo' maybeXattrs outInput outLength maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        outLength' <- peek outLength
        touchManagedPtr input
        touchManagedPtr fileInfo
        whenJust xattrs touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem outInput
        freeMem outLength
        return (outInput'', outLength')
     ) (do
        freeMem outInput
        freeMem outLength
     )


-- function ostree_raw_file_to_archive_z2_stream_with_options
-- Args : [Arg {argCName = "input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File raw content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file info", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xattrs", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Optional extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A GVariant `a{sv}` with an extensible set of flags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Serialized object stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_raw_file_to_archive_z2_stream_with_options" ostree_raw_file_to_archive_z2_stream_with_options :: 
    Ptr Gio.InputStream.InputStream ->      -- input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Gio.FileInfo.FileInfo ->            -- file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr GVariant ->                         -- xattrs : TVariant
    Ptr GVariant ->                         -- options : TVariant
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Like 'GI.OSTree.Functions.rawFileToArchiveZ2Stream', but supports an extensible set
of flags. The following flags are currently defined:

* @compression-level@ (@i@): Level of compression to use, 0–9, with 0 being
the least compression, and \<0 giving the default level (currently 6).

@since 2017.3
-}
rawFileToArchiveZ2StreamWithOptions ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@input@/: File raw content stream -}
    -> b
    {- ^ /@fileInfo@/: A file info -}
    -> Maybe (GVariant)
    {- ^ /@xattrs@/: Optional extended attributes -}
    -> Maybe (GVariant)
    {- ^ /@options@/: A GVariant @a{sv}@ with an extensible set of flags -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
rawFileToArchiveZ2StreamWithOptions input fileInfo xattrs options cancellable = liftIO $ do
    input' <- unsafeManagedPtrCastPtr input
    fileInfo' <- unsafeManagedPtrCastPtr fileInfo
    maybeXattrs <- case xattrs of
        Nothing -> return nullPtr
        Just jXattrs -> do
            jXattrs' <- unsafeManagedPtrGetPtr jXattrs
            return jXattrs'
    maybeOptions <- case options of
        Nothing -> return nullPtr
        Just jOptions -> do
            jOptions' <- unsafeManagedPtrGetPtr jOptions
            return jOptions'
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_raw_file_to_archive_z2_stream_with_options input' fileInfo' maybeXattrs maybeOptions outInput maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        touchManagedPtr input
        touchManagedPtr fileInfo
        whenJust xattrs touchManagedPtr
        whenJust options touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem outInput
        return outInput''
     ) (do
        freeMem outInput
     )


-- function ostree_raw_file_to_archive_z2_stream
-- Args : [Arg {argCName = "input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File raw content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A file info", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xattrs", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Optional extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Serialized object stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_raw_file_to_archive_z2_stream" ostree_raw_file_to_archive_z2_stream :: 
    Ptr Gio.InputStream.InputStream ->      -- input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Gio.FileInfo.FileInfo ->            -- file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr GVariant ->                         -- xattrs : TVariant
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Convert from a \"bare\" file representation into an
OSTREE_OBJECT_TYPE_FILE stream suitable for ostree pull.
-}
rawFileToArchiveZ2Stream ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a, Gio.FileInfo.IsFileInfo b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@input@/: File raw content stream -}
    -> b
    {- ^ /@fileInfo@/: A file info -}
    -> Maybe (GVariant)
    {- ^ /@xattrs@/: Optional extended attributes -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
rawFileToArchiveZ2Stream input fileInfo xattrs cancellable = liftIO $ do
    input' <- unsafeManagedPtrCastPtr input
    fileInfo' <- unsafeManagedPtrCastPtr fileInfo
    maybeXattrs <- case xattrs of
        Nothing -> return nullPtr
        Just jXattrs -> do
            jXattrs' <- unsafeManagedPtrGetPtr jXattrs
            return jXattrs'
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_raw_file_to_archive_z2_stream input' fileInfo' maybeXattrs outInput maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        touchManagedPtr input
        touchManagedPtr fileInfo
        whenJust xattrs touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem outInput
        return outInput''
     ) (do
        freeMem outInput
     )


-- function ostree_parse_refspec
-- Args : [Arg {argCName = "refspec", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A \"refspec\" string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_remote", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The remote name, or %NULL if the refspec refs to a local ref", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_ref", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name of ref", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_parse_refspec" ostree_parse_refspec :: 
    CString ->                              -- refspec : TBasicType TUTF8
    Ptr CString ->                          -- out_remote : TBasicType TUTF8
    Ptr CString ->                          -- out_ref : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Split a refspec like \"gnome-ostree:gnome-ostree\/buildmaster\" into
two parts; /@outRemote@/ will be set to \"gnome-ostree\", and /@outRef@/
will be \"gnome-ostree\/buildmaster\".

If /@refspec@/ refers to a local ref, /@outRemote@/ will be 'Nothing'.
-}
parseRefspec ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@refspec@/: A \"refspec\" string -}
    -> m (T.Text,T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
parseRefspec refspec = liftIO $ do
    refspec' <- textToCString refspec
    outRemote <- allocMem :: IO (Ptr CString)
    outRef <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ ostree_parse_refspec refspec' outRemote outRef
        outRemote' <- peek outRemote
        outRemote'' <- cstringToText outRemote'
        freeMem outRemote'
        outRef' <- peek outRef
        outRef'' <- cstringToText outRef'
        freeMem outRef'
        freeMem refspec'
        freeMem outRemote
        freeMem outRef
        return (outRemote'', outRef'')
     ) (do
        freeMem refspec'
        freeMem outRemote
        freeMem outRef
     )


-- function ostree_object_type_to_string
-- Args : [Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #OstreeObjectType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_type_to_string" ostree_object_type_to_string :: 
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO CString

{- |
Serialize /@objtype@/ to a string; this is used for file extensions.
-}
objectTypeToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OSTree.Enums.ObjectType
    {- ^ /@objtype@/: an 'GI.OSTree.Enums.ObjectType' -}
    -> m T.Text
objectTypeToString objtype = liftIO $ do
    let objtype' = (fromIntegral . fromEnum) objtype
    result <- ostree_object_type_to_string objtype'
    checkUnexpectedReturnNULL "objectTypeToString" result
    result' <- cstringToText result
    return result'


-- function ostree_object_type_from_string
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A stringified version of #OstreeObjectType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "ObjectType"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_type_from_string" ostree_object_type_from_string :: 
    CString ->                              -- str : TBasicType TUTF8
    IO CUInt

{- |
The reverse of 'GI.OSTree.Functions.objectTypeToString'.
-}
objectTypeFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: A stringified version of 'GI.OSTree.Enums.ObjectType' -}
    -> m OSTree.Enums.ObjectType
objectTypeFromString str = liftIO $ do
    str' <- textToCString str
    result <- ostree_object_type_from_string str'
    let result' = (toEnum . fromIntegral) result
    freeMem str'
    return result'


-- function ostree_object_to_string
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_to_string" ostree_object_to_string :: 
    CString ->                              -- checksum : TBasicType TUTF8
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO CString

{- |
/No description available in the introspection data./
-}
objectToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: An ASCII checksum -}
    -> OSTree.Enums.ObjectType
    {- ^ /@objtype@/: Object type -}
    -> m T.Text
    {- ^ __Returns:__ A string containing both /@checksum@/ and a stringifed version of /@objtype@/ -}
objectToString checksum objtype = liftIO $ do
    checksum' <- textToCString checksum
    let objtype' = (fromIntegral . fromEnum) objtype
    result <- ostree_object_to_string checksum' objtype'
    checkUnexpectedReturnNULL "objectToString" result
    result' <- cstringToText result
    freeMem result
    freeMem checksum'
    return result'


-- function ostree_object_name_serialize
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_name_serialize" ostree_object_name_serialize :: 
    CString ->                              -- checksum : TBasicType TUTF8
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO (Ptr GVariant)

{- |
/No description available in the introspection data./
-}
objectNameSerialize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: An ASCII checksum -}
    -> OSTree.Enums.ObjectType
    {- ^ /@objtype@/: An object type -}
    -> m GVariant
    {- ^ __Returns:__ A new floating 'GVariant' containing checksum string and objtype -}
objectNameSerialize checksum objtype = liftIO $ do
    checksum' <- textToCString checksum
    let objtype' = (fromIntegral . fromEnum) objtype
    result <- ostree_object_name_serialize checksum' objtype'
    checkUnexpectedReturnNULL "objectNameSerialize" result
    result' <- newGVariantFromPtr result
    freeMem checksum'
    return result'


-- function ostree_object_name_deserialize
-- Args : [Arg {argCName = "variant", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GVariant of type (su)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_checksum", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer into string memory of @variant with checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_name_deserialize" ostree_object_name_deserialize :: 
    Ptr GVariant ->                         -- variant : TVariant
    Ptr CString ->                          -- out_checksum : TBasicType TUTF8
    Ptr CUInt ->                            -- out_objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO ()

{- |
Reverse 'GI.OSTree.Functions.objectNameSerialize'.  Note that /@outChecksum@/ is
only valid for the lifetime of /@variant@/, and must not be freed.
-}
objectNameDeserialize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@variant@/: A 'GVariant' of type (su) -}
    -> m (T.Text,OSTree.Enums.ObjectType)
objectNameDeserialize variant = liftIO $ do
    variant' <- unsafeManagedPtrGetPtr variant
    outChecksum <- allocMem :: IO (Ptr CString)
    outObjtype <- allocMem :: IO (Ptr CUInt)
    ostree_object_name_deserialize variant' outChecksum outObjtype
    outChecksum' <- peek outChecksum
    outChecksum'' <- cstringToText outChecksum'
    outObjtype' <- peek outObjtype
    let outObjtype'' = (toEnum . fromIntegral) outObjtype'
    touchManagedPtr variant
    freeMem outChecksum
    freeMem outObjtype
    return (outChecksum'', outObjtype'')


-- function ostree_object_from_string
-- Args : [Arg {argCName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_checksum", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Parsed checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Parsed object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_object_from_string" ostree_object_from_string :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr CString ->                          -- out_checksum : TBasicType TUTF8
    Ptr CUInt ->                            -- out_objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO ()

{- |
Reverse 'GI.OSTree.Functions.objectToString'.
-}
objectFromString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@str@/: An ASCII checksum -}
    -> m (T.Text,OSTree.Enums.ObjectType)
objectFromString str = liftIO $ do
    str' <- textToCString str
    outChecksum <- allocMem :: IO (Ptr CString)
    outObjtype <- allocMem :: IO (Ptr CUInt)
    ostree_object_from_string str' outChecksum outObjtype
    outChecksum' <- peek outChecksum
    outChecksum'' <- cstringToText outChecksum'
    freeMem outChecksum'
    outObjtype' <- peek outObjtype
    let outObjtype'' = (toEnum . fromIntegral) outObjtype'
    freeMem str'
    freeMem outChecksum
    freeMem outObjtype
    return (outChecksum'', outObjtype'')


-- function ostree_metadata_variant_type
-- Args : [Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "VariantType"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_metadata_variant_type" ostree_metadata_variant_type :: 
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    IO (Ptr GLib.VariantType.VariantType)

{- |
/No description available in the introspection data./
-}
metadataVariantType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    OSTree.Enums.ObjectType
    -> m GLib.VariantType.VariantType
metadataVariantType objtype = liftIO $ do
    let objtype' = (fromIntegral . fromEnum) objtype
    result <- ostree_metadata_variant_type objtype'
    checkUnexpectedReturnNULL "metadataVariantType" result
    result' <- (newBoxed GLib.VariantType.VariantType) result
    return result'


-- function ostree_hash_object_name
-- Args : [Arg {argCName = "a", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GVariant containing a serialized object", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_hash_object_name" ostree_hash_object_name :: 
    Ptr () ->                               -- a : TBasicType TPtr
    IO Word32

{- |
Use this function with 'GI.GLib.Structs.HashTable.HashTable' and 'GI.OSTree.Functions.objectNameSerialize'.
-}
hashObjectName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@a@/: A 'GVariant' containing a serialized object -}
    -> m Word32
hashObjectName a = liftIO $ do
    result <- ostree_hash_object_name a
    return result


-- function ostree_diff_print
-- Args : [Arg {argCName = "a", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "First directory path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "First directory path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "modified", argType = TPtrArray (TInterface (Name {namespace = "OSTree", name = "DiffItem"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Modified files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "removed", argType = TPtrArray (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Removed files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "added", argType = TPtrArray (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Added files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_diff_print" ostree_diff_print :: 
    Ptr Gio.File.File ->                    -- a : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.File.File ->                    -- b : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr (GPtrArray (Ptr OSTree.DiffItem.DiffItem)) -> -- modified : TPtrArray (TInterface (Name {namespace = "OSTree", name = "DiffItem"}))
    Ptr (GPtrArray (Ptr Gio.File.File)) ->  -- removed : TPtrArray (TInterface (Name {namespace = "Gio", name = "File"}))
    Ptr (GPtrArray (Ptr Gio.File.File)) ->  -- added : TPtrArray (TInterface (Name {namespace = "Gio", name = "File"}))
    IO ()

{- |
Print the contents of a diff to stdout.
-}
diffPrint ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.File.IsFile b) =>
    a
    {- ^ /@a@/: First directory path -}
    -> b
    {- ^ /@b@/: First directory path -}
    -> [OSTree.DiffItem.DiffItem]
    {- ^ /@modified@/: Modified files -}
    -> [Gio.File.File]
    {- ^ /@removed@/: Removed files -}
    -> [Gio.File.File]
    {- ^ /@added@/: Added files -}
    -> m ()
diffPrint a b modified removed added = liftIO $ do
    a' <- unsafeManagedPtrCastPtr a
    b' <- unsafeManagedPtrCastPtr b
    modified' <- mapM unsafeManagedPtrGetPtr modified
    modified'' <- packGPtrArray modified'
    removed' <- mapM unsafeManagedPtrCastPtr removed
    removed'' <- packGPtrArray removed'
    added' <- mapM unsafeManagedPtrCastPtr added
    added'' <- packGPtrArray added'
    ostree_diff_print a' b' modified'' removed'' added''
    touchManagedPtr a
    touchManagedPtr b
    mapM_ touchManagedPtr modified
    mapM_ touchManagedPtr removed
    mapM_ touchManagedPtr added
    unrefPtrArray modified''
    unrefPtrArray removed''
    unrefPtrArray added''
    return ()


-- function ostree_diff_dirs
-- Args : [Arg {argCName = "flags", argType = TInterface (Name {namespace = "OSTree", name = "DiffFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "a", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "First directory path, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "First directory path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "modified", argType = TPtrArray (TInterface (Name {namespace = "OSTree", name = "DiffItem"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Modified files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "removed", argType = TPtrArray (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Removed files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "added", argType = TPtrArray (TInterface (Name {namespace = "Gio", name = "File"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Added files", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_diff_dirs" ostree_diff_dirs :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "OSTree", name = "DiffFlags"})
    Ptr Gio.File.File ->                    -- a : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.File.File ->                    -- b : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr (GPtrArray (Ptr OSTree.DiffItem.DiffItem)) -> -- modified : TPtrArray (TInterface (Name {namespace = "OSTree", name = "DiffItem"}))
    Ptr (GPtrArray (Ptr Gio.File.File)) ->  -- removed : TPtrArray (TInterface (Name {namespace = "Gio", name = "File"}))
    Ptr (GPtrArray (Ptr Gio.File.File)) ->  -- added : TPtrArray (TInterface (Name {namespace = "Gio", name = "File"}))
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Compute the difference between directory /@a@/ and /@b@/ as 3 separate
sets of 'GI.OSTree.Structs.DiffItem.DiffItem' in /@modified@/, /@removed@/, and /@added@/.
-}
diffDirs ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.File.IsFile b, Gio.Cancellable.IsCancellable c) =>
    [OSTree.Flags.DiffFlags]
    {- ^ /@flags@/: Flags -}
    -> a
    {- ^ /@a@/: First directory path, or 'Nothing' -}
    -> b
    {- ^ /@b@/: First directory path -}
    -> [OSTree.DiffItem.DiffItem]
    {- ^ /@modified@/: Modified files -}
    -> [Gio.File.File]
    {- ^ /@removed@/: Removed files -}
    -> [Gio.File.File]
    {- ^ /@added@/: Added files -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
diffDirs flags a b modified removed added cancellable = liftIO $ do
    let flags' = gflagsToWord flags
    a' <- unsafeManagedPtrCastPtr a
    b' <- unsafeManagedPtrCastPtr b
    modified' <- mapM unsafeManagedPtrGetPtr modified
    modified'' <- packGPtrArray modified'
    removed' <- mapM unsafeManagedPtrCastPtr removed
    removed'' <- packGPtrArray removed'
    added' <- mapM unsafeManagedPtrCastPtr added
    added'' <- packGPtrArray added'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_diff_dirs flags' a' b' modified'' removed'' added'' maybeCancellable
        touchManagedPtr a
        touchManagedPtr b
        mapM_ touchManagedPtr modified
        mapM_ touchManagedPtr removed
        mapM_ touchManagedPtr added
        whenJust cancellable touchManagedPtr
        unrefPtrArray modified''
        unrefPtrArray removed''
        unrefPtrArray added''
        return ()
     ) (do
        unrefPtrArray modified''
        unrefPtrArray removed''
        unrefPtrArray added''
     )


-- function ostree_create_directory_metadata
-- Args : [Arg {argCName = "dir_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GFileInfo containing directory information", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xattrs", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Optional extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "ostree_create_directory_metadata" ostree_create_directory_metadata :: 
    Ptr Gio.FileInfo.FileInfo ->            -- dir_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr GVariant ->                         -- xattrs : TVariant
    IO (Ptr GVariant)

{- |
/No description available in the introspection data./
-}
createDirectoryMetadata ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.FileInfo.IsFileInfo a) =>
    a
    {- ^ /@dirInfo@/: a 'GI.Gio.Objects.FileInfo.FileInfo' containing directory information -}
    -> Maybe (GVariant)
    {- ^ /@xattrs@/: Optional extended attributes -}
    -> m GVariant
    {- ^ __Returns:__ A new 'GVariant' containing 'GI.OSTree.Enums.ObjectTypeDirMeta' -}
createDirectoryMetadata dirInfo xattrs = liftIO $ do
    dirInfo' <- unsafeManagedPtrCastPtr dirInfo
    maybeXattrs <- case xattrs of
        Nothing -> return nullPtr
        Just jXattrs -> do
            jXattrs' <- unsafeManagedPtrGetPtr jXattrs
            return jXattrs'
    result <- ostree_create_directory_metadata dirInfo' maybeXattrs
    checkUnexpectedReturnNULL "createDirectoryMetadata" result
    result' <- wrapGVariantPtr result
    touchManagedPtr dirInfo
    whenJust xattrs touchManagedPtr
    return result'


-- function ostree_content_stream_parse
-- Args : [Arg {argCName = "compressed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether or not the stream is zlib-compressed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Object content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "input_length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Length of stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "trusted", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "If %TRUE, assume the content has been validated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The raw file content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Normal metadata", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_xattrs", argType = TVariant, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_content_stream_parse" ostree_content_stream_parse :: 
    CInt ->                                 -- compressed : TBasicType TBoolean
    Ptr Gio.InputStream.InputStream ->      -- input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Word64 ->                               -- input_length : TBasicType TUInt64
    CInt ->                                 -- trusted : TBasicType TBoolean
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr (Ptr Gio.FileInfo.FileInfo) ->      -- out_file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr (Ptr GVariant) ->                   -- out_xattrs : TVariant
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
The reverse of 'GI.OSTree.Functions.rawFileToContentStream'; this function
converts an object content stream back into components.
-}
contentStreamParse ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a, Gio.Cancellable.IsCancellable b) =>
    Bool
    {- ^ /@compressed@/: Whether or not the stream is zlib-compressed -}
    -> a
    {- ^ /@input@/: Object content stream -}
    -> Word64
    {- ^ /@inputLength@/: Length of stream -}
    -> Bool
    {- ^ /@trusted@/: If 'True', assume the content has been validated -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream,Gio.FileInfo.FileInfo,GVariant)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
contentStreamParse compressed input inputLength trusted cancellable = liftIO $ do
    let compressed' = (fromIntegral . fromEnum) compressed
    input' <- unsafeManagedPtrCastPtr input
    let trusted' = (fromIntegral . fromEnum) trusted
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    outFileInfo <- allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
    outXattrs <- allocMem :: IO (Ptr (Ptr GVariant))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_content_stream_parse compressed' input' inputLength trusted' outInput outFileInfo outXattrs maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        outFileInfo' <- peek outFileInfo
        outFileInfo'' <- (wrapObject Gio.FileInfo.FileInfo) outFileInfo'
        outXattrs' <- peek outXattrs
        outXattrs'' <- wrapGVariantPtr outXattrs'
        touchManagedPtr input
        whenJust cancellable touchManagedPtr
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
        return (outInput'', outFileInfo'', outXattrs'')
     ) (do
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
     )


-- function ostree_content_file_parse_at
-- Args : [Arg {argCName = "compressed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether or not the stream is zlib-compressed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent_dfd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Directory file descriptor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Subpath", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "trusted", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "If %TRUE, assume the content has been validated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The raw file content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Normal metadata", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_xattrs", argType = TVariant, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_content_file_parse_at" ostree_content_file_parse_at :: 
    CInt ->                                 -- compressed : TBasicType TBoolean
    Int32 ->                                -- parent_dfd : TBasicType TInt
    CString ->                              -- path : TBasicType TUTF8
    CInt ->                                 -- trusted : TBasicType TBoolean
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr (Ptr Gio.FileInfo.FileInfo) ->      -- out_file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr (Ptr GVariant) ->                   -- out_xattrs : TVariant
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
A thin wrapper for 'GI.OSTree.Functions.contentStreamParse'; this function
converts an object content stream back into components.
-}
contentFileParseAt ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Bool
    {- ^ /@compressed@/: Whether or not the stream is zlib-compressed -}
    -> Int32
    {- ^ /@parentDfd@/: Directory file descriptor -}
    -> T.Text
    {- ^ /@path@/: Subpath -}
    -> Bool
    {- ^ /@trusted@/: If 'True', assume the content has been validated -}
    -> Maybe (a)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream,Gio.FileInfo.FileInfo,GVariant)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
contentFileParseAt compressed parentDfd path trusted cancellable = liftIO $ do
    let compressed' = (fromIntegral . fromEnum) compressed
    path' <- textToCString path
    let trusted' = (fromIntegral . fromEnum) trusted
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    outFileInfo <- allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
    outXattrs <- allocMem :: IO (Ptr (Ptr GVariant))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_content_file_parse_at compressed' parentDfd path' trusted' outInput outFileInfo outXattrs maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        outFileInfo' <- peek outFileInfo
        outFileInfo'' <- (wrapObject Gio.FileInfo.FileInfo) outFileInfo'
        outXattrs' <- peek outXattrs
        outXattrs'' <- wrapGVariantPtr outXattrs'
        whenJust cancellable touchManagedPtr
        freeMem path'
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
        return (outInput'', outFileInfo'', outXattrs'')
     ) (do
        freeMem path'
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
     )


-- function ostree_content_file_parse
-- Args : [Arg {argCName = "compressed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Whether or not the stream is zlib-compressed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "content_path", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Path to file containing content", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "trusted", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "If %TRUE, assume the content has been validated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_input", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The raw file content stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Normal metadata", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "out_xattrs", argType = TVariant, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_content_file_parse" ostree_content_file_parse :: 
    CInt ->                                 -- compressed : TBasicType TBoolean
    Ptr Gio.File.File ->                    -- content_path : TInterface (Name {namespace = "Gio", name = "File"})
    CInt ->                                 -- trusted : TBasicType TBoolean
    Ptr (Ptr Gio.InputStream.InputStream) -> -- out_input : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Ptr (Ptr Gio.FileInfo.FileInfo) ->      -- out_file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr (Ptr GVariant) ->                   -- out_xattrs : TVariant
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
A thin wrapper for 'GI.OSTree.Functions.contentStreamParse'; this function
converts an object content stream back into components.
-}
contentFileParse ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.Cancellable.IsCancellable b) =>
    Bool
    {- ^ /@compressed@/: Whether or not the stream is zlib-compressed -}
    -> a
    {- ^ /@contentPath@/: Path to file containing content -}
    -> Bool
    {- ^ /@trusted@/: If 'True', assume the content has been validated -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (Gio.InputStream.InputStream,Gio.FileInfo.FileInfo,GVariant)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
contentFileParse compressed contentPath trusted cancellable = liftIO $ do
    let compressed' = (fromIntegral . fromEnum) compressed
    contentPath' <- unsafeManagedPtrCastPtr contentPath
    let trusted' = (fromIntegral . fromEnum) trusted
    outInput <- allocMem :: IO (Ptr (Ptr Gio.InputStream.InputStream))
    outFileInfo <- allocMem :: IO (Ptr (Ptr Gio.FileInfo.FileInfo))
    outXattrs <- allocMem :: IO (Ptr (Ptr GVariant))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_content_file_parse compressed' contentPath' trusted' outInput outFileInfo outXattrs maybeCancellable
        outInput' <- peek outInput
        outInput'' <- (wrapObject Gio.InputStream.InputStream) outInput'
        outFileInfo' <- peek outFileInfo
        outFileInfo'' <- (wrapObject Gio.FileInfo.FileInfo) outFileInfo'
        outXattrs' <- peek outXattrs
        outXattrs'' <- wrapGVariantPtr outXattrs'
        touchManagedPtr contentPath
        whenJust cancellable touchManagedPtr
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
        return (outInput'', outFileInfo'', outXattrs'')
     ) (do
        freeMem outInput
        freeMem outFileInfo
        freeMem outXattrs
     )


-- function ostree_commit_get_timestamp
-- Args : [Arg {argCName = "commit_variant", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_commit_get_timestamp" ostree_commit_get_timestamp :: 
    Ptr GVariant ->                         -- commit_variant : TVariant
    IO Word64

{- |
/No description available in the introspection data./
-}
commitGetTimestamp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -> m Word64
commitGetTimestamp commitVariant = liftIO $ do
    commitVariant' <- unsafeManagedPtrGetPtr commitVariant
    result <- ostree_commit_get_timestamp commitVariant'
    touchManagedPtr commitVariant
    return result


-- function ostree_commit_get_parent
-- Args : [Arg {argCName = "commit_variant", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Variant of type %OSTREE_OBJECT_TYPE_COMMIT", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_commit_get_parent" ostree_commit_get_parent :: 
    Ptr GVariant ->                         -- commit_variant : TVariant
    IO CString

{- |
/No description available in the introspection data./
-}
commitGetParent ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@commitVariant@/: Variant of type 'GI.OSTree.Enums.ObjectTypeCommit' -}
    -> m T.Text
    {- ^ __Returns:__ Checksum of the parent commit of /@commitVariant@/, or 'Nothing'
if none -}
commitGetParent commitVariant = liftIO $ do
    commitVariant' <- unsafeManagedPtrGetPtr commitVariant
    result <- ostree_commit_get_parent commitVariant'
    checkUnexpectedReturnNULL "commitGetParent" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr commitVariant
    return result'


-- function ostree_cmp_checksum_bytes
-- Args : [Arg {argCName = "a", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A binary checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "b", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A binary checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_cmp_checksum_bytes" ostree_cmp_checksum_bytes :: 
    Word8 ->                                -- a : TBasicType TUInt8
    Word8 ->                                -- b : TBasicType TUInt8
    IO Int32

{- |
Compare two binary checksums, using @/memcmp()/@.
-}
cmpChecksumBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word8
    {- ^ /@a@/: A binary checksum -}
    -> Word8
    {- ^ /@b@/: A binary checksum -}
    -> m Int32
cmpChecksumBytes a b = liftIO $ do
    result <- ostree_cmp_checksum_bytes a b
    return result


-- function ostree_cmd__private__
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "CmdPrivateVTable"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_cmd__private__" ostree_cmd__private__ :: 
    IO (Ptr OSTree.CmdPrivateVTable.CmdPrivateVTable)

{- |
/No description available in the introspection data./
-}
cmd_Private__ ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m OSTree.CmdPrivateVTable.CmdPrivateVTable
cmd_Private__  = liftIO $ do
    result <- ostree_cmd__private__
    checkUnexpectedReturnNULL "cmd_Private__" result
    result' <- (newPtr OSTree.CmdPrivateVTable.CmdPrivateVTable) result
    return result'


-- function ostree_checksum_to_bytes_v
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_to_bytes_v" ostree_checksum_to_bytes_v :: 
    CString ->                              -- checksum : TBasicType TUTF8
    IO (Ptr GVariant)

{- |
/No description available in the introspection data./
-}
checksumToBytesV ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: An ASCII checksum -}
    -> m GVariant
    {- ^ __Returns:__ New 'GVariant' of type ay with length 32 -}
checksumToBytesV checksum = liftIO $ do
    checksum' <- textToCString checksum
    result <- ostree_checksum_to_bytes_v checksum'
    checkUnexpectedReturnNULL "checksumToBytesV" result
    result' <- wrapGVariantPtr result
    freeMem checksum'
    return result'


-- function ostree_checksum_to_bytes
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray False 32 (-1) (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_to_bytes" ostree_checksum_to_bytes :: 
    CString ->                              -- checksum : TBasicType TUTF8
    IO (Ptr Word8)

{- |
/No description available in the introspection data./
-}
checksumToBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: An ASCII checksum -}
    -> m ByteString
    {- ^ __Returns:__ Binary checksum from /@checksum@/ of length 32; free with 'GI.GLib.Functions.free'. -}
checksumToBytes checksum = liftIO $ do
    checksum' <- textToCString checksum
    result <- ostree_checksum_to_bytes checksum'
    checkUnexpectedReturnNULL "checksumToBytes" result
    result' <- (unpackByteStringWithLength 32) result
    freeMem result
    freeMem checksum'
    return result'


-- function ostree_checksum_inplace_to_bytes
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a SHA256 string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buf", argType = TBasicType TUInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Output buffer with at least 32 bytes of space", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_inplace_to_bytes" ostree_checksum_inplace_to_bytes :: 
    CString ->                              -- checksum : TBasicType TUTF8
    Word8 ->                                -- buf : TBasicType TUInt8
    IO ()

{- |
Convert /@checksum@/ from a string to binary in-place, without
allocating memory.  Use this function in hot code paths.
-}
checksumInplaceToBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: a SHA256 string -}
    -> Word8
    {- ^ /@buf@/: Output buffer with at least 32 bytes of space -}
    -> m ()
checksumInplaceToBytes checksum buf = liftIO $ do
    checksum' <- textToCString checksum
    ostree_checksum_inplace_to_bytes checksum' buf
    freeMem checksum'
    return ()


-- function ostree_checksum_from_bytes_v
-- Args : [Arg {argCName = "csum_v", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GVariant of type ay", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_from_bytes_v" ostree_checksum_from_bytes_v :: 
    Ptr GVariant ->                         -- csum_v : TVariant
    IO CString

{- |
/No description available in the introspection data./
-}
checksumFromBytesV ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@csumV@/: 'GVariant' of type ay -}
    -> m T.Text
    {- ^ __Returns:__ String form of /@csumBytes@/ -}
checksumFromBytesV csumV = liftIO $ do
    csumV' <- unsafeManagedPtrGetPtr csumV
    result <- ostree_checksum_from_bytes_v csumV'
    checkUnexpectedReturnNULL "checksumFromBytesV" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr csumV
    return result'


-- function ostree_checksum_from_bytes
-- Args : [Arg {argCName = "csum", argType = TCArray False 32 (-1) (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An binary checksum of length 32", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_from_bytes" ostree_checksum_from_bytes :: 
    Ptr Word8 ->                            -- csum : TCArray False 32 (-1) (TBasicType TUInt8)
    IO CString

{- |
/No description available in the introspection data./
-}
checksumFromBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@csum@/: An binary checksum of length 32 -}
    -> m T.Text
    {- ^ __Returns:__ String form of /@csum@/ -}
checksumFromBytes csum = liftIO $ do
    csum' <- packByteString csum
    result <- ostree_checksum_from_bytes csum'
    checkUnexpectedReturnNULL "checksumFromBytes" result
    result' <- cstringToText result
    freeMem result
    freeMem csum'
    return result'


-- function ostree_checksum_file_from_input
-- Args : [Arg {argCName = "file_info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File information", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xattrs", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Optional extended attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "in", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "File content, should be %NULL for symbolic links", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_csum", argType = TCArray False 32 (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for binary checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_checksum_file_from_input" ostree_checksum_file_from_input :: 
    Ptr Gio.FileInfo.FileInfo ->            -- file_info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr GVariant ->                         -- xattrs : TVariant
    Ptr Gio.InputStream.InputStream ->      -- in : TInterface (Name {namespace = "Gio", name = "InputStream"})
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    Ptr (Ptr Word8) ->                      -- out_csum : TCArray False 32 (-1) (TBasicType TUInt8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Compute the OSTree checksum for a given input.
-}
checksumFileFromInput ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.FileInfo.IsFileInfo a, Gio.InputStream.IsInputStream b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@fileInfo@/: File information -}
    -> Maybe (GVariant)
    {- ^ /@xattrs@/: Optional extended attributes -}
    -> Maybe (b)
    {- ^ /@in@/: File content, should be 'Nothing' for symbolic links -}
    -> OSTree.Enums.ObjectType
    {- ^ /@objtype@/: Object type -}
    -> Maybe (c)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (ByteString)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
checksumFileFromInput fileInfo xattrs in_ objtype cancellable = liftIO $ do
    fileInfo' <- unsafeManagedPtrCastPtr fileInfo
    maybeXattrs <- case xattrs of
        Nothing -> return nullPtr
        Just jXattrs -> do
            jXattrs' <- unsafeManagedPtrGetPtr jXattrs
            return jXattrs'
    maybeIn_ <- case in_ of
        Nothing -> return nullPtr
        Just jIn_ -> do
            jIn_' <- unsafeManagedPtrCastPtr jIn_
            return jIn_'
    let objtype' = (fromIntegral . fromEnum) objtype
    outCsum <- allocMem :: IO (Ptr (Ptr Word8))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_checksum_file_from_input fileInfo' maybeXattrs maybeIn_ objtype' outCsum maybeCancellable
        outCsum' <- peek outCsum
        outCsum'' <- (unpackByteStringWithLength 32) outCsum'
        freeMem outCsum'
        touchManagedPtr fileInfo
        whenJust xattrs touchManagedPtr
        whenJust in_ touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem outCsum
        return outCsum''
     ) (do
        freeMem outCsum
     )


-- function ostree_checksum_file_async_finish
-- Args : [Arg {argCName = "f", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Async result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_csum", argType = TCArray False 32 (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for binary checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_checksum_file_async_finish" ostree_checksum_file_async_finish :: 
    Ptr Gio.File.File ->                    -- f : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr Word8) ->                      -- out_csum : TCArray False 32 (-1) (TBasicType TUInt8)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finish computing the OSTree checksum for a given file; see
'GI.OSTree.Functions.checksumFileAsync'.
-}
checksumFileAsyncFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@f@/: File path -}
    -> b
    {- ^ /@result@/: Async result -}
    -> m (ByteString)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
checksumFileAsyncFinish f result_ = liftIO $ do
    f' <- unsafeManagedPtrCastPtr f
    result_' <- unsafeManagedPtrCastPtr result_
    outCsum <- allocMem :: IO (Ptr (Ptr Word8))
    onException (do
        _ <- propagateGError $ ostree_checksum_file_async_finish f' result_' outCsum
        outCsum' <- peek outCsum
        outCsum'' <- (unpackByteStringWithLength 32) outCsum'
        freeMem outCsum'
        touchManagedPtr f
        touchManagedPtr result_
        freeMem outCsum
        return outCsum''
     ) (do
        freeMem outCsum
     )


-- function ostree_checksum_file_async
-- Args : [Arg {argCName = "f", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Priority for operation, see %G_IO_PRIORITY_DEFAULT", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Invoked when operation is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Data for @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_file_async" ostree_checksum_file_async :: 
    Ptr Gio.File.File ->                    -- f : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously compute the OSTree checksum for a given file;
complete with 'GI.OSTree.Functions.checksumFileAsyncFinish'.
-}
checksumFileAsync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@f@/: File path -}
    -> OSTree.Enums.ObjectType
    {- ^ /@objtype@/: Object type -}
    -> Int32
    {- ^ /@ioPriority@/: Priority for operation, see @/G_IO_PRIORITY_DEFAULT/@ -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Invoked when operation is complete -}
    -> m ()
checksumFileAsync f objtype ioPriority cancellable callback = liftIO $ do
    f' <- unsafeManagedPtrCastPtr f
    let objtype' = (fromIntegral . fromEnum) objtype
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    ostree_checksum_file_async f' objtype' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr f
    whenJust cancellable touchManagedPtr
    return ()


-- function ostree_checksum_file
-- Args : [Arg {argCName = "f", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "objtype", argType = TInterface (Name {namespace = "OSTree", name = "ObjectType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Object type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_csum", argType = TCArray False 32 (-1) (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for binary checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_checksum_file" ostree_checksum_file :: 
    Ptr Gio.File.File ->                    -- f : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- objtype : TInterface (Name {namespace = "OSTree", name = "ObjectType"})
    Ptr (Ptr Word8) ->                      -- out_csum : TCArray False 32 (-1) (TBasicType TUInt8)
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Compute the OSTree checksum for a given file.
-}
checksumFile ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@f@/: File path -}
    -> OSTree.Enums.ObjectType
    {- ^ /@objtype@/: Object type -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (ByteString)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
checksumFile f objtype cancellable = liftIO $ do
    f' <- unsafeManagedPtrCastPtr f
    let objtype' = (fromIntegral . fromEnum) objtype
    outCsum <- allocMem :: IO (Ptr (Ptr Word8))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_checksum_file f' objtype' outCsum maybeCancellable
        outCsum' <- peek outCsum
        outCsum'' <- (unpackByteStringWithLength 32) outCsum'
        freeMem outCsum'
        touchManagedPtr f
        whenJust cancellable touchManagedPtr
        freeMem outCsum
        return outCsum''
     ) (do
        freeMem outCsum
     )


-- function ostree_checksum_bytes_peek_validate
-- Args : [Arg {argCName = "bytes", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GVariant of type ay", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray False 32 (-1) (TBasicType TUInt8))
-- throws : True
-- Skip return : False

foreign import ccall "ostree_checksum_bytes_peek_validate" ostree_checksum_bytes_peek_validate :: 
    Ptr GVariant ->                         -- bytes : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Word8)

{- |
Like 'GI.OSTree.Functions.checksumBytesPeek', but also throws /@error@/.
-}
checksumBytesPeekValidate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@bytes@/: 'GVariant' of type ay -}
    -> m ByteString
    {- ^ __Returns:__ Binary checksum data /(Can throw 'Data.GI.Base.GError.GError')/ -}
checksumBytesPeekValidate bytes = liftIO $ do
    bytes' <- unsafeManagedPtrGetPtr bytes
    onException (do
        result <- propagateGError $ ostree_checksum_bytes_peek_validate bytes'
        checkUnexpectedReturnNULL "checksumBytesPeekValidate" result
        result' <- (unpackByteStringWithLength 32) result
        touchManagedPtr bytes
        return result'
     ) (do
        return ()
     )


-- function ostree_checksum_bytes_peek
-- Args : [Arg {argCName = "bytes", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GVariant of type ay", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray False 32 (-1) (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_bytes_peek" ostree_checksum_bytes_peek :: 
    Ptr GVariant ->                         -- bytes : TVariant
    IO (Ptr Word8)

{- |
/No description available in the introspection data./
-}
checksumBytesPeek ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    {- ^ /@bytes@/: 'GVariant' of type ay -}
    -> m ByteString
    {- ^ __Returns:__ Binary checksum data in /@bytes@/; do not free.  If /@bytes@/ does not have the correct length, return 'Nothing'. -}
checksumBytesPeek bytes = liftIO $ do
    bytes' <- unsafeManagedPtrGetPtr bytes
    result <- ostree_checksum_bytes_peek bytes'
    checkUnexpectedReturnNULL "checksumBytesPeek" result
    result' <- (unpackByteStringWithLength 32) result
    touchManagedPtr bytes
    return result'


-- function ostree_checksum_b64_to_bytes
-- Args : [Arg {argCName = "checksum", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An ASCII checksum", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray False 32 (-1) (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_b64_to_bytes" ostree_checksum_b64_to_bytes :: 
    CString ->                              -- checksum : TBasicType TUTF8
    IO (Ptr Word8)

{- |
/No description available in the introspection data./
-}
checksumB64ToBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@checksum@/: An ASCII checksum -}
    -> m ByteString
    {- ^ __Returns:__ Binary version of /@checksum@/. -}
checksumB64ToBytes checksum = liftIO $ do
    checksum' <- textToCString checksum
    result <- ostree_checksum_b64_to_bytes checksum'
    checkUnexpectedReturnNULL "checksumB64ToBytes" result
    result' <- (unpackByteStringWithLength 32) result
    freeMem result
    freeMem checksum'
    return result'


-- function ostree_checksum_b64_from_bytes
-- Args : [Arg {argCName = "csum", argType = TCArray False 32 (-1) (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An binary checksum of length 32", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_checksum_b64_from_bytes" ostree_checksum_b64_from_bytes :: 
    Ptr Word8 ->                            -- csum : TCArray False 32 (-1) (TBasicType TUInt8)
    IO CString

{- |
/No description available in the introspection data./
-}
checksumB64FromBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    {- ^ /@csum@/: An binary checksum of length 32 -}
    -> m T.Text
    {- ^ __Returns:__ Modified base64 encoding of /@csum@/

The \"modified\" term refers to the fact that instead of \'\/\', the \'_\'
character is used. -}
checksumB64FromBytes csum = liftIO $ do
    csum' <- packByteString csum
    result <- ostree_checksum_b64_from_bytes csum'
    checkUnexpectedReturnNULL "checksumB64FromBytes" result
    result' <- cstringToText result
    freeMem result
    freeMem csum'
    return result'