summaryrefslogtreecommitdiff
path: root/rust/src/collaboration/group.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-04 19:47:55 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit788a8b7091bbdde77817030e0836d7a7a786fd99 (patch)
tree40e8f8d3c870788259a5acb5d14995cdc1656979 /rust/src/collaboration/group.rs
parenta826c589dfc10c542deba7ca3343a462e02d6bde (diff)
[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.
Diffstat (limited to 'rust/src/collaboration/group.rs')
-rw-r--r--rust/src/collaboration/group.rs20
1 files changed, 3 insertions, 17 deletions
diff --git a/rust/src/collaboration/group.rs b/rust/src/collaboration/group.rs
index 94253519..b8b32c7a 100644
--- a/rust/src/collaboration/group.rs
+++ b/rust/src/collaboration/group.rs
@@ -2,7 +2,6 @@ use super::Remote;
use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable};
use crate::string::{AsCStr, BnString};
use binaryninjacore_sys::*;
-use std::ffi::c_char;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::ptr::NonNull;
@@ -52,12 +51,7 @@ impl RemoteGroup {
/// You will need to push the group to update the Remote.
pub fn set_name<U: AsCStr>(&self, name: U) {
let name = name.to_cstr();
- unsafe {
- BNCollaborationGroupSetName(
- self.handle.as_ptr(),
- name.as_ref().as_ptr() as *const c_char,
- )
- }
+ unsafe { BNCollaborationGroupSetName(self.handle.as_ptr(), name.as_ptr()) }
}
/// Get list of users in the group
@@ -93,10 +87,7 @@ impl RemoteGroup {
I::Item: AsCStr,
{
let usernames: Vec<_> = usernames.into_iter().map(|u| u.to_cstr()).collect();
- let mut usernames_raw: Vec<_> = usernames
- .iter()
- .map(|s| s.as_ref().as_ptr() as *const c_char)
- .collect();
+ let mut usernames_raw: Vec<_> = usernames.iter().map(|s| s.as_ptr()).collect();
// TODO: This should only fail if collaboration is not supported.
// TODO: Because you should not have a RemoteGroup at that point we can ignore?
// TODO: Do you need any permissions to do this?
@@ -113,12 +104,7 @@ impl RemoteGroup {
/// Test if a group has a user with the given username
pub fn contains_user<U: AsCStr>(&self, username: U) -> bool {
let username = username.to_cstr();
- unsafe {
- BNCollaborationGroupContainsUser(
- self.handle.as_ptr(),
- username.as_ref().as_ptr() as *const c_char,
- )
- }
+ unsafe { BNCollaborationGroupContainsUser(self.handle.as_ptr(), username.as_ptr()) }
}
}