Trait gio::prelude::BufferedInputStreamExt

source ·
pub trait BufferedInputStreamExt: IsA<BufferedInputStream> + Sealed + 'static {
    // Provided methods
    fn fill(
        &self,
        count: isize,
        cancellable: Option<&impl IsA<Cancellable>>,
    ) -> Result<isize, Error> { ... }
    fn fill_async<P: FnOnce(Result<isize, Error>) + 'static>(
        &self,
        count: isize,
        io_priority: Priority,
        cancellable: Option<&impl IsA<Cancellable>>,
        callback: P,
    ) { ... }
    fn fill_future(
        &self,
        count: isize,
        io_priority: Priority,
    ) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>> { ... }
    fn available(&self) -> usize { ... }
    fn buffer_size(&self) -> usize { ... }
    fn peek_buffer(&self) -> Vec<u8> { ... }
    fn read_byte(
        &self,
        cancellable: Option<&impl IsA<Cancellable>>,
    ) -> Result<i32, Error> { ... }
    fn set_buffer_size(&self, size: usize) { ... }
    fn connect_buffer_size_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all BufferedInputStream methods.

§Implementors

BufferedInputStream, DataInputStream

Provided Methods§

source

fn fill( &self, count: isize, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<isize, Error>

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 IOErrorEnum::InvalidArgument 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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error 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 g_buffered_input_stream_fill_async().

§count

the number of bytes that will be read from the stream

§cancellable

optional #GCancellable object, None to ignore

§Returns

the number of bytes read into @self’s buffer, up to @count, or -1 on error.

source

fn fill_async<P: FnOnce(Result<isize, Error>) + 'static>( &self, count: isize, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )

Reads data into @self’s buffer asynchronously, up to @count size. @io_priority can be used to prioritize reads. For the synchronous version of this function, see g_buffered_input_stream_fill().

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

§count

the number of bytes that will be read from the stream

§io_priority

the [I/O priority][io-priority] of the request

§cancellable

optional #GCancellable object

§callback

a #GAsyncReadyCallback

source

fn fill_future( &self, count: isize, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>

source

fn available(&self) -> usize

Gets the size of the available data within the stream.

§Returns

size of the available stream.

source

fn buffer_size(&self) -> usize

Gets the size of the input buffer.

§Returns

the current buffer size.

source

fn peek_buffer(&self) -> Vec<u8>

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.

§Returns
     read-only buffer
source

fn read_byte( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<i32, Error>

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 None, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error 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.

§cancellable

optional #GCancellable object, None to ignore

§Returns

the byte read from the @self, or -1 on end of stream or error.

source

fn set_buffer_size(&self, size: usize)

Sets the size of the internal buffer of @self to @size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.

§size

a #gsize

source

fn connect_buffer_size_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§