Skip to content

Commit

Permalink
linera_service::persistent: use the indicative mood for function do…
Browse files Browse the repository at this point in the history
…cumentation
  • Loading branch information
Twey committed Jul 2, 2024
1 parent 7dfa45e commit d215310
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions linera-service/src/persistent/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn open_options() -> fs_err::OpenOptions {
}

impl<T: serde::de::DeserializeOwned> File<T> {
/// Create a new persistent file at `path` containing `value`.
/// Creates a new persistent file at `path` containing `value`.
pub fn new(path: &Path, value: T) -> anyhow::Result<Self> {
Ok(Self {
_lock: Lock::new(
Expand All @@ -84,15 +84,15 @@ impl<T: serde::de::DeserializeOwned> File<T> {
})
}

/// Read the value from a file at `path`, returning an error if it does not exist.
/// Reads the value from a file at `path`, returning an error if it does not exist.
pub fn read(path: &Path) -> anyhow::Result<Self> {
Self::read_or_create(path, || {
Err(anyhow::anyhow!("Path does not exist: {}", path.display()))
})
}

/// Read the value from a file at `path`, calling the `value` function to create it if
/// it does not exist. If it does exist, `value` will not be called.
/// Reads the value from a file at `path`, calling the `value` function to create it
/// if it does not exist. If it does exist, `value` will not be called.
pub fn read_or_create(
path: &Path,
value: impl FnOnce() -> anyhow::Result<T>,
Expand All @@ -111,7 +111,7 @@ impl<T: serde::de::DeserializeOwned> File<T> {
})
}

/// Take the value out, releasing the lock on the persistent file.
/// Takes the value out, releasing the lock on the persistent file.
pub fn into_value(self) -> T {
self.value
}
Expand Down
6 changes: 3 additions & 3 deletions linera-service/src/persistent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub use file::File;
pub trait Persist: Deref {
type Error: std::fmt::Debug;

/// Get a mutable reference to the value.
/// Gets a mutable reference to the value.
fn as_mut(_: &mut Self) -> &mut Self::Target;

/// Save the value to persistent storage.
/// Saves the value to persistent storage.
fn persist(_: &mut Self) -> Result<(), Self::Error>;

/// Get a mutable reference to the value which, on drop, will automatically persist
/// Gets a mutable reference to the value which, on drop, will automatically persist
/// the new value.
fn mutate(this: &mut Self) -> RefMut<Self> {
RefMut(this)
Expand Down

0 comments on commit d215310

Please sign in to comment.