From a25ef6974e0ba3989f6205c19a1f9ccfc81db584 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 15 May 2019 16:28:11 +0200 Subject: core, store, tool: Use realm instead of domain. - Remove the domain parameter from core::Context. - Replace it with a realm to be passed in when opening a store. - For sq, merge store name and realm into the --store parameter. - Fixes #105. --- core/src/lib.rs | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'core') diff --git a/core/src/lib.rs b/core/src/lib.rs index a3b6010e..540ae34a 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -13,7 +13,7 @@ /// # use sequoia_core::{Context, Result}; /// # f().unwrap(); /// # fn f() -> Result<()> { -/// let c = Context::new("org.example.webmail")?; +/// let c = Context::new(); /// # Ok(()) /// # } /// ``` @@ -39,7 +39,7 @@ use tempdir::TempDir; /// # use sequoia_core::{Context, Result}; /// # f().unwrap(); /// # fn f() -> Result<()> { -/// let c = Context::new("org.example.webmail")?; +/// let c = Context::new()?; /// # Ok(()) /// # } /// ``` @@ -51,7 +51,7 @@ use tempdir::TempDir; /// # use sequoia_core::{Context, NetworkPolicy, Result}; /// # f().unwrap(); /// # fn f() -> Result<()> { -/// let c = Context::configure("org.example.webmail") +/// let c = Context::configure() /// # .ephemeral() /// .network_policy(NetworkPolicy::Offline) /// .build()?; @@ -59,7 +59,6 @@ use tempdir::TempDir; /// # } /// ``` pub struct Context { - domain: String, home: PathBuf, lib: PathBuf, network_policy: NetworkPolicy, @@ -71,7 +70,6 @@ pub struct Context { impl Clone for Context { fn clone(&self) -> Self { Context { - domain: self.domain.clone(), home: self.home.clone(), lib: self.lib.clone(), network_policy: self.network_policy, @@ -100,26 +98,17 @@ fn prefix() -> PathBuf { impl Context { /// Creates a 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. - pub fn new(domain: &str) -> Result { - Self::configure(domain).build() + pub fn new() -> Result { + Self::configure().build() } /// Creates a Context that can be configured. /// - /// `domain` should uniquely identify your application, it is - /// strongly suggested to use a reversed fully qualified domain - /// name that is associated with your application. - /// /// The configuration is seeded like in `Context::new`, but can be /// modified. A configuration has to be finalized using /// `.build()` in order to turn it into a Context. - pub fn configure(domain: &str) -> Config { + pub fn configure() -> Config { Config(Context { - domain: String::from(domain), home: PathBuf::from(""), // Defer computation of default. lib: prefix().join("lib").join("sequoia"), network_policy: NetworkPolicy::Encrypted, @@ -129,11 +118,6 @@ impl Context { }) } - /// Returns the domain of the context. - pub fn domain(&self) -> &str { - &self.domain - } - /// Returns the directory containing shared state. pub fn home(&self) -> &Path { &self.home @@ -169,7 +153,7 @@ impl Context { /// # use sequoia_core::{Context, NetworkPolicy, Result}; /// # f().unwrap(); /// # fn f() -> Result<()> { -/// let c = Context::configure("org.example.webmail") +/// let c = Context::configure() /// # .ephemeral() /// .network_policy(NetworkPolicy::Offline) /// .build()?; @@ -185,8 +169,7 @@ impl Context { /// # use std::path::Path; /// # f().unwrap(); /// # fn f() -> Result<()> { -/// let c = Context::configure("org.example.my.test") -/// .ephemeral().build()?; +/// let c = Context::configure().ephemeral().build()?; /// let ephemeral_home = c.home().to_path_buf(); /// // Do some tests. /// drop(c); -- cgit v1.2.3