From 9dadf92c16da5cd21def79ae39ca98803c9208ec Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 5 May 2025 13:17:30 -0400 Subject: [Rust] Rename `AsCStr` to `IntoCStr` --- rust/src/collaboration/remote.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'rust/src/collaboration/remote.rs') diff --git a/rust/src/collaboration/remote.rs b/rust/src/collaboration/remote.rs index 4d69873a..baeba412 100644 --- a/rust/src/collaboration/remote.rs +++ b/rust/src/collaboration/remote.rs @@ -10,7 +10,7 @@ use crate::enterprise; use crate::progress::{NoProgressCallback, ProgressCallback}; use crate::project::Project; use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; -use crate::string::{AsCStr, BnString}; +use crate::string::{BnString, IntoCStr}; #[repr(transparent)] pub struct Remote { @@ -27,7 +27,7 @@ impl Remote { } /// Create a Remote and add it to the list of known remotes (saved to Settings) - pub fn new(name: N, address: A) -> Ref { + pub fn new(name: N, address: A) -> Ref { let name = name.to_cstr(); let address = address.to_cstr(); let result = unsafe { BNCollaborationCreateRemote(name.as_ptr(), address.as_ptr()) }; @@ -163,7 +163,7 @@ impl Remote { } /// Requests an authentication token using a username and password. - pub fn request_authentication_token( + pub fn request_authentication_token( &self, username: U, password: P, @@ -275,7 +275,7 @@ impl Remote { /// Gets a specific project in the Remote by its id. /// /// NOTE: If projects have not been pulled, they will be pulled upon calling this. - pub fn get_project_by_id(&self, id: S) -> Result>, ()> { + pub fn get_project_by_id(&self, id: S) -> Result>, ()> { if !self.has_pulled_projects() { self.pull_projects()?; } @@ -288,7 +288,7 @@ impl Remote { /// Gets a specific project in the Remote by its name. /// /// NOTE: If projects have not been pulled, they will be pulled upon calling this. - pub fn get_project_by_name( + pub fn get_project_by_name( &self, name: S, ) -> Result>, ()> { @@ -331,7 +331,7 @@ impl Remote { /// /// * `name` - Project name /// * `description` - Project description - pub fn create_project( + pub fn create_project( &self, name: N, description: D, @@ -383,8 +383,8 @@ impl Remote { pub fn push_project(&self, project: &RemoteProject, extra_fields: I) -> Result<(), ()> where I: Iterator, - K: AsCStr, - V: AsCStr, + K: IntoCStr, + V: IntoCStr, { let (keys, values): (Vec<_>, Vec<_>) = extra_fields .into_iter() @@ -446,7 +446,7 @@ impl Remote { /// /// If groups have not been pulled, they will be pulled upon calling this. /// This function is only available to accounts with admin status on the Remote. - pub fn get_group_by_name(&self, name: S) -> Result>, ()> { + pub fn get_group_by_name(&self, name: S) -> Result>, ()> { if !self.has_pulled_groups() { self.pull_groups()?; } @@ -462,7 +462,7 @@ impl Remote { /// # Arguments /// /// * `prefix` - Prefix of name for groups - pub fn search_groups( + pub fn search_groups( &self, prefix: S, ) -> Result<(Array, Array), ()> { @@ -526,9 +526,9 @@ impl Remote { /// * `usernames` - List of usernames of users in the group pub fn create_group(&self, name: N, usernames: I) -> Result, ()> where - N: AsCStr, + N: IntoCStr, I: IntoIterator, - I::Item: AsCStr, + I::Item: IntoCStr, { let name = name.to_cstr(); let usernames: Vec<_> = usernames.into_iter().map(|s| s.to_cstr()).collect(); @@ -557,8 +557,8 @@ impl Remote { pub fn push_group(&self, group: &RemoteGroup, extra_fields: I) -> Result<(), ()> where I: IntoIterator, - K: AsCStr, - V: AsCStr, + K: IntoCStr, + V: IntoCStr, { let (keys, values): (Vec<_>, Vec<_>) = extra_fields .into_iter() @@ -617,7 +617,7 @@ impl Remote { /// # Arguments /// /// * `id` - The identifier of the user to retrieve. - pub fn get_user_by_id(&self, id: S) -> Result>, ()> { + pub fn get_user_by_id(&self, id: S) -> Result>, ()> { if !self.has_pulled_users() { self.pull_users()?; } @@ -635,7 +635,7 @@ impl Remote { /// # Arguments /// /// * `username` - The username of the user to retrieve. - pub fn get_user_by_username( + pub fn get_user_by_username( &self, username: S, ) -> Result>, ()> { @@ -665,7 +665,7 @@ impl Remote { /// # Arguments /// /// * `prefix` - The prefix to search for in usernames. - pub fn search_users( + pub fn search_users( &self, prefix: S, ) -> Result<(Array, Array), ()> { @@ -730,7 +730,7 @@ impl Remote { /// # Arguments /// /// * Various details about the new user to be created. - pub fn create_user( + pub fn create_user( &self, username: U, email: E, @@ -772,8 +772,8 @@ impl Remote { pub fn push_user(&self, user: &RemoteUser, extra_fields: I) -> Result<(), ()> where I: Iterator, - K: AsCStr, - V: AsCStr, + K: IntoCStr, + V: IntoCStr, { let (keys, values): (Vec<_>, Vec<_>) = extra_fields .into_iter() -- cgit v1.3.1