chore: added explicit target to names, consistency

This commit is contained in:
əlemi 2024-10-15 19:31:21 +02:00
parent cda0584b0e
commit a9d17bf630
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 9 additions and 9 deletions

View file

@ -153,7 +153,7 @@ impl Client {
} }
/// Join and return a [`Workspace`]. /// Join and return a [`Workspace`].
pub async fn join_workspace(&self, workspace: impl AsRef<str>) -> ConnectionResult<Workspace> { pub async fn attach_workspace(&self, workspace: impl AsRef<str>) -> ConnectionResult<Workspace> {
let token = self let token = self
.0 .0
.session .session
@ -203,7 +203,7 @@ impl Client {
} }
/// Get the currently logged in user. /// Get the currently logged in user.
pub fn user(&self) -> &User { pub fn my_user(&self) -> &User {
&self.0.user &self.0.user
} }
} }

View file

@ -140,7 +140,7 @@ impl Workspace {
} }
/// Create a new buffer in the current workspace. /// Create a new buffer in the current workspace.
pub async fn create(&self, path: &str) -> RemoteResult<()> { pub async fn create_buffer(&self, path: &str) -> RemoteResult<()> {
let mut workspace_client = self.0.services.ws(); let mut workspace_client = self.0.services.ws();
workspace_client workspace_client
.create_buffer(tonic::Request::new(BufferNode { .create_buffer(tonic::Request::new(BufferNode {
@ -158,7 +158,7 @@ impl Workspace {
} }
/// Attach to a buffer and return a handle to it. /// Attach to a buffer and return a handle to it.
pub async fn attach(&self, path: &str) -> ConnectionResult<buffer::Controller> { pub async fn attach_buffer(&self, path: &str) -> ConnectionResult<buffer::Controller> {
let mut worskspace_client = self.0.services.ws(); let mut worskspace_client = self.0.services.ws();
let request = tonic::Request::new(BufferNode { let request = tonic::Request::new(BufferNode {
path: path.to_string(), path: path.to_string(),
@ -190,7 +190,7 @@ impl Workspace {
/// If this method returns `false` you have a dangling ref, maybe just waiting for garbage /// If this method returns `false` you have a dangling ref, maybe just waiting for garbage
/// collection or maybe preventing the controller from being dropped completely /// collection or maybe preventing the controller from being dropped completely
#[allow(clippy::redundant_pattern_matching)] // all cases are clearer this way #[allow(clippy::redundant_pattern_matching)] // all cases are clearer this way
pub fn detach(&self, path: &str) -> bool { pub fn detach_buffer(&self, path: &str) -> bool {
match self.0.buffers.remove(path) { match self.0.buffers.remove(path) {
None => true, // noop: we werent attached in the first place None => true, // noop: we werent attached in the first place
Some((_name, controller)) => match Arc::into_inner(controller.0) { Some((_name, controller)) => match Arc::into_inner(controller.0) {
@ -256,8 +256,8 @@ impl Workspace {
} }
/// Delete a buffer. /// Delete a buffer.
pub async fn delete(&self, path: &str) -> RemoteResult<()> { pub async fn delete_buffer(&self, path: &str) -> RemoteResult<()> {
self.detach(path); // just in case self.detach_buffer(path); // just in case
let mut workspace_client = self.0.services.ws(); let mut workspace_client = self.0.services.ws();
workspace_client workspace_client
@ -285,13 +285,13 @@ impl Workspace {
/// Return a handle to the [buffer::Controller] with the given path, if present. /// Return a handle to the [buffer::Controller] with the given path, if present.
// #[cfg_attr(feature = "js", napi)] // https://github.com/napi-rs/napi-rs/issues/1120 // #[cfg_attr(feature = "js", napi)] // https://github.com/napi-rs/napi-rs/issues/1120
pub fn buffer_by_name(&self, path: &str) -> Option<buffer::Controller> { pub fn get_buffer(&self, path: &str) -> Option<buffer::Controller> {
self.0.buffers.get(path).map(|x| x.clone()) self.0.buffers.get(path).map(|x| x.clone())
} }
/// Get a list of all the currently attached buffers. /// Get a list of all the currently attached buffers.
// #[cfg_attr(feature = "js", napi)] // https://github.com/napi-rs/napi-rs/issues/1120 // #[cfg_attr(feature = "js", napi)] // https://github.com/napi-rs/napi-rs/issues/1120
pub fn buffer_list(&self) -> Vec<String> { pub fn active_buffers(&self) -> Vec<String> {
self.0 self.0
.buffers .buffers
.iter() .iter()