Seek
interface Seek
Seek to an offset, in bytes, in a stream.
Seek to an offset, in bytes, in a stream.
Seek to an offset, in bytes, in a stream.
A seek beyond the end of a stream is allowed, but behavior is defined by the implementation.
If the seek operation completed successfully, this method returns the new position from the start of the stream. That position can be used later with SeekFrom::Start
.
[src]
fn rewind(self) throws IoError {
try self.seek(0, SeekFrom.Start);
}
Rewind to the beginning of a stream.
[src]
fn rewind(self) throws IoError {
try self.seek(0, SeekFrom.Start);
}
Rewind to the beginning of a stream.
Rewind to the beginning of a stream.
stream_len
pub fn stream_len(self): int throws IoError
[src]
fn stream_len(self): int throws IoError {
let old_pos = try self.stream_position();
let len = try self.seek(0, SeekFrom.End);
if (old_pos != len) {
try self.seek(old_pos, SeekFrom.Start);
}
return len;
}
Returns the length of this stream (in bytes).
stream_len
pub fn stream_len(self): int throws IoError
[src]
fn stream_len(self): int throws IoError {
let old_pos = try self.stream_position();
let len = try self.seek(0, SeekFrom.End);
if (old_pos != len) {
try self.seek(old_pos, SeekFrom.Start);
}
return len;
}
Returns the length of this stream (in bytes).
Returns the length of this stream (in bytes).
stream_position
pub fn stream_position(self): int throws IoError
[src]
fn stream_position(self): int throws IoError {
return try self.seek(0, SeekFrom.Current);
}
Returns the current seek position from the start of the stream.
stream_position
pub fn stream_position(self): int throws IoError
[src]
fn stream_position(self): int throws IoError {
return try self.seek(0, SeekFrom.Current);
}
Returns the current seek position from the start of the stream.
Returns the current seek position from the start of the stream.
seek_relative
pub fn seek_relative(self, offset: int) throws IoError
[src]
fn seek_relative(self, offset: int) throws IoError {
try self.seek(offset, SeekFrom.Current);
}
Seeks relative to the current position.
seek_relative
pub fn seek_relative(self, offset: int) throws IoError
[src]
fn seek_relative(self, offset: int) throws IoError {
try self.seek(offset, SeekFrom.Current);
}
Seeks relative to the current position.
Seeks relative to the current position.
This is equivalent to self.seek(offset, SeekFrom.Current)
but doesn't return the new position.