mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
docs: fix references
This commit is contained in:
parent
6fe47ff682
commit
59aaf8f3b6
2 changed files with 22 additions and 22 deletions
|
@ -45,13 +45,13 @@ pub mod a_sync {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
/// connect to remote address instantiating a new client [crate::Client::new]
|
/// connect to remote address instantiating a new client [crate::client::Client::new]
|
||||||
pub async fn connect(&self, addr: &str) -> Result<(), Error> {
|
pub async fn connect(&self, addr: &str) -> Result<(), Error> {
|
||||||
*self.client.lock().await = Some(Client::new(addr).await?);
|
*self.client.lock().await = Some(Client::new(addr).await?);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::join]
|
/// threadsafe version of [crate::client::Client::join]
|
||||||
pub async fn join(&self, session: &str) -> Result<Arc<CursorController>, Error> {
|
pub async fn join(&self, session: &str) -> Result<Arc<CursorController>, Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -61,7 +61,7 @@ pub mod a_sync {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::create]
|
/// threadsafe version of [crate::client::Client::create]
|
||||||
pub async fn create(&self, path: &str, content: Option<&str>) -> Result<(), Error> {
|
pub async fn create(&self, path: &str, content: Option<&str>) -> Result<(), Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -71,7 +71,7 @@ pub mod a_sync {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::attach]
|
/// threadsafe version of [crate::client::Client::attach]
|
||||||
pub async fn attach(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
pub async fn attach(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -81,7 +81,7 @@ pub mod a_sync {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::get_cursor]
|
/// threadsafe version of [crate::client::Client::get_cursor]
|
||||||
pub async fn get_cursor(&self) -> Result<Arc<CursorController>, Error> {
|
pub async fn get_cursor(&self) -> Result<Arc<CursorController>, Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -91,7 +91,7 @@ pub mod a_sync {
|
||||||
.ok_or(Error::InvalidState { msg: "join workspace first".into() })
|
.ok_or(Error::InvalidState { msg: "join workspace first".into() })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::get_buffer]
|
/// threadsafe version of [crate::client::Client::get_buffer]
|
||||||
pub async fn get_buffer(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
pub async fn get_buffer(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -101,7 +101,7 @@ pub mod a_sync {
|
||||||
.ok_or(Error::InvalidState { msg: "join workspace first".into() })
|
.ok_or(Error::InvalidState { msg: "join workspace first".into() })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::leave_workspace]
|
/// threadsafe version of [crate::client::Client::leave_workspace]
|
||||||
pub async fn leave_workspace(&self) -> Result<(), Error> {
|
pub async fn leave_workspace(&self) -> Result<(), Error> {
|
||||||
self.client
|
self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -111,7 +111,7 @@ pub mod a_sync {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe version of [crate::Client::disconnect_buffer]
|
/// threadsafe version of [crate::client::Client::disconnect_buffer]
|
||||||
pub async fn disconnect_buffer(&self, path: &str) -> Result<bool, Error> {
|
pub async fn disconnect_buffer(&self, path: &str) -> Result<bool, Error> {
|
||||||
let res = self.client
|
let res = self.client
|
||||||
.lock().await
|
.lock().await
|
||||||
|
@ -168,43 +168,43 @@ pub mod sync {
|
||||||
/// return a reference to contained tokio runtime, to spawn tasks on
|
/// return a reference to contained tokio runtime, to spawn tasks on
|
||||||
pub fn rt(&self) -> &Handle { &self.runtime.handle() }
|
pub fn rt(&self) -> &Handle { &self.runtime.handle() }
|
||||||
|
|
||||||
/// connect and store a client session, threadsafe and sync version of [crate::Client::new]
|
/// connect and store a client session, threadsafe and sync version of [crate::client::Client::new]
|
||||||
pub fn connect(&self, addr: &str) -> Result<(), Error> {
|
pub fn connect(&self, addr: &str) -> Result<(), Error> {
|
||||||
*self.client.lock().expect("client mutex poisoned") = Some(self.rt().block_on(Client::new(addr))?);
|
*self.client.lock().expect("client mutex poisoned") = Some(self.rt().block_on(Client::new(addr))?);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::join]
|
/// threadsafe and sync version of [crate::client::Client::join]
|
||||||
pub fn join(&self, session: &str) -> Result<Arc<CursorController>, Error> {
|
pub fn join(&self, session: &str) -> Result<Arc<CursorController>, Error> {
|
||||||
self.if_client(|c| self.rt().block_on(c.join(session)))?
|
self.if_client(|c| self.rt().block_on(c.join(session)))?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::create]
|
/// threadsafe and sync version of [crate::client::Client::create]
|
||||||
pub fn create(&self, path: &str, content: Option<&str>) -> Result<(), Error> {
|
pub fn create(&self, path: &str, content: Option<&str>) -> Result<(), Error> {
|
||||||
self.if_client(|c| self.rt().block_on(c.create(path, content)))?
|
self.if_client(|c| self.rt().block_on(c.create(path, content)))?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::attach]
|
/// threadsafe and sync version of [crate::client::Client::attach]
|
||||||
pub fn attach(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
pub fn attach(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
||||||
self.if_client(|c| self.rt().block_on(c.attach(path)))?
|
self.if_client(|c| self.rt().block_on(c.attach(path)))?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::get_cursor]
|
/// threadsafe and sync version of [crate::client::Client::get_cursor]
|
||||||
pub fn get_cursor(&self) -> Result<Arc<CursorController>, Error> {
|
pub fn get_cursor(&self) -> Result<Arc<CursorController>, Error> {
|
||||||
self.if_client(|c| c.get_cursor().ok_or(Error::InvalidState { msg: "join workspace first".into() }))?
|
self.if_client(|c| c.get_cursor().ok_or(Error::InvalidState { msg: "join workspace first".into() }))?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::get_buffer]
|
/// threadsafe and sync version of [crate::client::Client::get_buffer]
|
||||||
pub fn get_buffer(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
pub fn get_buffer(&self, path: &str) -> Result<Arc<BufferController>, Error> {
|
||||||
self.if_client(|c| c.get_buffer(path).ok_or(Error::InvalidState { msg: "join workspace or create requested buffer first".into() }))?
|
self.if_client(|c| c.get_buffer(path).ok_or(Error::InvalidState { msg: "join workspace or create requested buffer first".into() }))?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::leave_workspace]
|
/// threadsafe and sync version of [crate::client::Client::leave_workspace]
|
||||||
pub fn leave_workspace(&self) -> Result<(), Error> {
|
pub fn leave_workspace(&self) -> Result<(), Error> {
|
||||||
self.if_client(|c| c.leave_workspace())
|
self.if_client(|c| c.leave_workspace())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// threadsafe and sync version of [crate::Client::disconnect_buffer]
|
/// threadsafe and sync version of [crate::client::Client::disconnect_buffer]
|
||||||
pub fn disconnect_buffer(&self, path: &str) -> Result<bool, Error> {
|
pub fn disconnect_buffer(&self, path: &str) -> Result<bool, Error> {
|
||||||
self.if_client(|c| c.disconnect_buffer(path))
|
self.if_client(|c| c.disconnect_buffer(path))
|
||||||
}
|
}
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -6,13 +6,13 @@
|
||||||
//!
|
//!
|
||||||
//! ## structure
|
//! ## structure
|
||||||
//! The main entrypoint is the [Instance] object, that maintains a connection and can
|
//! The main entrypoint is the [Instance] object, that maintains a connection and can
|
||||||
//! be used to join workspaces or attach to buffers. It contains the underlying [Client] and
|
//! be used to join workspaces or attach to buffers. It contains the underlying [client::Client] and
|
||||||
//! stores active controllers.
|
//! stores active controllers.
|
||||||
//!
|
//!
|
||||||
//! Some actions will return structs implementing the [Controller] trait. These can be polled
|
//! Some actions will return structs implementing the [api::Controller] trait. These can be polled
|
||||||
//! for new stream events ([Controller::poll]/[Controller::recv]), which will be returned in order.
|
//! for new stream events ([api::Controller::poll]/[api::Controller::recv]), which will be returned in order.
|
||||||
//! Blocking and callback variants are also implemented. The [Controller] can also be used to send new
|
//! Blocking and callback variants are also implemented. The [api::Controller] can also be used to send new
|
||||||
//! events to the server ([Controller::send]).
|
//! events to the server ([api::Controller::send]).
|
||||||
//!
|
//!
|
||||||
//! Each operation on a buffer is represented as an [ot::OperationSeq].
|
//! Each operation on a buffer is represented as an [ot::OperationSeq].
|
||||||
//! A visualization about how OperationSeqs work is available
|
//! A visualization about how OperationSeqs work is available
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
//! * `sync` : wraps the [instance::a_sync::Instance] holder into a sync variant: [instance::sync::Instance]
|
//! * `sync` : wraps the [instance::a_sync::Instance] holder into a sync variant: [instance::sync::Instance]
|
||||||
//!
|
//!
|
||||||
//! ## examples
|
//! ## examples
|
||||||
//! while the [Client] itself is the core structure implementing all methods, plugins will mostly
|
//! while the [client::Client] itself is the core structure implementing all methods, plugins will mostly
|
||||||
//! interact with [Instance] managers.
|
//! interact with [Instance] managers.
|
||||||
//!
|
//!
|
||||||
//! ### async
|
//! ### async
|
||||||
|
|
Loading…
Reference in a new issue