pub trait SeekableExt: 'static {
    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

Required Methods

Tests if the stream supports the GSeekableIface.

Returns

true if self can be seeked. false otherwise.

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

Returns

true if the stream can be truncated, false otherwise.

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 glib::SeekType.

cancellable

optional Cancellable object, None to ignore.

Returns

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

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.

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 Cancellable object, None to ignore.

Returns

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

Implementors