diff --git a/src/lib.rs b/src/lib.rs index c5ea53f..08fc167 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,30 @@ //! }); //! ``` //! +//! # Levels +//! +//! Locks are ordered by [`Level`](crate::level::Level), a +//! const-generic type. Create semantic aliases for your domain: +//! +//! ```rust +//! use surelock::level::Level; +//! +//! type Database = Level<0>; +//! type Table = Level<1>; +//! type Row = Level<2>; +//! ``` +//! +//! Use [`Mutex::new_after`](crate::mutex::Mutex::new_after) to +//! chain levels automatically: +//! +//! ```rust +//! use surelock::mutex::Mutex; +//! +//! let db: Mutex = Mutex::new("mydb".into()); +//! let table = db.new_after("users".to_string()); // Level<1> +//! let row = table.new_after(42u64); // Level<2> +//! ``` +//! //! # Backend Agnostic //! //! [`Mutex`](crate::mutex::Mutex) is generic over any diff --git a/src/set.rs b/src/set.rs index 656728b..2809f8f 100644 --- a/src/set.rs +++ b/src/set.rs @@ -1,6 +1,6 @@ //! Pre-sorted lock collection. //! -//! A [`LockSet`] wraps a [`Acquirable`] and pre-computes the acquisition +//! A [`LockSet`] wraps an [`Acquirable`] and pre-computes the acquisition //! order (sorted by [`LockId`](crate::id::LockId)). Construct once, lock many times via //! [`MutexKey::acquire`](crate::key::MutexKey::acquire). @@ -25,9 +25,9 @@ use crate::acquirable::Acquirable; /// let set = LockSet::new((&a, &b)); /// ``` pub struct LockSet { - pub(crate) group: L, + group: L, /// Indices into the group, sorted by `LockId`. - pub(crate) sorted_indices: Vec, + sorted_indices: Vec, } impl core::fmt::Debug for LockSet {