Trait gio::prelude::BufferedInputStreamExt [−][src]
pub trait BufferedInputStreamExt: 'static { fn fill<P: IsA<Cancellable>>(
&self,
count: isize,
cancellable: Option<&P>
) -> Result<isize, Error>; fn fill_async<P: IsA<Cancellable>, Q: FnOnce(Result<isize, Error>) + Send + 'static>(
&self,
count: isize,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
); fn fill_async_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<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> 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
Required methods
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
fill_async()
.
count
the number of bytes that will be read from the stream
cancellable
optional Cancellable
object, None
to ignore
Returns
the number of bytes read into self
’s buffer, up to count
,
or -1 on error.
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][io-priority] of the request
cancellable
optional Cancellable
object
callback
a GAsyncReadyCallback
fn fill_async_future(
&self,
count: isize,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<isize, Error>> + 'static>>
fn buffer_size(&self) -> usize
fn buffer_size(&self) -> usize
fn 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
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 Cancellable
object, None
to ignore
Returns
the byte read from the self
, or -1 on end of stream or error.
fn 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