tokio-fs: How can I get file position like Python's file.tell()? #2556
Answered
by
Darksonn
ariesdevil
asked this question in
General
-
How can I get a file position like Python's file.tell()? Does the |
Beta Was this translation helpful? Give feedback.
Answered by
Darksonn
May 22, 2020
Replies: 1 comment 3 replies
-
The use tokio::io::AsyncSeekExt;
use std::io::SeekFrom;
let pos = file.seek(SeekFrom::Current(0)).await?;
println!("Current position in file is {}.", pos); |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ariesdevil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
seek
method returns the position after seeking, so you can seek by zero like this: