gi-gio-2.0.18: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.BufferedInputStream

Contents

Description

Buffered input stream implements 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 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

Exported types

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

fill

bufferedInputStreamFill Source #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) 
=> a

stream: a BufferedInputStream

-> Int64

count: the number of bytes that will be read from the stream

-> Maybe b

cancellable: optional 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 GError)

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 #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) 
=> a

stream: a 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 Cancellable object

-> Maybe AsyncReadyCallback

callback: a 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 #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsAsyncResult b) 
=> a

stream: a BufferedInputStream

-> b

result: a AsyncResult

-> m Int64

Returns: a gssize of the read stream, or -1 on an error. (Can throw GError)

Finishes an asynchronous read.

getAvailable

bufferedInputStreamGetAvailable Source #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a) 
=> a

stream: BufferedInputStream

-> m Word64

Returns: size of the available stream.

Gets the size of the available data within the stream.

getBufferSize

bufferedInputStreamGetBufferSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a) 
=> a

stream: a BufferedInputStream

-> m Word64

Returns: the current buffer size.

Gets the size of the input buffer.

new

bufferedInputStreamNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsInputStream a) 
=> a

baseStream: a InputStream

-> m BufferedInputStream

Returns: a InputStream for the given baseStream.

Creates a new InputStream from the given baseStream, with a buffer set to the default size (4 kilobytes).

newSized

bufferedInputStreamNewSized Source #

Arguments

:: (HasCallStack, MonadIO m, IsInputStream a) 
=> a

baseStream: a InputStream

-> Word64

size: a gsize

-> m BufferedInputStream

Returns: a InputStream.

Creates a new BufferedInputStream from the given baseStream, with a buffer set to size.

peek

bufferedInputStreamPeek Source #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a) 
=> a

stream: a 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.

Peeks in the buffer, copying data of size count into buffer, offset offset bytes.

peekBuffer

bufferedInputStreamPeekBuffer Source #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a) 
=> a

stream: a BufferedInputStream

-> 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 #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a, IsCancellable b) 
=> a

stream: a BufferedInputStream

-> Maybe b

cancellable: optional Cancellable object, Nothing to ignore

-> m Int32

Returns: the byte read from the stream, or -1 on end of stream or error. (Can throw GError)

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 #

Arguments

:: (HasCallStack, MonadIO m, IsBufferedInputStream a) 
=> a

stream: a BufferedInputStream

-> Word64

size: a gsize

-> 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 => Word32 -> IO (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 ]