Factor replica and sync configuration into simple owned structs
This commit is contained in:
@@ -25,7 +25,7 @@ pub struct LocalServer<'t> {
|
||||
|
||||
impl<'t> LocalServer<'t> {
|
||||
/// A test server has no notion of clients, signatures, encryption, etc.
|
||||
pub fn new(directory: &Path) -> Fallible<LocalServer> {
|
||||
pub fn new<P: AsRef<Path>>(directory: P) -> Fallible<LocalServer<'t>> {
|
||||
let mut config = Config::default(directory);
|
||||
config.bucket("versions", None);
|
||||
config.bucket("numbers", None);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use crate::ServerConfig;
|
||||
use failure::Fallible;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test;
|
||||
|
||||
@@ -8,3 +11,12 @@ mod types;
|
||||
pub use local::LocalServer;
|
||||
pub use remote::RemoteServer;
|
||||
pub use types::*;
|
||||
|
||||
pub fn from_config(config: ServerConfig) -> Fallible<Box<dyn Server>> {
|
||||
Ok(match config {
|
||||
ServerConfig::Local { server_dir } => Box::new(LocalServer::new(server_dir)?),
|
||||
ServerConfig::Remote { origin, client_id } => {
|
||||
Box::new(RemoteServer::new(origin, client_id))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user