Skip to content

Commit

Permalink
rename SeekDir to SeekFrom in rust
Browse files Browse the repository at this point in the history
Signed-off-by: silver-ymz <[email protected]>
  • Loading branch information
silver-ymz committed Sep 4, 2023
1 parent ab31901 commit abb4462
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bindings/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ mod ffi {
value: String,
}

enum SeekDir {
#[cxx_name = "SeekDir"]
enum SeekFrom {
Start = 0,
Current = 1,
End = 2,
Expand Down Expand Up @@ -77,7 +78,7 @@ mod ffi {

#[cxx_name = "read"]
fn reader_read(self: &mut Reader, buf: &mut [u8]) -> Result<usize>;
fn seek(self: &mut Reader, offset: u64, dir: SeekDir) -> Result<u64>;
fn seek(self: &mut Reader, offset: u64, dir: SeekFrom) -> Result<u64>;
}
}

Expand Down Expand Up @@ -149,11 +150,11 @@ impl Reader {
Ok(self.0.read(buf)?)
}

fn seek(&mut self, offset: u64, dir: ffi::SeekDir) -> Result<u64> {
fn seek(&mut self, offset: u64, dir: ffi::SeekFrom) -> Result<u64> {
let pos = match dir {
ffi::SeekDir::Start => std::io::SeekFrom::Start(offset),
ffi::SeekDir::Current => std::io::SeekFrom::Current(offset as i64),
ffi::SeekDir::End => std::io::SeekFrom::End(offset as i64),
ffi::SeekFrom::Start => std::io::SeekFrom::Start(offset),
ffi::SeekFrom::Current => std::io::SeekFrom::Current(offset as i64),
ffi::SeekFrom::End => std::io::SeekFrom::End(offset as i64),
_ => return Err(anyhow::anyhow!("invalid seek dir")),
};

Expand Down

0 comments on commit abb4462

Please sign in to comment.