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/websocket.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/websocket.rs')
| -rw-r--r-- | rust/tests/websocket.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/rust/tests/websocket.rs b/rust/tests/websocket.rs index c5cf6be4..2c25a810 100644 --- a/rust/tests/websocket.rs +++ b/rust/tests/websocket.rs @@ -1,6 +1,5 @@ use binaryninja::headless::Session; use binaryninja::rc::Ref; -use binaryninja::string::IntoCStr; use binaryninja::websocket::{ register_websocket_provider, CoreWebsocketClient, CoreWebsocketProvider, WebsocketClient, WebsocketClientCallback, WebsocketProvider, @@ -31,11 +30,9 @@ impl WebsocketClient for MyWebsocketClient { Self { core } } - fn connect<I, K, V>(&self, host: &str, _headers: I) -> bool + fn connect<I>(&self, host: &str, _headers: I) -> bool where - I: IntoIterator<Item = (K, V)>, - K: IntoCStr, - V: IntoCStr, + I: IntoIterator<Item = (String, String)>, { assert_eq!(host, "url"); true @@ -89,7 +86,11 @@ fn reg_websocket_provider() { let provider = register_websocket_provider::<MyWebsocketProvider>("RustWebsocketProvider"); let client = provider.create_client().unwrap(); let mut callback = MyClientCallbacks::default(); - let success = client.initialize_connection("url", [("header", "value")], &mut callback); + let success = client.initialize_connection( + "url", + [("header".to_string(), "value".to_string())], + &mut callback, + ); assert!(success, "Failed to initialize connection!"); } @@ -100,7 +101,11 @@ fn listen_websocket_provider() { let client = provider.create_client().unwrap(); let mut callback = MyClientCallbacks::default(); - client.initialize_connection("url", [("header", "value")], &mut callback); + client.initialize_connection( + "url", + [("header".to_string(), "value".to_string())], + &mut callback, + ); assert!(client.write("test1".as_bytes())); assert!(client.write("test2".as_bytes())); |
