|
|
@ -25,7 +25,7 @@ pub trait SessionAccess { |
|
|
|
|
|
|
|
|
|
|
|
impl<'a> SessionAccess for Session<'a> { |
|
|
|
impl<'a> SessionAccess for Session<'a> { |
|
|
|
fn get<T: DeserializeOwned>(&self, path: &str) -> Option<T> { |
|
|
|
fn get<T: DeserializeOwned>(&self, path: &str) -> Option<T> { |
|
|
|
self.tap(|data| data.dot_get(path)) |
|
|
|
self.tap(|data| data.dot_get(path).unwrap_or_default()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn get_or<T: DeserializeOwned>(&self, path: &str, def: T) -> T { |
|
|
|
fn get_or<T: DeserializeOwned>(&self, path: &str, def: T) -> T { |
|
|
@ -41,19 +41,19 @@ impl<'a> SessionAccess for Session<'a> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn take<T: DeserializeOwned>(&self, path: &str) -> Option<T> { |
|
|
|
fn take<T: DeserializeOwned>(&self, path: &str) -> Option<T> { |
|
|
|
self.tap(|data| data.dot_take(path)) |
|
|
|
self.tap(|data| data.dot_take(path).unwrap_or_default()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn replace<O: DeserializeOwned, N: Serialize>(&self, path: &str, new: N) -> Option<O> { |
|
|
|
fn replace<O: DeserializeOwned, N: Serialize>(&self, path: &str, new: N) -> Option<O> { |
|
|
|
self.tap(|data| data.dot_replace(path, new)) |
|
|
|
self.tap(|data| data.dot_replace(path, new).unwrap_or_default()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn set<T: Serialize>(&self, path: &str, value: T) { |
|
|
|
fn set<T: Serialize>(&self, path: &str, value: T) { |
|
|
|
self.tap(|data| data.dot_set(path, value)); |
|
|
|
self.tap(|data| data.dot_set(path, value)).unwrap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn remove(&self, path: &str) -> bool { |
|
|
|
fn remove(&self, path: &str) -> bool { |
|
|
|
self.tap(|data| data.dot_remove(path)) |
|
|
|
self.tap(|data| { data.dot_remove(path).is_ok() }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|