Trait gio::prelude::DataInputStreamExtManual
source · pub trait DataInputStreamExtManual: 'static {
// Required methods
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>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
);
fn read_line_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>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
);
fn read_line_utf8_future(
&self,
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Option<GString>, 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>) + 'static>(
&self,
stop_chars: &[u8],
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
);
fn read_upto_future(
&self,
stop_chars: &[u8],
io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>;
}Required Methods§
sourcefn read_line<P: IsA<Cancellable>>(
&self,
cancellable: Option<&P>
) -> Result<Vec<u8>, Error>
fn read_line<P: IsA<Cancellable>>( &self, cancellable: Option<&P> ) -> Result<Vec<u8>, Error>
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.
sourcefn read_line_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn read_line_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&P>, callback: Q )
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_future( &self, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<Vec<u8>, Error>> + 'static>>
sourcefn 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>) + 'static>( &self, io_priority: Priority, cancellable: Option<&P>, callback: Q )
fn read_line_utf8_future( &self, io_priority: Priority ) -> Pin<Box_<dyn Future<Output = Result<Option<GString>, Error>> + 'static>>
sourcefn read_upto<P: IsA<Cancellable>>(
&self,
stop_chars: &[u8],
cancellable: Option<&P>
) -> Result<Vec<u8>, Error>
fn read_upto<P: IsA<Cancellable>>( &self, stop_chars: &[u8], cancellable: Option<&P> ) -> Result<Vec<u8>, Error>
Reads a string from the data input stream, up to the first occurrence of any of the stop characters.
In contrast to g_data_input_stream_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
sourcefn read_upto_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + 'static>(
&self,
stop_chars: &[u8],
io_priority: Priority,
cancellable: Option<&P>,
callback: Q
)
fn read_upto_async<P: IsA<Cancellable>, Q: FnOnce(Result<Vec<u8>, Error>) + 'static>( &self, stop_chars: &[u8], io_priority: Priority, cancellable: Option<&P>, callback: Q )
The asynchronous version of read_upto().
It is an error to have two outstanding calls to this function.
In contrast to g_data_input_stream_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