From 788a8b7091bbdde77817030e0836d7a7a786fd99 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:47:55 -0400 Subject: [Rust] Simplify usage surrounding c strings `cstring.as_ref().as_ptr() as *const c_char` -> `cstring.as_ptr()` `cstring.as_ref().as_ptr() as *mut _` -> `cstring.as_ptr()` `cstring.as_ptr() as *const c_char` -> `cstring.as_ptr()` With a few fixes for cstrings that might be dropped prematurely. --- rust/src/collaboration/sync.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'rust/src/collaboration/sync.rs') diff --git a/rust/src/collaboration/sync.rs b/rust/src/collaboration/sync.rs index 4c112336..5afb8923 100644 --- a/rust/src/collaboration/sync.rs +++ b/rust/src/collaboration/sync.rs @@ -63,7 +63,7 @@ pub fn download_file_with_progress( let result = unsafe { BNCollaborationDownloadFile( file.handle.as_ptr(), - db_path.as_ref().as_ptr() as *const c_char, + db_path.as_ptr(), Some(F::cb_progress_callback), &mut progress as *mut F as *mut c_void, ) @@ -239,7 +239,7 @@ where let success = unsafe { BNCollaborationDownloadDatabaseForFile( file.handle.as_ptr(), - db_path.as_ref().as_ptr() as *const c_char, + db_path.as_ptr(), force, Some(F::cb_progress_callback), &mut progress as *mut _ as *mut c_void, @@ -485,7 +485,7 @@ pub fn set_snapshot_author( BNCollaborationSetSnapshotAuthor( database.handle.as_ptr(), snapshot.handle.as_ptr(), - author.as_ref().as_ptr() as *const c_char, + author.as_ptr(), ) }; success.then_some(()).ok_or(()) @@ -658,7 +658,7 @@ pub fn get_remote_snapshot_from_local_type_archive( let value = unsafe { BNCollaborationGetRemoteSnapshotFromLocalTypeArchive( type_archive.handle.as_ptr(), - snapshot_id.as_ref().as_ptr() as *const c_char, + snapshot_id.as_ptr(), ) }; NonNull::new(value).map(|handle| unsafe { RemoteSnapshot::ref_from_raw(handle) }) @@ -687,7 +687,7 @@ pub fn is_type_archive_snapshot_ignored( unsafe { BNCollaborationIsTypeArchiveSnapshotIgnored( type_archive.handle.as_ptr(), - snapshot_id.as_ref().as_ptr() as *const c_char, + snapshot_id.as_ptr(), ) } } @@ -713,7 +713,7 @@ pub fn download_type_archive_with_progress( let success = unsafe { BNCollaborationDownloadTypeArchive( file.handle.as_ptr(), - db_path.as_ref().as_ptr() as *const c_char, + db_path.as_ptr(), Some(F::cb_progress_callback), &mut progress as *mut F as *mut c_void, &mut value, -- cgit v1.3.1