From 54f03c70388f6d8a58f1434ee0ac5d96839c9709 Mon Sep 17 00:00:00 2001 From: li_junsong Date: Mon, 14 Aug 2023 19:54:52 +0800 Subject: [PATCH] =?UTF-8?q?C=E4=BE=A7=E5=91=BD=E5=90=8D=E9=A3=8E=E6=A0=BC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li_junsong --- interfaces/kits/rust/include/rust_file.h | 24 ++++++++++++------------ interfaces/kits/rust/src/ffi.rs | 14 +++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/interfaces/kits/rust/include/rust_file.h b/interfaces/kits/rust/include/rust_file.h index cf2ba4c52..2bb614ada 100644 --- a/interfaces/kits/rust/include/rust_file.h +++ b/interfaces/kits/rust/include/rust_file.h @@ -38,9 +38,9 @@ typedef void StringVector; * @param End Sets the offset from th tail of the file. */ enum SeekPos { - Start, - Current, - End + START, + CURRENT, + END }; /** @@ -50,8 +50,8 @@ enum SeekPos { * @param Multiple Creates a multi-level directory. */ enum MakeDirectionMode { - Single, - Multiple + SINGLE, + MULTIPLE }; /** @@ -76,7 +76,7 @@ typedef struct { * 3.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -StringVector* readLines(char* path); +StringVector* ReadLines(char* path); /** * @ingroup rust @@ -90,7 +90,7 @@ StringVector* readLines(char* path); * 2.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -Str* nextLine(StringVector* lines); +Str* NextLine(StringVector* lines); /** * @ingroup rust @@ -98,7 +98,7 @@ Str* nextLine(StringVector* lines); * @param lines pointer to `StringVector`. * @li rust_file.h:The file where the interface is located. */ -void stringVectorFree(StringVector* lines); +void StringVectorFree(StringVector* lines); /** * @ingroup rust @@ -111,7 +111,7 @@ void stringVectorFree(StringVector* lines); * 2.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -void lseek(int fd, long long offset, enum SeekPos pos); +void Lseek(int fd, long long offset, enum SeekPos pos); /** * @ingroup rust @@ -123,7 +123,7 @@ void lseek(int fd, long long offset, enum SeekPos pos); * 2.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -void mkdirs(char* path, enum MakeDirectionMode mode); +void Mkdirs(char* path, enum MakeDirectionMode mode); /** * @ingroup rust @@ -135,7 +135,7 @@ void mkdirs(char* path, enum MakeDirectionMode mode); * 1.Errors are stored in errno. * @li rust_file.h:The file where the interface is located. */ -Str* getParent(int fd); +Str* GetParent(int fd); /** * @ingroup rust @@ -143,7 +143,7 @@ Str* getParent(int fd); * @param lines pointer to `Str`. * @li rust_file.h:The file where the interface is located. */ -void parentFree(Str* str); +void ParentFree(Str* str); #ifdef __cplusplus #if __cplusplus diff --git a/interfaces/kits/rust/src/ffi.rs b/interfaces/kits/rust/src/ffi.rs index e151408af..47a6c7e6b 100644 --- a/interfaces/kits/rust/src/ffi.rs +++ b/interfaces/kits/rust/src/ffi.rs @@ -22,7 +22,7 @@ use std::ffi::CString; use std::ptr::null_mut; #[no_mangle] -pub unsafe extern "C" fn readLines(path: *const c_char) -> *mut StringVector { +pub unsafe extern "C" fn ReadLines(path: *const c_char) -> *mut StringVector { match read_lines(path) { Ok(sv) => sv, Err(e) => { @@ -33,7 +33,7 @@ pub unsafe extern "C" fn readLines(path: *const c_char) -> *mut StringVector { } #[no_mangle] -pub unsafe extern "C" fn nextLine(lines: *mut StringVector) -> *mut Str { +pub unsafe extern "C" fn NextLine(lines: *mut StringVector) -> *mut Str { match next_line(lines) { Ok(s) => s, Err(e) => { @@ -44,14 +44,14 @@ pub unsafe extern "C" fn nextLine(lines: *mut StringVector) -> *mut Str { } #[no_mangle] -pub unsafe extern "C" fn stringVectorFree(lines: *mut StringVector) { +pub unsafe extern "C" fn StringVectorFree(lines: *mut StringVector) { if !lines.is_null() { let _ = Box::from_raw(lines); } } #[no_mangle] -pub extern "C" fn lseek(fd: i32, offset: i64, pos: SeekPos) { +pub extern "C" fn Lseek(fd: i32, offset: i64, pos: SeekPos) { match seek(fd, offset, pos) { Ok(_) => {} Err(e) => unsafe { @@ -61,7 +61,7 @@ pub extern "C" fn lseek(fd: i32, offset: i64, pos: SeekPos) { } #[no_mangle] -pub extern "C" fn mkdirs(path: *const c_char, mode: MakeDirectionMode) { +pub extern "C" fn Mkdirs(path: *const c_char, mode: MakeDirectionMode) { match create_dir(path, mode) { Ok(_) => {} Err(e) => unsafe { error_control(e) }, @@ -69,7 +69,7 @@ pub extern "C" fn mkdirs(path: *const c_char, mode: MakeDirectionMode) { } #[no_mangle] -pub extern "C" fn getParent(fd: i32) -> *mut Str { +pub extern "C" fn GetParent(fd: i32) -> *mut Str { match get_parent(fd) { Ok(str) => str, Err(e) => { @@ -82,7 +82,7 @@ pub extern "C" fn getParent(fd: i32) -> *mut Str { } #[no_mangle] -pub unsafe extern "C" fn parentFree(str: *mut Str) { +pub unsafe extern "C" fn ParentFree(str: *mut Str) { if !str.is_null() { let string = Box::from_raw(str); let _ = CString::from_raw(string.str as *mut c_char); -- Gitee