Crate lockable

source ·
Expand description

TODO Crate level documentation

Structs

A RAII implementation of a scoped lock for locks from a LockableHashMap or LockableLruCache. When this instance is dropped (falls out of scope), the lock will be unlocked.
A threadsafe hash map where individual keys can be locked/unlocked, even if there is no entry for this key in the map. It initially considers all keys as “unlocked”, but they can be locked and if a second thread tries to acquire a lock for the same key, they will have to wait.
A threadsafe LRU cache where individual keys can be locked/unlocked, even if there is no entry for this key in the cache. It initially considers all keys as “unlocked”, but they can be locked and if a second thread tries to acquire a lock for the same key, they will have to wait.

Enums

An instance of this enum defines a limit on the number of entries in a LockableLruCache or a LockableHashMap. It can be used to cause old entries to be evicted if a limit on the number of entries is exceeded in a call to the following functions:
A type that can never be instantiated. This can be used in a Result<T, Never> to indicate that an operation cannot return an error.
An instance of this enum defines a limit on the number of entries in a LockableLruCache or a LockableHashMap. It can be used to cause old entries to be evicted if a limit on the number of entries is exceeded in a call to the following functions:
This error is thrown by Guard::try_insert if the entry already exists

Traits

Extension trait for Result<T, Never> that adds infallible_unwrap(), an infallible version of unwrap().
A common trait for both LockableHashMap and LockableLruCache that offers some common functionalities.