Trait gio::prelude::SeekableExt
source · pub trait SeekableExt: 'static {
// Required 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
Trait containing all Seekable
methods.
Implementors
BufferedInputStream
, BufferedOutputStream
, DataInputStream
, DataOutputStream
, FileIOStream
, FileInputStream
, FileOutputStream
, MemoryInputStream
, MemoryOutputStream
, Seekable
Required Methods§
sourcefn can_truncate(&self) -> bool
fn can_truncate(&self) -> bool
Tests if the length of the stream can be adjusted with
truncate()
.
Returns
sourcefn seek(
&self,
offset: i64,
type_: SeekType,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
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_
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.
sourcefn tell(&self) -> i64
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.
sourcefn truncate(
&self,
offset: i64,
cancellable: Option<&impl IsA<Cancellable>>
) -> Result<(), Error>
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 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.