Trait gio::prelude::DataInputStreamExtManual [−][src]
pub trait DataInputStreamExtManual: 'static { fn read_line<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<Vec<u8>, Error>; fn read_line_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
); fn read_line_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>; fn read_line_utf8<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<Option<GString>, Error>; fn read_line_utf8_async<P: IsA<Cancellable>, Q: FnOnce(Result<Option<GString>, Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
); fn read_line_utf8_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Option<GString>, Error>> + 'static>>; fn read_until<P: IsA<Cancellable>>(
&self,
stop_chars: &[u8],
cancellable: Option<&P>
) -> Result<Vec<u8>, Error>; fn read_until_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + Send + 'static>(
&self,
stop_chars: &[u8],
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
); fn read_until_async_future(
&self,
stop_chars: &[u8],
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>; fn read_upto<P: IsA<Cancellable>>(
&self,
stop_chars: &[u8],
cancellable: Option<&P>
) -> Result<Vec<u8>, Error>; fn read_upto_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + Send + 'static>(
&self,
stop_chars: &[u8],
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
); fn read_upto_async_future(
&self,
stop_chars: &[u8],
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>; }
Required methods
Reads a line from the data input stream. Note that no encoding checks or conversion is performed; the input is not guaranteed to be UTF-8, and may in fact have embedded NUL characters.
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.
cancellable
optional Cancellable
object, None
to ignore.
Returns
a NUL terminated byte array with the line that was read in
(without the newlines). Set length
to a gsize
to get the length
of the read line. On an error, it will return None
and error
will be set. If there’s no content to read, it will still return
None
, but error
won’t be set.
length
a gsize
to get the length of the data read in.
The asynchronous version of read_line()
. It is
an error to have two outstanding calls to this function.
When the operation is finished, callback
will be called. You
can then call g_data_input_stream_read_line_finish()
to get
the result of the operation.
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
object, None
to ignore.
callback
callback to call when the request is satisfied.
fn read_line_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>
fn read_line_utf8<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<Option<GString>, Error>
fn read_line_utf8<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<Option<GString>, Error>
Reads a UTF-8 encoded line from the data input stream.
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.
cancellable
optional Cancellable
object, None
to ignore.
Returns
a NUL terminated UTF-8 string
with the line that was read in (without the newlines). Set
length
to a gsize
to get the length of the read line. On an
error, it will return None
and error
will be set. For UTF-8
conversion errors, the set error domain is G_CONVERT_ERROR
. If
there’s no content to read, it will still return None
, but error
won’t be set.
length
a gsize
to get the length of the data read in.
fn read_line_utf8_async<P: IsA<Cancellable>, Q: FnOnce(Result<Option<GString>, Error>) + Send + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn read_line_utf8_async_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Option<GString>, Error>> + 'static>>
Reads a string from the data input stream, up to the first occurrence of any of the stop characters.
Note that, in contrast to read_until_async()
,
this function consumes the stop character that it finds.
Don’t use this function in new code. Its functionality is
inconsistent with read_until_async()
. Both
functions will be marked as deprecated in a future release. Use
read_upto()
instead, but note that that function
does not consume the stop character.
Deprecated since 2.56
Use read_upto()
instead, which has more
consistent behaviour regarding the stop character.
stop_chars
characters to terminate the read.
cancellable
optional Cancellable
object, None
to ignore.
Returns
a string with the data that was read
before encountering any of the stop characters. Set length
to
a gsize
to get the length of the string. This function will
return None
on an error.
length
a gsize
to get the length of the data read in.
The asynchronous version of read_until()
.
It is an error to have two outstanding calls to this function.
Note that, in contrast to read_until()
,
this function does not consume the stop character that it finds. You
must read it for yourself.
When the operation is finished, callback
will be called. You
can then call g_data_input_stream_read_until_finish()
to get
the result of the operation.
Don’t use this function in new code. Its functionality is
inconsistent with read_until()
. Both functions
will be marked as deprecated in a future release. Use
read_upto_async()
instead.
Deprecated since 2.56
Use read_upto_async()
instead, which
has more consistent behaviour regarding the stop character.
stop_chars
characters to terminate the read.
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
object, None
to ignore.
callback
callback to call when the request is satisfied.
fn read_until_async_future(
&self,
stop_chars: &[u8],
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>
Reads a string from the data input stream, up to the first occurrence of any of the stop characters.
In contrast to read_until()
, this function
does not consume the stop character. You have to use
DataInputStreamExt::read_byte()
to get it before calling
read_upto()
again.
Note that stop_chars
may contain ‘\0’ if stop_chars_len
is
specified.
The returned string will always be nul-terminated on success.
stop_chars
characters to terminate the read
stop_chars_len
length of stop_chars
. May be -1 if stop_chars
is
nul-terminated
cancellable
optional Cancellable
object, None
to ignore
Returns
a string with the data that was read
before encountering any of the stop characters. Set length
to
a gsize
to get the length of the string. This function will
return None
on an error
length
a gsize
to get the length of the data read in
The asynchronous version of read_upto()
.
It is an error to have two outstanding calls to this function.
In contrast to read_until()
, this function
does not consume the stop character. You have to use
DataInputStreamExt::read_byte()
to get it before calling
read_upto()
again.
Note that stop_chars
may contain ‘\0’ if stop_chars_len
is
specified.
When the operation is finished, callback
will be called. You
can then call g_data_input_stream_read_upto_finish()
to get
the result of the operation.
stop_chars
characters to terminate the read
stop_chars_len
length of stop_chars
. May be -1 if stop_chars
is
nul-terminated
io_priority
the [I/O priority][io-priority] of the request
cancellable
optional Cancellable
object, None
to ignore
callback
callback to call when the request is satisfied