aboutsummaryrefslogtreecommitdiff
path: root/src/manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/manager')
-rw-r--r--src/manager/builder.rs8
-rw-r--r--src/manager/mod.rs20
-rw-r--r--src/manager/updater.rs24
3 files changed, 19 insertions, 33 deletions
diff --git a/src/manager/builder.rs b/src/manager/builder.rs
index e5fe2da..a5f04f2 100644
--- a/src/manager/builder.rs
+++ b/src/manager/builder.rs
@@ -162,11 +162,9 @@ fn find_psk<'a>(
src: &'a Source,
p: &proto::Peer,
) -> Result<Option<&'a model::Key>, Error> {
- let want = gc.peers.get(&p.public_key);
- let want = if let Some(v) = want {
- v
- } else {
- return Ok(None);
+ let want = match gc.peers.get(&p.public_key) {
+ Some(v) => v,
+ None => return Ok(None),
};
if let Some(ref want_src) = &want.source {
diff --git a/src/manager/mod.rs b/src/manager/mod.rs
index 78d579f..aa8b792 100644
--- a/src/manager/mod.rs
+++ b/src/manager/mod.rs
@@ -95,20 +95,15 @@ impl Manager {
}
fn state_path(&self) -> Option<PathBuf> {
- let mut path = if let Some(ref path) = self.state_directory {
- path.clone()
- } else {
- return None;
- };
+ let mut path = self.state_directory.as_ref()?.clone();
path.push("state.json");
Some(path)
}
fn current_load(&mut self) -> bool {
- let path = if let Some(path) = self.state_path() {
- path
- } else {
- return false;
+ let path = match self.state_path() {
+ Some(v) => v,
+ None => return false,
};
let data = match load_file(&path) {
@@ -136,10 +131,9 @@ impl Manager {
}
fn current_update(&mut self, c: &model::Config) {
- let path = if let Some(path) = self.state_path() {
- path
- } else {
- return;
+ let path = match self.state_path() {
+ Some(v) => v,
+ None => return,
};
let data = serde_json::to_vec(c).unwrap();
diff --git a/src/manager/updater.rs b/src/manager/updater.rs
index 0de675c..14d55fc 100644
--- a/src/manager/updater.rs
+++ b/src/manager/updater.rs
@@ -19,20 +19,15 @@ impl Updater {
}
fn cache_path(&self, s: &Source) -> Option<PathBuf> {
- if let Some(ref dir) = self.config.cache_directory {
- let mut p = dir.clone();
- p.push(&s.name);
- Some(p)
- } else {
- None
- }
+ let mut p = self.config.cache_directory.as_ref()?.clone();
+ p.push(&s.name);
+ Some(p)
}
fn cache_update(&self, src: &Source) {
- let path = if let Some(path) = self.cache_path(src) {
- path
- } else {
- return;
+ let path = match self.cache_path(src) {
+ Some(v) => v,
+ None => return,
};
let data = serde_json::to_vec(&src.data).unwrap();
@@ -45,10 +40,9 @@ impl Updater {
}
pub fn cache_load(&self, src: &mut Source) -> bool {
- let path = if let Some(path) = self.cache_path(src) {
- path
- } else {
- return false;
+ let path = match self.cache_path(src) {
+ Some(v) => v,
+ None => return false,
};
let data = match load_file(&path) {