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

Buffered input stream implements 'GI.Gio.Objects.FilterInputStream.FilterInputStream' and provides
for buffered reads.

By default, 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream'\'s buffer size is set at 4 kilobytes.

To create a buffered input stream, use 'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamNew',
or 'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamNewSized' to specify the buffer\'s size at
construction.

To get the size of a buffer within a buffered input stream, use
'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamGetBufferSize'. To change the size of a
buffered input stream\'s buffer, use
'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamSetBufferSize'. Note that the buffer\'s size
cannot be reduced below the size of the data within the buffer.
-}

module GI.Gio.Objects.BufferedInputStream
    ( 

-- * Exported types
    BufferedInputStream(..)                 ,
    IsBufferedInputStream                   ,
    toBufferedInputStream                   ,
    noBufferedInputStream                   ,


 -- * Methods
-- ** fill #method:fill#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamFillMethodInfo       ,
#endif
    bufferedInputStreamFill                 ,


-- ** fillAsync #method:fillAsync#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamFillAsyncMethodInfo  ,
#endif
    bufferedInputStreamFillAsync            ,


-- ** fillFinish #method:fillFinish#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamFillFinishMethodInfo ,
#endif
    bufferedInputStreamFillFinish           ,


-- ** getAvailable #method:getAvailable#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamGetAvailableMethodInfo,
#endif
    bufferedInputStreamGetAvailable         ,


-- ** getBufferSize #method:getBufferSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamGetBufferSizeMethodInfo,
#endif
    bufferedInputStreamGetBufferSize        ,


-- ** new #method:new#
    bufferedInputStreamNew                  ,


-- ** newSized #method:newSized#
    bufferedInputStreamNewSized             ,


-- ** peek #method:peek#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamPeekMethodInfo       ,
#endif
    bufferedInputStreamPeek                 ,


-- ** peekBuffer #method:peekBuffer#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamPeekBufferMethodInfo ,
#endif
    bufferedInputStreamPeekBuffer           ,


-- ** readByte #method:readByte#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamReadByteMethodInfo   ,
#endif
    bufferedInputStreamReadByte             ,


-- ** setBufferSize #method:setBufferSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamSetBufferSizeMethodInfo,
#endif
    bufferedInputStreamSetBufferSize        ,




 -- * Properties
-- ** bufferSize #attr:bufferSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    BufferedInputStreamBufferSizePropertyInfo,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    bufferedInputStreamBufferSize           ,
#endif
    constructBufferedInputStreamBufferSize  ,
    getBufferedInputStreamBufferSize        ,
    setBufferedInputStreamBufferSize        ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Seekable as Gio.Seekable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.FilterInputStream as Gio.FilterInputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream

newtype BufferedInputStream = BufferedInputStream (ManagedPtr BufferedInputStream)
foreign import ccall "g_buffered_input_stream_get_type"
    c_g_buffered_input_stream_get_type :: IO GType

instance GObject BufferedInputStream where
    gobjectType _ = c_g_buffered_input_stream_get_type
    

class GObject o => IsBufferedInputStream o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError BufferedInputStream a) =>
    IsBufferedInputStream a
#endif
instance IsBufferedInputStream BufferedInputStream
instance Gio.FilterInputStream.IsFilterInputStream BufferedInputStream
instance Gio.InputStream.IsInputStream BufferedInputStream
instance GObject.Object.IsObject BufferedInputStream
instance Gio.Seekable.IsSeekable BufferedInputStream

toBufferedInputStream :: (MonadIO m, IsBufferedInputStream o) => o -> m BufferedInputStream
toBufferedInputStream = liftIO . unsafeCastTo BufferedInputStream

noBufferedInputStream :: Maybe BufferedInputStream
noBufferedInputStream = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveBufferedInputStreamMethod (t :: Symbol) (o :: *) :: * where
    ResolveBufferedInputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveBufferedInputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveBufferedInputStreamMethod "canSeek" o = Gio.Seekable.SeekableCanSeekMethodInfo
    ResolveBufferedInputStreamMethod "canTruncate" o = Gio.Seekable.SeekableCanTruncateMethodInfo
    ResolveBufferedInputStreamMethod "clearPending" o = Gio.InputStream.InputStreamClearPendingMethodInfo
    ResolveBufferedInputStreamMethod "close" o = Gio.InputStream.InputStreamCloseMethodInfo
    ResolveBufferedInputStreamMethod "closeAsync" o = Gio.InputStream.InputStreamCloseAsyncMethodInfo
    ResolveBufferedInputStreamMethod "closeFinish" o = Gio.InputStream.InputStreamCloseFinishMethodInfo
    ResolveBufferedInputStreamMethod "fill" o = BufferedInputStreamFillMethodInfo
    ResolveBufferedInputStreamMethod "fillAsync" o = BufferedInputStreamFillAsyncMethodInfo
    ResolveBufferedInputStreamMethod "fillFinish" o = BufferedInputStreamFillFinishMethodInfo
    ResolveBufferedInputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveBufferedInputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveBufferedInputStreamMethod "hasPending" o = Gio.InputStream.InputStreamHasPendingMethodInfo
    ResolveBufferedInputStreamMethod "isClosed" o = Gio.InputStream.InputStreamIsClosedMethodInfo
    ResolveBufferedInputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveBufferedInputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveBufferedInputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveBufferedInputStreamMethod "peek" o = BufferedInputStreamPeekMethodInfo
    ResolveBufferedInputStreamMethod "peekBuffer" o = BufferedInputStreamPeekBufferMethodInfo
    ResolveBufferedInputStreamMethod "read" o = Gio.InputStream.InputStreamReadMethodInfo
    ResolveBufferedInputStreamMethod "readAll" o = Gio.InputStream.InputStreamReadAllMethodInfo
    ResolveBufferedInputStreamMethod "readAllAsync" o = Gio.InputStream.InputStreamReadAllAsyncMethodInfo
    ResolveBufferedInputStreamMethod "readAllFinish" o = Gio.InputStream.InputStreamReadAllFinishMethodInfo
    ResolveBufferedInputStreamMethod "readAsync" o = Gio.InputStream.InputStreamReadAsyncMethodInfo
    ResolveBufferedInputStreamMethod "readByte" o = BufferedInputStreamReadByteMethodInfo
    ResolveBufferedInputStreamMethod "readBytes" o = Gio.InputStream.InputStreamReadBytesMethodInfo
    ResolveBufferedInputStreamMethod "readBytesAsync" o = Gio.InputStream.InputStreamReadBytesAsyncMethodInfo
    ResolveBufferedInputStreamMethod "readBytesFinish" o = Gio.InputStream.InputStreamReadBytesFinishMethodInfo
    ResolveBufferedInputStreamMethod "readFinish" o = Gio.InputStream.InputStreamReadFinishMethodInfo
    ResolveBufferedInputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveBufferedInputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveBufferedInputStreamMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveBufferedInputStreamMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveBufferedInputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveBufferedInputStreamMethod "seek" o = Gio.Seekable.SeekableSeekMethodInfo
    ResolveBufferedInputStreamMethod "skip" o = Gio.InputStream.InputStreamSkipMethodInfo
    ResolveBufferedInputStreamMethod "skipAsync" o = Gio.InputStream.InputStreamSkipAsyncMethodInfo
    ResolveBufferedInputStreamMethod "skipFinish" o = Gio.InputStream.InputStreamSkipFinishMethodInfo
    ResolveBufferedInputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveBufferedInputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveBufferedInputStreamMethod "tell" o = Gio.Seekable.SeekableTellMethodInfo
    ResolveBufferedInputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveBufferedInputStreamMethod "truncate" o = Gio.Seekable.SeekableTruncateMethodInfo
    ResolveBufferedInputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveBufferedInputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveBufferedInputStreamMethod "getAvailable" o = BufferedInputStreamGetAvailableMethodInfo
    ResolveBufferedInputStreamMethod "getBaseStream" o = Gio.FilterInputStream.FilterInputStreamGetBaseStreamMethodInfo
    ResolveBufferedInputStreamMethod "getBufferSize" o = BufferedInputStreamGetBufferSizeMethodInfo
    ResolveBufferedInputStreamMethod "getCloseBaseStream" o = Gio.FilterInputStream.FilterInputStreamGetCloseBaseStreamMethodInfo
    ResolveBufferedInputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveBufferedInputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveBufferedInputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveBufferedInputStreamMethod "setBufferSize" o = BufferedInputStreamSetBufferSizeMethodInfo
    ResolveBufferedInputStreamMethod "setCloseBaseStream" o = Gio.FilterInputStream.FilterInputStreamSetCloseBaseStreamMethodInfo
    ResolveBufferedInputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveBufferedInputStreamMethod "setPending" o = Gio.InputStream.InputStreamSetPendingMethodInfo
    ResolveBufferedInputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveBufferedInputStreamMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveBufferedInputStreamMethod t BufferedInputStream, O.MethodInfo info BufferedInputStream p) => O.IsLabelProxy t (BufferedInputStream -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBufferedInputStreamMethod t BufferedInputStream, O.MethodInfo info BufferedInputStream p) => O.IsLabel t (BufferedInputStream -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- VVV Prop "buffer-size"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Nothing,Nothing)

getBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> m Word32
getBufferedInputStreamBufferSize obj = liftIO $ getObjectPropertyUInt32 obj "buffer-size"

setBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> Word32 -> m ()
setBufferedInputStreamBufferSize obj val = liftIO $ setObjectPropertyUInt32 obj "buffer-size" val

constructBufferedInputStreamBufferSize :: (IsBufferedInputStream o) => Word32 -> IO (GValueConstruct o)
constructBufferedInputStreamBufferSize val = constructObjectPropertyUInt32 "buffer-size" val

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamBufferSizePropertyInfo
instance AttrInfo BufferedInputStreamBufferSizePropertyInfo where
    type AttrAllowedOps BufferedInputStreamBufferSizePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint BufferedInputStreamBufferSizePropertyInfo = (~) Word32
    type AttrBaseTypeConstraint BufferedInputStreamBufferSizePropertyInfo = IsBufferedInputStream
    type AttrGetType BufferedInputStreamBufferSizePropertyInfo = Word32
    type AttrLabel BufferedInputStreamBufferSizePropertyInfo = "buffer-size"
    type AttrOrigin BufferedInputStreamBufferSizePropertyInfo = BufferedInputStream
    attrGet _ = getBufferedInputStreamBufferSize
    attrSet _ = setBufferedInputStreamBufferSize
    attrConstruct _ = constructBufferedInputStreamBufferSize
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList BufferedInputStream
type instance O.AttributeList BufferedInputStream = BufferedInputStreamAttributeList
type BufferedInputStreamAttributeList = ('[ '("baseStream", Gio.FilterInputStream.FilterInputStreamBaseStreamPropertyInfo), '("bufferSize", BufferedInputStreamBufferSizePropertyInfo), '("closeBaseStream", Gio.FilterInputStream.FilterInputStreamCloseBaseStreamPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
bufferedInputStreamBufferSize :: AttrLabelProxy "bufferSize"
bufferedInputStreamBufferSize = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList BufferedInputStream = BufferedInputStreamSignalList
type BufferedInputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method BufferedInputStream::new
-- method type : Constructor
-- Args : [Arg {argCName = "base_stream", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_new" g_buffered_input_stream_new :: 
    Ptr Gio.InputStream.InputStream ->      -- base_stream : TInterface (Name {namespace = "Gio", name = "InputStream"})
    IO (Ptr BufferedInputStream)

{- |
Creates a new 'GI.Gio.Objects.InputStream.InputStream' from the given /@baseStream@/, with
a buffer set to the default size (4 kilobytes).
-}
bufferedInputStreamNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a) =>
    a
    {- ^ /@baseStream@/: a 'GI.Gio.Objects.InputStream.InputStream' -}
    -> m BufferedInputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream' for the given /@baseStream@/. -}
bufferedInputStreamNew baseStream = liftIO $ do
    baseStream' <- unsafeManagedPtrCastPtr baseStream
    result <- g_buffered_input_stream_new baseStream'
    checkUnexpectedReturnNULL "bufferedInputStreamNew" result
    result' <- (wrapObject BufferedInputStream) result
    touchManagedPtr baseStream
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

-- method BufferedInputStream::new_sized
-- method type : Constructor
-- Args : [Arg {argCName = "base_stream", argType = TInterface (Name {namespace = "Gio", name = "InputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_new_sized" g_buffered_input_stream_new_sized :: 
    Ptr Gio.InputStream.InputStream ->      -- base_stream : TInterface (Name {namespace = "Gio", name = "InputStream"})
    Word64 ->                               -- size : TBasicType TUInt64
    IO (Ptr BufferedInputStream)

{- |
Creates a new 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' from the given /@baseStream@/,
with a buffer set to /@size@/.
-}
bufferedInputStreamNewSized ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.InputStream.IsInputStream a) =>
    a
    {- ^ /@baseStream@/: a 'GI.Gio.Objects.InputStream.InputStream' -}
    -> Word64
    {- ^ /@size@/: a @/gsize/@ -}
    -> m BufferedInputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream'. -}
bufferedInputStreamNewSized baseStream size = liftIO $ do
    baseStream' <- unsafeManagedPtrCastPtr baseStream
    result <- g_buffered_input_stream_new_sized baseStream' size
    checkUnexpectedReturnNULL "bufferedInputStreamNewSized" result
    result' <- (wrapObject BufferedInputStream) result
    touchManagedPtr baseStream
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

-- method BufferedInputStream::fill
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes that will be read from the stream", 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 "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill" g_buffered_input_stream_fill :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Int64 ->                                -- count : TBasicType TInt64
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Int64

{- |
Tries to read /@count@/ bytes from the stream into the buffer.
Will block during this read.

If /@count@/ is zero, returns zero and does nothing. A value of /@count@/
larger than @/G_MAXSSIZE/@ will cause a 'GI.Gio.Enums.IOErrorEnumInvalidArgument' error.

On success, the number of bytes read into the buffer is returned.
It is not an error if this is not the same as the requested size, as it
can happen e.g. near the end of a file. Zero is returned on end of file
(or if /@count@/ is zero),  but never otherwise.

If /@count@/ is -1 then the attempted read size is equal to the number of
bytes that are required to fill the buffer.

If /@cancellable@/ is not 'Nothing', then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.

On error -1 is returned and /@error@/ is set accordingly.

For the asynchronous, non-blocking, version of this function, see
'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamFillAsync'.
-}
bufferedInputStreamFill ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> Int64
    {- ^ /@count@/: the number of bytes that will be read from the stream -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m Int64
    {- ^ __Returns:__ the number of bytes read into /@stream@/\'s buffer, up to /@count@/,
    or -1 on error. /(Can throw 'Data.GI.Base.GError.GError')/ -}
bufferedInputStreamFill stream count cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_buffered_input_stream_fill stream' count maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamFillMethodInfo
instance (signature ~ (Int64 -> Maybe (b) -> m Int64), MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo BufferedInputStreamFillMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamFill

#endif

-- method BufferedInputStream::fill_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "count", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes that will be read from the stream", 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 "the [I/O priority][io-priority] of the request", 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 "optional #GCancellable object", 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 "a #GAsyncReadyCallback", 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 "a #gpointer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill_async" g_buffered_input_stream_fill_async :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Int64 ->                                -- count : TBasicType TInt64
    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 ()

{- |
Reads data into /@stream@/\'s buffer asynchronously, up to /@count@/ size.
/@ioPriority@/ can be used to prioritize reads. For the synchronous
version of this function, see 'GI.Gio.Objects.BufferedInputStream.bufferedInputStreamFill'.

If /@count@/ is -1 then the attempted read size is equal to the number
of bytes that are required to fill the buffer.
-}
bufferedInputStreamFillAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> Int64
    {- ^ /@count@/: the number of bytes that will be read from the stream -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' -}
    -> m ()
bufferedInputStreamFillAsync stream count ioPriority cancellable callback = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    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
    g_buffered_input_stream_fill_async stream' count ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr stream
    whenJust cancellable touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamFillAsyncMethodInfo
instance (signature ~ (Int64 -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo BufferedInputStreamFillAsyncMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamFillAsync

#endif

-- method BufferedInputStream::fill_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", 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 "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_fill_finish" g_buffered_input_stream_fill_finish :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO Int64

{- |
Finishes an asynchronous read.
-}
bufferedInputStreamFillFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m Int64
    {- ^ __Returns:__ a @/gssize/@ of the read stream, or %-1 on an error. /(Can throw 'Data.GI.Base.GError.GError')/ -}
bufferedInputStreamFillFinish stream result_ = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_buffered_input_stream_fill_finish stream' result_'
        touchManagedPtr stream
        touchManagedPtr result_
        return result
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamFillFinishMethodInfo
instance (signature ~ (b -> m Int64), MonadIO m, IsBufferedInputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo BufferedInputStreamFillFinishMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamFillFinish

#endif

-- method BufferedInputStream::get_available
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GBufferedInputStream", 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 "g_buffered_input_stream_get_available" g_buffered_input_stream_get_available :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    IO Word64

{- |
Gets the size of the available data within the stream.
-}
bufferedInputStreamGetAvailable ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a) =>
    a
    {- ^ /@stream@/: 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> m Word64
    {- ^ __Returns:__ size of the available stream. -}
bufferedInputStreamGetAvailable stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_buffered_input_stream_get_available stream'
    touchManagedPtr stream
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamGetAvailableMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsBufferedInputStream a) => O.MethodInfo BufferedInputStreamGetAvailableMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamGetAvailable

#endif

-- method BufferedInputStream::get_buffer_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", 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 "g_buffered_input_stream_get_buffer_size" g_buffered_input_stream_get_buffer_size :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    IO Word64

{- |
Gets the size of the input buffer.
-}
bufferedInputStreamGetBufferSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> m Word64
    {- ^ __Returns:__ the current buffer size. -}
bufferedInputStreamGetBufferSize stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    result <- g_buffered_input_stream_get_buffer_size stream'
    touchManagedPtr stream
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamGetBufferSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsBufferedInputStream a) => O.MethodInfo BufferedInputStreamGetBufferSizeMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamGetBufferSize

#endif

-- method BufferedInputStream::peek
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a pointer to\n  an allocated chunk of memory", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offset", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "count", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_peek" g_buffered_input_stream_peek :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 3 (TBasicType TUInt8)
    Word64 ->                               -- offset : TBasicType TUInt64
    Word64 ->                               -- count : TBasicType TUInt64
    IO Word64

{- |
Peeks in the buffer, copying data of size /@count@/ into /@buffer@/,
offset /@offset@/ bytes.
-}
bufferedInputStreamPeek ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> ByteString
    {- ^ /@buffer@/: a pointer to
  an allocated chunk of memory -}
    -> Word64
    {- ^ /@offset@/: a @/gsize/@ -}
    -> m Word64
    {- ^ __Returns:__ a @/gsize/@ of the number of bytes peeked, or -1 on error. -}
bufferedInputStreamPeek stream buffer offset = liftIO $ do
    let count = fromIntegral $ B.length buffer
    stream' <- unsafeManagedPtrCastPtr stream
    buffer' <- packByteString buffer
    result <- g_buffered_input_stream_peek stream' buffer' offset count
    touchManagedPtr stream
    freeMem buffer'
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamPeekMethodInfo
instance (signature ~ (ByteString -> Word64 -> m Word64), MonadIO m, IsBufferedInputStream a) => O.MethodInfo BufferedInputStreamPeekMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamPeek

#endif

-- method BufferedInputStream::peek_buffer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "count", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the number of bytes available in the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "count", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize to get the number of bytes available in the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TCArray False (-1) 1 (TBasicType TUInt8))
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_peek_buffer" g_buffered_input_stream_peek_buffer :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Ptr Word64 ->                           -- count : TBasicType TUInt64
    IO (Ptr Word8)

{- |
Returns the buffer with the currently available bytes. The returned
buffer must not be modified and will become invalid when reading from
the stream or filling the buffer.
-}
bufferedInputStreamPeekBuffer ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> m ByteString
    {- ^ __Returns:__ 
         read-only buffer -}
bufferedInputStreamPeekBuffer stream = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    count <- allocMem :: IO (Ptr Word64)
    result <- g_buffered_input_stream_peek_buffer stream' count
    count' <- peek count
    checkUnexpectedReturnNULL "bufferedInputStreamPeekBuffer" result
    result' <- (unpackByteStringWithLength count') result
    touchManagedPtr stream
    freeMem count
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamPeekBufferMethodInfo
instance (signature ~ (m ByteString), MonadIO m, IsBufferedInputStream a) => O.MethodInfo BufferedInputStreamPeekBufferMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamPeekBuffer

#endif

-- method BufferedInputStream::read_byte
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", 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 "optional #GCancellable object, %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : True
-- Skip return : False

foreign import ccall "g_buffered_input_stream_read_byte" g_buffered_input_stream_read_byte :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO Int32

{- |
Tries to read a single byte from the stream or the buffer. Will block
during this read.

On success, the byte read from the stream is returned. On end of stream
-1 is returned but it\'s not an exceptional error and /@error@/ is not set.

If /@cancellable@/ is not 'Nothing', then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error 'GI.Gio.Enums.IOErrorEnumCancelled' will be returned. If an
operation was partially finished when the operation was cancelled the
partial result will be returned, without an error.

On error -1 is returned and /@error@/ is set accordingly.
-}
bufferedInputStreamReadByte ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore -}
    -> m Int32
    {- ^ __Returns:__ the byte read from the /@stream@/, or -1 on end of stream or error. /(Can throw 'Data.GI.Base.GError.GError')/ -}
bufferedInputStreamReadByte stream cancellable = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_buffered_input_stream_read_byte stream' maybeCancellable
        touchManagedPtr stream
        whenJust cancellable touchManagedPtr
        return result
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamReadByteMethodInfo
instance (signature ~ (Maybe (b) -> m Int32), MonadIO m, IsBufferedInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo BufferedInputStreamReadByteMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamReadByte

#endif

-- method BufferedInputStream::set_buffer_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "BufferedInputStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBufferedInputStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #gsize", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_buffered_input_stream_set_buffer_size" g_buffered_input_stream_set_buffer_size :: 
    Ptr BufferedInputStream ->              -- stream : TInterface (Name {namespace = "Gio", name = "BufferedInputStream"})
    Word64 ->                               -- size : TBasicType TUInt64
    IO ()

{- |
Sets the size of the internal buffer of /@stream@/ to /@size@/, or to the
size of the contents of the buffer. The buffer can never be resized
smaller than its current contents.
-}
bufferedInputStreamSetBufferSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsBufferedInputStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.BufferedInputStream.BufferedInputStream' -}
    -> Word64
    {- ^ /@size@/: a @/gsize/@ -}
    -> m ()
bufferedInputStreamSetBufferSize stream size = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    g_buffered_input_stream_set_buffer_size stream' size
    touchManagedPtr stream
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data BufferedInputStreamSetBufferSizeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsBufferedInputStream a) => O.MethodInfo BufferedInputStreamSetBufferSizeMethodInfo a signature where
    overloadedMethod _ = bufferedInputStreamSetBufferSize

#endif