Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
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, BufferedInputStream
'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 Word64
- bufferedInputStreamGetBufferSize :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> m Word64
- bufferedInputStreamNew :: (HasCallStack, MonadIO m, IsInputStream a) => a -> m BufferedInputStream
- bufferedInputStreamNewSized :: (HasCallStack, MonadIO m, IsInputStream a) => a -> Word64 -> m BufferedInputStream
- bufferedInputStreamPeek :: (HasCallStack, MonadIO m, IsBufferedInputStream a) => a -> ByteString -> Word64 -> m Word64
- 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 -> Word64 -> 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 # | |
IsGValue BufferedInputStream Source # | Convert |
Defined in GI.Gio.Objects.BufferedInputStream toGValue :: BufferedInputStream -> IO GValue # fromGValue :: GValue -> IO BufferedInputStream # | |
ManagedPtrNewtype BufferedInputStream Source # | |
TypedObject BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream | |
GObject BufferedInputStream Source # | |
Defined in GI.Gio.Objects.BufferedInputStream | |
HasParentTypes BufferedInputStream Source # | |
Defined in GI.Gio.Objects.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
Overloaded methods
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 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 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
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 Word64 | 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 Word64 | 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 |
|
-> Word64 |
|
-> 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 |
|
-> Word64 |
|
-> m Word64 | 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 Nothing
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error 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.
setBufferSize
bufferedInputStreamSetBufferSize Source #
:: (HasCallStack, MonadIO m, IsBufferedInputStream a) | |
=> a |
|
-> Word64 |
|
-> 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
No description available in the introspection data.
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 ]