bits of docs

This commit is contained in:
Dustin J. Mitchell 2020-11-29 21:26:39 -05:00
parent 8601c0cb67
commit de03209285
3 changed files with 16 additions and 1 deletions

View file

@ -18,7 +18,7 @@ The [`server`](crate::server) module defines the interface a server must meet.
# See Also # See Also
See the [TaskChampion Book](https://github.com/djmitche/taskchampion/blob/main/docs/src/SUMMARY.md) See the [TaskChampion Book](http://djmitche.github.com/taskchampion)
for more information about the design and usage of the tool. for more information about the design and usage of the tool.
*/ */

View file

@ -12,6 +12,18 @@ use uuid::Uuid;
/// A replica represents an instance of a user's task data, providing an easy interface /// A replica represents an instance of a user's task data, providing an easy interface
/// for querying and modifying that data. /// for querying and modifying that data.
///
/// ## Tasks
///
/// Tasks are uniquely identified by UUIDs.
/// Most task modifications are performed via the [`crate::Task`] and [`crate::TaskMut`] types.
///
/// ## Working Set
///
/// A replica maintains a "working set" of tasks that are of current concern to the user,
/// specifically pending tasks. These are indexed with small, easy-to-type integers. Newly
/// pending tasks are automatically added to the working set, and the working set is "renumbered"
/// during the garbage-collection process.
pub struct Replica { pub struct Replica {
taskdb: TaskDB, taskdb: TaskDB,
} }
@ -23,6 +35,8 @@ impl Replica {
} }
} }
/// Construct a new replica from a configuration object. This is the common way
/// to create a new object.
pub fn from_config(config: ReplicaConfig) -> Fallible<Replica> { pub fn from_config(config: ReplicaConfig) -> Fallible<Replica> {
let storage = Box::new(KVStorage::new(config.taskdb_dir)?); let storage = Box::new(KVStorage::new(config.taskdb_dir)?);
Ok(Replica::new(storage)) Ok(Replica::new(storage))

View file

@ -12,6 +12,7 @@ pub use local::LocalServer;
pub use remote::RemoteServer; pub use remote::RemoteServer;
pub use types::*; pub use types::*;
/// Create a new server based on the given configuration.
pub fn from_config(config: ServerConfig) -> Fallible<Box<dyn Server>> { pub fn from_config(config: ServerConfig) -> Fallible<Box<dyn Server>> {
Ok(match config { Ok(match config {
ServerConfig::Local { server_dir } => Box::new(LocalServer::new(server_dir)?), ServerConfig::Local { server_dir } => Box::new(LocalServer::new(server_dir)?),