From f4b0a7c5159d418e22682d2bd7d413fb3587ca7f Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 19:51:52 +0100 Subject: store function accept any document --- src/remake/records.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/remake/records.rs') diff --git a/src/remake/records.rs b/src/remake/records.rs index 40b563a..fecae4c 100644 --- a/src/remake/records.rs +++ b/src/remake/records.rs @@ -38,7 +38,7 @@ use crate::clock::UnixMillis; use crate::document::meta::{self, REMAKES, VOTES}; use crate::document::replica::Epoch; use crate::document::store::{self, StoreError}; -use crate::document::{ChangeHash, Document}; +use crate::document::{ChangeHash, Document, Transactable}; /// One day, for retention defaults. const DAY_MS: u64 = 24 * 60 * 60 * 1000; @@ -446,7 +446,7 @@ pub(crate) fn load_register(doc: &Document) -> Register { } fn write_part( - doc: &mut Document, + doc: &mut impl Transactable, id: &str, part: &str, value: &T, @@ -456,7 +456,7 @@ fn write_part( } pub(crate) fn write_proposal( - doc: &mut Document, + doc: &mut impl Transactable, id: &str, proposal: &Proposal, ) -> Result<(), StoreError> { @@ -464,7 +464,7 @@ pub(crate) fn write_proposal( } pub(crate) fn write_decision( - doc: &mut Document, + doc: &mut impl Transactable, id: &str, decision: &Decision, ) -> Result<(), StoreError> { @@ -472,7 +472,7 @@ pub(crate) fn write_decision( } pub(crate) fn write_abort_request( - doc: &mut Document, + doc: &mut impl Transactable, id: &str, request: &AbortRequest, ) -> Result<(), StoreError> { @@ -480,7 +480,11 @@ pub(crate) fn write_abort_request( } /// Writes `voter`'s entry in the votes register (replacing its earlier one). -pub(crate) fn write_vote(doc: &mut Document, voter: &str, vote: &Vote) -> Result<(), StoreError> { +pub(crate) fn write_vote( + doc: &mut impl Transactable, + voter: &str, + vote: &Vote, +) -> Result<(), StoreError> { let json = serde_json::to_value(vote).map_err(anyhow::Error::from)?; store::write_path(doc, ®ister_path(voter), &json) } -- cgit v1.3.1