[][src]Trait gio::DataInputStreamExt

pub trait DataInputStreamExt: 'static {
    fn get_byte_order(&self) -> DataStreamByteOrder;
fn get_newline_type(&self) -> DataStreamNewlineType;
fn read_byte<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<u8, Error>;
fn read_int16<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<i16, Error>;
fn read_int32<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<i32, Error>;
fn read_int64<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<i64, Error>;
fn read_line_utf8<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<(Option<GString>, usize), Error>;
fn read_uint16<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<u16, Error>;
fn read_uint32<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<u32, Error>;
fn read_uint64<P: IsA<Cancellable>>(
        &self,
        cancellable: Option<&P>
    ) -> Result<u64, Error>;
fn read_until<P: IsA<Cancellable>>(
        &self,
        stop_chars: &str,
        cancellable: Option<&P>
    ) -> Result<(GString, usize), Error>;
fn read_until_async<P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static>(
        &self,
        stop_chars: &str,
        io_priority: Priority,
        cancellable: Option<&P>,
        callback: Q
    );
fn read_until_async_future(
        &self,
        stop_chars: &str,
        io_priority: Priority
    ) -> Pin<Box_<dyn Future<Output = Result<(GString, usize), Error>> + 'static>>;
fn read_upto<P: IsA<Cancellable>>(
        &self,
        stop_chars: &str,
        cancellable: Option<&P>
    ) -> Result<(GString, usize), Error>;
fn read_upto_async<P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static>(
        &self,
        stop_chars: &str,
        io_priority: Priority,
        cancellable: Option<&P>,
        callback: Q
    );
fn read_upto_async_future(
        &self,
        stop_chars: &str,
        io_priority: Priority
    ) -> Pin<Box_<dyn Future<Output = Result<(GString, usize), Error>> + 'static>>;
fn set_byte_order(&self, order: DataStreamByteOrder);
fn set_newline_type(&self, type_: DataStreamNewlineType);
fn connect_property_byte_order_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_newline_type_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all DataInputStream methods.

Implementors

DataInputStream

Required methods

fn get_byte_order(&self) -> DataStreamByteOrder

Gets the byte order for the data input stream.

Returns

the self's current DataStreamByteOrder.

fn get_newline_type(&self) -> DataStreamNewlineType

Gets the current newline type for the self.

Returns

DataStreamNewlineType for the given self.

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

Reads an unsigned 8-bit/1-byte value from self.

cancellable

optional Cancellable object, None to ignore.

Returns

an unsigned 8-bit/1-byte value read from the self or 0 if an error occurred.

fn read_int16<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<i16, Error>

Reads a 16-bit/2-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order and DataInputStreamExt::set_byte_order.

cancellable

optional Cancellable object, None to ignore.

Returns

a signed 16-bit/2-byte value read from self or 0 if an error occurred.

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

Reads a signed 32-bit/4-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order and DataInputStreamExt::set_byte_order.

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 signed 32-bit/4-byte value read from the self or 0 if an error occurred.

fn read_int64<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<i64, Error>

Reads a 64-bit/8-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order and DataInputStreamExt::set_byte_order.

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 signed 64-bit/8-byte value read from self or 0 if an error occurred.

fn read_line_utf8<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<(Option<GString>, usize), 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.

length

a gsize to get the length of the data read in.

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.

fn read_uint16<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<u16, Error>

Reads an unsigned 16-bit/2-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order and DataInputStreamExt::set_byte_order.

cancellable

optional Cancellable object, None to ignore.

Returns

an unsigned 16-bit/2-byte value read from the self or 0 if an error occurred.

fn read_uint32<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<u32, Error>

Reads an unsigned 32-bit/4-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order and DataInputStreamExt::set_byte_order.

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

an unsigned 32-bit/4-byte value read from the self or 0 if an error occurred.

fn read_uint64<P: IsA<Cancellable>>(
    &self,
    cancellable: Option<&P>
) -> Result<u64, Error>

Reads an unsigned 64-bit/8-byte value from self.

In order to get the correct byte order for this read operation, see DataInputStreamExt::get_byte_order.

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

an unsigned 64-bit/8-byte read from self or 0 if an error occurred.

fn read_until<P: IsA<Cancellable>>(
    &self,
    stop_chars: &str,
    cancellable: Option<&P>
) -> Result<(GString, usize), Error>

Reads a string from the data input stream, up to the first occurrence of any of the stop characters.

Note that, in contrast to DataInputStreamExt::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 DataInputStreamExt::read_until_async. Both functions will be marked as deprecated in a future release. Use DataInputStreamExt::read_upto instead, but note that that function does not consume the stop character.

Deprecated since 2.56

Use DataInputStreamExt::read_upto instead, which has more consistent behaviour regarding the stop character.

stop_chars

characters to terminate the read.

length

a gsize to get the length of the data read in.

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.

fn read_until_async<P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static>(
    &self,
    stop_chars: &str,
    io_priority: Priority,
    cancellable: Option<&P>,
    callback: Q
)

The asynchronous version of DataInputStreamExt::read_until. It is an error to have two outstanding calls to this function.

Note that, in contrast to DataInputStreamExt::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 DataInputStreamExt::read_until_finish to get the result of the operation.

Don't use this function in new code. Its functionality is inconsistent with DataInputStreamExt::read_until. Both functions will be marked as deprecated in a future release. Use DataInputStreamExt::read_upto_async instead.

Deprecated since 2.56

Use DataInputStreamExt::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.

user_data

the data to pass to callback function.

fn read_until_async_future(
    &self,
    stop_chars: &str,
    io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(GString, usize), Error>> + 'static>>

fn read_upto<P: IsA<Cancellable>>(
    &self,
    stop_chars: &str,
    cancellable: Option<&P>
) -> Result<(GString, usize), Error>

Reads a string from the data input stream, up to the first occurrence of any of the stop characters.

In contrast to DataInputStreamExt::read_until, this function does not consume the stop character. You have to use DataInputStreamExt::read_byte to get it before calling DataInputStreamExt::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

length

a gsize to get the length of the data read in

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

fn read_upto_async<P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static>(
    &self,
    stop_chars: &str,
    io_priority: Priority,
    cancellable: Option<&P>,
    callback: Q
)

The asynchronous version of DataInputStreamExt::read_upto. It is an error to have two outstanding calls to this function.

In contrast to DataInputStreamExt::read_until, this function does not consume the stop character. You have to use DataInputStreamExt::read_byte to get it before calling DataInputStreamExt::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 DataInputStreamExt::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

user_data

the data to pass to callback function

fn read_upto_async_future(
    &self,
    stop_chars: &str,
    io_priority: Priority
) -> Pin<Box_<dyn Future<Output = Result<(GString, usize), Error>> + 'static>>

fn set_byte_order(&self, order: DataStreamByteOrder)

This function sets the byte order for the given self. All subsequent reads from the self will be read in the given order.

order

a DataStreamByteOrder to set.

fn set_newline_type(&self, type_: DataStreamNewlineType)

Sets the newline type for the self.

Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read chunk ends in "CR" we must read an additional byte to know if this is "CR" or "CR LF", and this might block if there is no more data available.

type_

the type of new line return as DataStreamNewlineType.

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

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

Loading content...

Implementors

impl<O: IsA<DataInputStream>> DataInputStreamExt for O[src]

Loading content...