From abb446261d153e7321043ea6986a59598125aa7b Mon Sep 17 00:00:00 2001 From: silver-ymz Date: Mon, 4 Sep 2023 23:06:26 +0800 Subject: [PATCH] rename SeekDir to SeekFrom in rust Signed-off-by: silver-ymz --- bindings/cpp/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/cpp/src/lib.rs b/bindings/cpp/src/lib.rs index c3c0d4ba922..c1a94fd4bc9 100644 --- a/bindings/cpp/src/lib.rs +++ b/bindings/cpp/src/lib.rs @@ -27,7 +27,8 @@ mod ffi { value: String, } - enum SeekDir { + #[cxx_name = "SeekDir"] + enum SeekFrom { Start = 0, Current = 1, End = 2, @@ -77,7 +78,7 @@ mod ffi { #[cxx_name = "read"] fn reader_read(self: &mut Reader, buf: &mut [u8]) -> Result; - fn seek(self: &mut Reader, offset: u64, dir: SeekDir) -> Result; + fn seek(self: &mut Reader, offset: u64, dir: SeekFrom) -> Result; } } @@ -149,11 +150,11 @@ impl Reader { Ok(self.0.read(buf)?) } - fn seek(&mut self, offset: u64, dir: ffi::SeekDir) -> Result { + fn seek(&mut self, offset: u64, dir: ffi::SeekFrom) -> Result { 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")), };