mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
docs: updated docs
This commit is contained in:
parent
a622ac773c
commit
9422f9a216
3 changed files with 18 additions and 14 deletions
|
@ -62,6 +62,7 @@ impl TextChange {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "woot")]
|
#[cfg(feature = "woot")]
|
||||||
|
/// consume the [TextChange], transforming it into a Vec of [woot::crdt::Op]
|
||||||
pub fn transform(self, woot: &Woot) -> WootResult<Vec<Op>> {
|
pub fn transform(self, woot: &Woot) -> WootResult<Vec<Op>> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
if self.is_empty() { return Ok(out); } // no-op
|
if self.is_empty() { return Ok(out); } // no-op
|
||||||
|
|
|
@ -19,8 +19,7 @@ pub(crate) trait ControllerWorker<T : Sized + Send + Sync> {
|
||||||
///
|
///
|
||||||
/// this generic trait is implemented by actors managing stream procedures.
|
/// this generic trait is implemented by actors managing stream procedures.
|
||||||
/// events can be enqueued for dispatching without blocking ([Controller::send]), and an async blocking
|
/// events can be enqueued for dispatching without blocking ([Controller::send]), and an async blocking
|
||||||
/// api ([Controller::recv]) is provided to wait for server events. Additional sync blocking
|
/// api ([Controller::recv]) is provided to wait for server events.
|
||||||
/// ([Controller::blocking_recv]) is implemented if feature `sync` is enabled.
|
|
||||||
///
|
///
|
||||||
/// * if possible, prefer a pure [Controller::recv] consumer, awaiting for events
|
/// * if possible, prefer a pure [Controller::recv] consumer, awaiting for events
|
||||||
/// * if async is not feasible a [Controller::poll]/[Controller::try_recv] approach is possible
|
/// * if async is not feasible a [Controller::poll]/[Controller::try_recv] approach is possible
|
||||||
|
|
28
src/lib.rs
28
src/lib.rs
|
@ -5,8 +5,8 @@
|
||||||
//! > the core library of the codemp project, driving all editor plugins
|
//! > the core library of the codemp project, driving all editor plugins
|
||||||
//!
|
//!
|
||||||
//! ## structure
|
//! ## structure
|
||||||
//! The main entrypoint is the [Instance] object, that maintains a connection and can
|
//! The main entrypoint is the [Client] object, that maintains a connection and can
|
||||||
//! be used to join workspaces or attach to buffers. It contains the underlying [client::Client] and
|
//! be used to join workspaces or attach to buffers. It contains the underlying [Workspace] and
|
||||||
//! stores active controllers.
|
//! stores active controllers.
|
||||||
//!
|
//!
|
||||||
//! Some actions will return structs implementing the [api::Controller] trait. These can be polled
|
//! Some actions will return structs implementing the [api::Controller] trait. These can be polled
|
||||||
|
@ -21,26 +21,21 @@
|
||||||
//! immediately but instead deferred until compatible.
|
//! immediately but instead deferred until compatible.
|
||||||
//!
|
//!
|
||||||
//! ## features
|
//! ## features
|
||||||
//! * `woot` : include the underlying CRDT library and re-exports it (default enabled)
|
|
||||||
//! * `api` : include traits for core interfaces under [api] (default enabled)
|
//! * `api` : include traits for core interfaces under [api] (default enabled)
|
||||||
|
//! * `woot` : include the underlying CRDT library and re-exports it (default enabled)
|
||||||
//! * `proto` : include GRCP protocol definitions under [proto] (default enabled)
|
//! * `proto` : include GRCP protocol definitions under [proto] (default enabled)
|
||||||
//! * `client` : include the local [client] implementation (default enabled)
|
//! * `client` : include the local [client] implementation (default enabled)
|
||||||
//!
|
//!
|
||||||
//! ## examples
|
//! ## examples
|
||||||
//! the [client::Client] itself is the core structure implementing all methods, plugins should
|
//! most methods are split between the [Client] itself and the current [Workspace]
|
||||||
//! attempt to keep a single instance at any time
|
|
||||||
//!
|
|
||||||
//! working sessions are [workspace::Workspace] and while managing multiple ones is in theory
|
|
||||||
//! possible, it's not really working right now due to how authentication is managed
|
|
||||||
//!
|
//!
|
||||||
//! ### async
|
//! ### async
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use codemp::api::{Controller, TextChange};
|
//! use codemp::api::{Controller, TextChange};
|
||||||
//! # use codemp::client::Client;
|
|
||||||
//!
|
//!
|
||||||
//! # async fn async_example() -> codemp::Result<()> {
|
//! # async fn async_example() -> codemp::Result<()> {
|
||||||
//! // creating a client session will immediately attempt to connect
|
//! // creating a client session will immediately attempt to connect
|
||||||
//! let mut session = Client::new("http://alemi.dev:50053").await?;
|
//! let mut session = codemp::Client::new("http://alemi.dev:50053").await?;
|
||||||
//!
|
//!
|
||||||
//! // login first, obtaining a new token granting access to 'some_workspace'
|
//! // login first, obtaining a new token granting access to 'some_workspace'
|
||||||
//! session.login(
|
//! session.login(
|
||||||
|
@ -73,18 +68,19 @@
|
||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
//! it's always possible to get a [Workspace] reference using [Client::get_workspace]
|
||||||
|
//!
|
||||||
//! ### sync
|
//! ### sync
|
||||||
//! if async is not viable, a solution might be keeping a global tokio runtime and blocking on it:
|
//! if async is not viable, a solution might be keeping a global tokio runtime and blocking on it:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! # use codemp::client::Client;
|
|
||||||
//! # use std::sync::Arc;
|
//! # use std::sync::Arc;
|
||||||
//! # use codemp::api::Controller;
|
//! # use codemp::api::Controller;
|
||||||
//! #
|
//! #
|
||||||
//! # fn sync_example() -> codemp::Result<()> {
|
//! # fn sync_example() -> codemp::Result<()> {
|
||||||
//! let rt = tokio::runtime::Runtime::new().unwrap();
|
//! let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
//! let mut session = rt.block_on( // using block_on allows calling async code
|
//! let mut session = rt.block_on( // using block_on allows calling async code
|
||||||
//! Client::new("http://alemi.dev:50051")
|
//! codemp::Client::new("http://alemi.dev:50051")
|
||||||
//! )?;
|
//! )?;
|
||||||
//!
|
//!
|
||||||
//! rt.block_on(session.login(
|
//! rt.block_on(session.login(
|
||||||
|
@ -214,3 +210,11 @@ pub mod proto {
|
||||||
|
|
||||||
pub use errors::Error;
|
pub use errors::Error;
|
||||||
pub use errors::Result;
|
pub use errors::Result;
|
||||||
|
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
pub use client::Client;
|
||||||
|
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
pub use workspace::Workspace;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue