mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-09 00:15:23 -04:00
refactor(indexeddb): add type to represent time-based lock on event cache
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
committed by
Ivan Enderlin
parent
12292c5375
commit
bc0018aecb
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use matrix_sdk_base::{
|
||||
deserialized_responses::TimelineEvent, event_cache::store::extract_event_relation,
|
||||
linked_chunk::ChunkIdentifier,
|
||||
@@ -19,6 +21,22 @@ use matrix_sdk_base::{
|
||||
use ruma::{OwnedEventId, OwnedRoomId, RoomId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Representation of a time-based lock on the entire
|
||||
/// [`IndexeddbEventCacheStore`](crate::event_cache_store::IndexeddbEventCacheStore)
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Lease {
|
||||
pub key: String,
|
||||
pub holder: String,
|
||||
pub expiration: Duration,
|
||||
}
|
||||
|
||||
impl Lease {
|
||||
/// Determines whether the lease is expired at a given time `t`
|
||||
pub fn expired_at(&self, t: Duration) -> bool {
|
||||
self.expiration < t
|
||||
}
|
||||
}
|
||||
|
||||
/// Representation of a [`Chunk`](matrix_sdk_base::linked_chunk::Chunk)
|
||||
/// which can be stored in IndexedDB.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user