Skip to content

Commit

Permalink
improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kingwingfly committed Aug 14, 2024
1 parent a6dd7a7 commit 632e86b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
-->

## [Unreleased]
## [1.0.4] - 2024-08-15

- doc

## [1.0.3] - 2024-08-13

- doc
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["encrypt-config", "encrypt-config-derive", "tests", "examples"]
resolver = "2"

[workspace.package]
version = "1.0.3"
version = "1.0.4"
authors = ["Louis <[email protected]>"]
description = "A Rust crate to manage, persist and encrypt your configurations."
license = "MIT"
Expand Down
18 changes: 12 additions & 6 deletions encrypt-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ use std::any::Any;

/// A struct that can be used to **cache** configuration values.
/// This behaves like a native cache in CPU:
/// 1. If cache hit, reading returns the cached value, while writing upgrades the cached value then set cache flag dirty.
/// 2. If cache miss, reading loads the value from the source to cache, while writing saves the value to source then loads it to cache.
/// 3. All caches values dirty will be written back when Config dropped.
///
/// **At most N** different types in all threads are safe to be managed due to the default cache capacity.
/// `get`:
/// 1. If cache hit, returns the cached value's ref.
/// 2. If cache miss, loads the value from the source to cache (default as fallback), then returns the ref.
///
/// `get_mut`
/// 1. If cache hit, returns the cached value's mut ref, dereferencing it will mark the value as dirty.
/// 2. If cache miss, loads the value from the source to cache (default as fallback), then returns the mut ref.
/// 3. All caches values dirty will be written back when Config dropped or cache line evicted.
///
/// **At most N** different config types are safe to be managed at the same time due to the cache capacity.
/// And each type can be ref **up to 63** times or mut ref **up to 1** time at the same time.
/// Or invalid borrow may happen.
/// Or invalid borrow may happen (since the counter wraps around on overflow).
#[cfg_attr(
feature = "secret",
doc = "To avoid entering the password during testing, you can enable `mock` feature. This can always return the **same** Encrypter during **each** test."
Expand Down Expand Up @@ -96,7 +102,7 @@ impl<const N: usize> Config<N> {
pub type CfgRef<'a, T> = CacheRef<'a, T>;

/// # Panic
/// - If you already held a [`CfgMut`], [`Config::get()`] will panic.
/// - If you already held a [`CfgRef`] or [`CfgMut`], [`Config::get_mut()`] will panic.
pub type CfgMut<'a, T> = CacheMut<'a, T>;

/// This trait is used to retrieve the config value from the cache.
Expand Down

0 comments on commit 632e86b

Please sign in to comment.