Trait gio::prelude::SeekableExt

source ·
pub trait SeekableExt: IsA<Seekable> + Sealed + 'static {
    // Provided methods
    fn can_seek(&self) -> bool { ... }
    fn can_truncate(&self) -> bool { ... }
    fn seek(
        &self,
        offset: i64,
        type_: SeekType,
        cancellable: Option<&impl IsA<Cancellable>>,
    ) -> Result<(), Error> { ... }
    fn tell(&self) -> i64 { ... }
    fn truncate(
        &self,
        offset: i64,
        cancellable: Option<&impl IsA<Cancellable>>,
    ) -> Result<(), Error> { ... }
}
Expand description

Provided Methods§

source

fn can_seek(&self) -> bool

Tests if the stream supports the #GSeekableIface.

§Returns

true if @self can be seeked. false otherwise.

source

fn can_truncate(&self) -> bool

Tests if the length of the stream can be adjusted with g_seekable_truncate().

§Returns

true if the stream can be truncated, false otherwise.

source

fn seek( &self, offset: i64, type_: SeekType, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Seeks in the stream by the given @offset, modified by @type_.

Attempting to seek past the end of the stream will have different results depending on if the stream is fixed-sized or resizable. If the stream is resizable then seeking past the end and then writing will result in zeros filling the empty space. Seeking past the end of a resizable stream and reading will result in EOF. Seeking past the end of a fixed-sized stream will fail.

Any operation that would result in a negative offset will fail.

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.

§offset

a #goffset.

§type_

a #GSeekType.

§cancellable

optional #GCancellable object, None to ignore.

§Returns

true if successful. If an error has occurred, this function will return false and set @error appropriately if present.

source

fn tell(&self) -> i64

Tells the current position within the stream.

§Returns

the (positive or zero) offset from the beginning of the buffer, zero if the target is not seekable.

source

fn truncate( &self, offset: i64, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Sets the length of the stream to @offset. If the stream was previously larger than @offset, the extra data is discarded. If the stream was previously shorter than @offset, it is extended with NUL (‘\0’) bytes.

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.

§offset

new length for @self, in bytes.

§cancellable

optional #GCancellable object, None to ignore.

§Returns

true if successful. If an error has occurred, this function will return false and set @error appropriately if present.

Object Safety§

This trait is not object safe.

Implementors§