pub trait BufferedInputStreamExt: IsA<BufferedInputStream> + '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
Provided Methods§
Sourcefn fill(
&self,
count: isize,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<isize, Error>
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
[error@Gio.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 [error@Gio.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
fill_async()
.
§count
the number of bytes that will be read from the stream
§cancellable
optional Cancellable
object, NULL
to ignore
§Returns
the number of bytes read into @self’s buffer, up to @count,
or -1
on error.
Sourcefn fill_async<P: FnOnce(Result<isize, Error>) + 'static>(
&self,
count: isize,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
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 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 of the request
§cancellable
optional Cancellable
object
§callback
a `callback::Gio::AsyncReadyCallback
fn fill_future( &self, count: isize, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
Sourcefn buffer_size(&self) -> usize
fn buffer_size(&self) -> usize
Sourcefn peek_buffer(&self) -> Vec<u8>
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
Sourcefn read_byte(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<i32, Error>
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 NULL
, then the operation can be cancelled by
triggering the cancellable object from another thread. If the operation
was cancelled, the error [error@Gio.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 Cancellable
object, NULL
to ignore
§Returns
the byte read from the @self, or -1
on end of stream or error.
Sourcefn set_buffer_size(&self, size: usize)
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
fn connect_buffer_size_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.