summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@pep-project.org>2017-12-06 11:51:42 +0100
committerJustus Winter <justus@pep-project.org>2017-12-06 11:53:01 +0100
commitb0fd3726cf4bc9cfd1651d36a624103e65f3f3e3 (patch)
treefd537a0bbf97ee00cc473d33ea8a0bcf27e52899 /src/lib.rs
parent1c98b651ed00e4638be31206f790f06a4fb5c8af (diff)
Add 'domain' to the context.
- The domain uniquely identifies the application. It should be a property of the context.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7f737aad..ac8afc4e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -23,7 +23,14 @@ use std::io;
use std::path::{Path, PathBuf};
/// A `&Context` is required for many operations.
+///
+/// # Example
+///
+/// ```
+/// let c = Context::new("org.example.webmail").finalize().unwrap();
+/// ```
pub struct Context {
+ domain: String,
home: PathBuf,
lib: PathBuf,
}
@@ -34,17 +41,28 @@ fn prefix() -> PathBuf {
}
impl Context {
- /// Create a `Pre(Context)` with reasonable defaults. `Pre(Context)`s
- /// can be modified, and have to be finalized in order to turn
- /// them into a Context.
- pub fn new() -> Pre {
+ /// Creates a `Pre(Context)` with reasonable defaults.
+ ///
+ /// `domain` should uniquely identify your application, it is
+ /// strongly suggested to use a reversed fully qualified domain
+ /// name that is associated with your application.
+ ///
+ /// `Pre(Context)`s can be modified, and have to be finalized in
+ /// order to turn them into a Context.
+ pub fn new(domain: &str) -> Pre {
Pre(Context {
+ domain: String::from(domain),
home: env::home_dir().unwrap_or(env::temp_dir())
.join(".sequoia"),
lib: prefix().join("lib").join("sequoia"),
})
}
+ /// Return the directory containing backend servers.
+ pub fn domain(&self) -> &str {
+ &self.domain
+ }
+
/// Return the directory containing shared state and rendezvous
/// nodes.
pub fn home(&self) -> &Path {