diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-07 19:22:21 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 2f214f6c9935e8ce8df4732cde44a540a003258c (patch) | |
| tree | 6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /rust/tests/collaboration.rs | |
| parent | b4cf0be8816182c9efca037e27e9439482f8bf36 (diff) | |
[Rust] Reduce usage of `IntoCStr` in function signatures
This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids.
Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type.
This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type.
Special consideration must be made for symbols or other possible non utf-8 objects.
This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8.
Diffstat (limited to 'rust/tests/collaboration.rs')
| -rw-r--r-- | rust/tests/collaboration.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/rust/tests/collaboration.rs b/rust/tests/collaboration.rs index 210492e4..3526a6f8 100644 --- a/rust/tests/collaboration.rs +++ b/rust/tests/collaboration.rs @@ -109,7 +109,7 @@ fn test_project_creation() { .expect("Failed to delete file"); assert!( !project - .get_file_by_id(created_file_id) + .get_file_by_id(&created_file_id) .is_ok_and(|f| f.is_some()), "File was not deleted" ); @@ -136,7 +136,7 @@ fn test_project_creation() { let created_folder_file_id = created_folder_file.id(); // Verify the file exists in the folder. let check_folder_file = project - .get_file_by_id(created_folder_file_id) + .get_file_by_id(&created_folder_file_id) .expect("Failed to get folder file by id") .unwrap(); assert_eq!(check_folder_file.name().as_str(), "test_folder_file"); @@ -155,7 +155,7 @@ fn test_project_creation() { .expect("Failed to delete folder"); assert!( !project - .get_folder_by_id(created_folder_id) + .get_folder_by_id(&created_folder_id) .is_ok_and(|f| f.is_some()), "Folder was not deleted" ); @@ -190,7 +190,7 @@ fn test_project_sync() { SymbolBuilder::new(SymbolType::Function, "test", entry_function.start()).create(); view.define_user_symbol(&new_entry_func_symbol); // Verify that we modified the binary - assert_eq!(entry_function.symbol().raw_name().as_str(), "test"); + assert_eq!(entry_function.symbol().raw_name(), "test".into()); // Make new snapshot. assert!(view.file().save_auto_snapshot()); // We should have two snapshots. @@ -210,20 +210,20 @@ fn test_project_sync() { drop(view); // Verify that the remote file exists. project - .get_file_by_id(remote_file.id()) + .get_file_by_id(&remote_file.id()) .expect("Failed to get remote file by id"); // Download the remote database with our changes. let downloaded_file = remote_file - .download_database(out_dir.join("downloaded_atox.obj.bndb")) + .download_database(&out_dir.join("downloaded_atox.obj.bndb")) .expect("Failed to download database"); let downloaded_view = downloaded_file - .view_of_type(view_type) + .view_of_type(&view_type) .expect("Failed to open downloaded view"); // Verify the changes in the entry function. let entry_function = downloaded_view .entry_point_function() .expect("Failed to get entry point function"); - assert_eq!(entry_function.symbol().raw_name().as_str(), "test"); + assert_eq!(entry_function.symbol().raw_name(), "test".into()); project .delete_file(&remote_file) .expect("Failed to delete file"); |
