Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
Buffered input stream implements FilterInputStream
and provides
for buffered reads.
By default, GBufferedInputStream
's buffer size is set at 4 kilobytes.
To create a buffered input stream, use bufferedInputStreamNew
,
or bufferedInputStreamNewSized
to specify the buffer's size at
construction.
To get the size of a buffer within a buffered input stream, use
bufferedInputStreamGetBufferSize
. To change the size of a
buffered input stream's buffer, use bufferedInputStreamSetBufferSize
.
Note that the buffer's size cannot be reduced below the size of the data within the buffer.
Synopsis
- newtype BufferedInputStream = BufferedInputStream (ManagedPtr BufferedInputStream)
- class (GObject o, IsDescendantOf BufferedInputStream o) => IsBufferedInputStream o
- toBufferedInputStream :: (MonadIO m, IsBufferedInputStream o) => o -> m BufferedInputStream
- bufferedInputStreamFill :: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) => a -> Int64 -> Maybe b -> m Int64
- bufferedInputStreamFillAsync :: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) => a -> Int64 -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- bufferedInputStreamFillFinish :: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsAsyncResult b) => a -> b -> m Int64
- bufferedInputStreamGetAvailable :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> m CSize
- bufferedInputStreamGetBufferSize :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> m CSize
- bufferedInputStreamNew :: (HasCallStack, MonadIO m, IsInputStream a) => a -> m BufferedInputStream
- bufferedInputStreamNewSized :: (HasCallStack, MonadIO m, IsInputStream a) => a -> CSize -> m BufferedInputStream
- bufferedInputStreamPeek :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> ByteString -> CSize -> m CSize
- bufferedInputStreamPeekBuffer :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> m ByteString
- bufferedInputStreamReadByte :: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) => a -> Maybe b -> m Int32
- bufferedInputStreamSetBufferSize :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> CSize -> m ()
- constructBufferedInputStreamBufferSize :: (IsBufferedInputStream o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> m Word32
- setBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> Word32 -> m ()
Exported types
newtype BufferedInputStream Source #
Memory-managed wrapper type.
Instances
Eq BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream (==) :: BufferedInputStream -> BufferedInputStream -> Bool # (/=) :: BufferedInputStream -> BufferedInputStream -> Bool # | |
GObject BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream | |
ManagedPtrNewtype BufferedInputStream Source # | |
TypedObject BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream | |
HasParentTypes BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream | |
IsGValue (Maybe BufferedInputStream) Source # | Convert |
Defined in GI.Gio.Objects.BufferedInputStream gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe BufferedInputStream -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe BufferedInputStream) # | |
type ParentTypes BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream |
class (GObject o, IsDescendantOf BufferedInputStream o) => IsBufferedInputStream o Source #
Type class for types which can be safely cast to BufferedInputStream
, for instance with toBufferedInputStream
.
Instances
(GObject o, IsDescendantOf BufferedInputStream o) => IsBufferedInputStream o Source # | |
Defined in GI.Gio.Objects.BufferedInputStream |
toBufferedInputStream :: (MonadIO m, IsBufferedInputStream o) => o -> m BufferedInputStream Source #
Cast to BufferedInputStream
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, canSeek, canTruncate, clearPending, close, closeAsync, closeFinish, fill, fillAsync, fillFinish, forceFloating, freezeNotify, getv, hasPending, isClosed, isFloating, notify, notifyByPspec, peek, peekBuffer, read, readAll, readAllAsync, readAllFinish, readAsync, readByte, readBytes, readBytesAsync, readBytesFinish, readFinish, ref, refSink, runDispose, seek, skip, skipAsync, skipFinish, stealData, stealQdata, tell, thawNotify, truncate, unref, watchClosure.
Getters
getAvailable, getBaseStream, getBufferSize, getCloseBaseStream, getData, getProperty, getQdata.
Setters
setBufferSize, setCloseBaseStream, setData, setDataFull, setPending, setProperty.
fill
bufferedInputStreamFill Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) | |
=> a |
|
-> Int64 |
|
-> Maybe b |
|
-> m Int64 | Returns: the number of bytes read into |
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
[errorgio
.IOErrorEnum.INVALID_ARGUMENT] 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 NULL
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error [errorgio
.IOErrorEnum.CANCELLED] 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
bufferedInputStreamFillAsync
.
fillAsync
bufferedInputStreamFillAsync Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) | |
=> a |
|
-> Int64 |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
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 bufferedInputStreamFill
.
If count
is -1
then the attempted read size is equal to the number
of bytes that are required to fill the buffer.
fillFinish
bufferedInputStreamFillFinish Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m Int64 | Returns: a |
Finishes an asynchronous read.
getAvailable
bufferedInputStreamGetAvailable Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> m CSize | Returns: size of the available stream. |
Gets the size of the available data within the stream.
getBufferSize
bufferedInputStreamGetBufferSize Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> m CSize | Returns: the current buffer size. |
Gets the size of the input buffer.
new
bufferedInputStreamNew Source #
:: (HasCallStack, MonadIO m, IsInputStream a) | |
=> a |
|
-> m BufferedInputStream | Returns: a |
Creates a new InputStream
from the given baseStream
, with
a buffer set to the default size (4 kilobytes).
newSized
bufferedInputStreamNewSized Source #
:: (HasCallStack, MonadIO m, IsInputStream a) | |
=> a |
|
-> CSize |
|
-> m BufferedInputStream | Returns: a |
Creates a new BufferedInputStream
from the given baseStream
,
with a buffer set to size
.
peek
bufferedInputStreamPeek Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> ByteString |
|
-> CSize |
|
-> m CSize | Returns: a |
Peeks in the buffer, copying data of size count
into buffer
,
offset offset
bytes.
peekBuffer
bufferedInputStreamPeekBuffer Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> m ByteString | Returns: read-only buffer |
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.
readByte
bufferedInputStreamReadByte Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m Int32 | Returns: the byte read from the |
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 NULL
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error [errorgio
.IOErrorEnum.CANCELLED] 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.
setBufferSize
bufferedInputStreamSetBufferSize Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> CSize |
|
-> m () |
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.
Properties
bufferSize
The size of the backend buffer, in bytes.
constructBufferedInputStreamBufferSize :: (IsBufferedInputStream o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “buffer-size
” property. This is rarely needed directly, but it is used by new
.
getBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> m Word32 Source #
Get the value of the “buffer-size
” property.
When overloading is enabled, this is equivalent to
get
bufferedInputStream #bufferSize
setBufferedInputStreamBufferSize :: (MonadIO m, IsBufferedInputStream o) => o -> Word32 -> m () Source #
Set the value of the “buffer-size
” property.
When overloading is enabled, this is equivalent to
set
bufferedInputStream [ #bufferSize:=
value ]