From 8128321f0d1397f438f225ca8733e3aa9de67e53 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 26 Apr 2021 15:41:08 -0600 Subject: [PATCH] add put --- patch-db/src/model.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patch-db/src/model.rs b/patch-db/src/model.rs index 5943c2f..8894b74 100644 --- a/patch-db/src/model.rs +++ b/patch-db/src/model.rs @@ -84,6 +84,15 @@ where } } } +impl Model +where + T: Serialize + for<'de> Deserialize<'de> + Send + Sync, +{ + pub async fn put(&self, tx: &mut Tx, value: &T) -> Result<(), Error> { + self.lock(tx, LockType::Write).await; + tx.put(&self.ptr, value).await + } +} impl From for Model where T: Serialize + for<'de> Deserialize<'de>,