Skip to content

tokio-fs: How can I get file position like Python's file.tell()? #2556

Answered by Darksonn
ariesdevil asked this question in General
Discussion options

You must be logged in to vote

The seek method returns the position after seeking, so you can seek by zero like this:

use tokio::io::AsyncSeekExt;
use std::io::SeekFrom;

let pos = file.seek(SeekFrom::Current(0)).await?;
println!("Current position in file is {}.", pos);

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ariesdevil
Comment options

@Darksonn
Comment options

@ariesdevil
Comment options

Answer selected by ariesdevil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants