summaryrefslogtreecommitdiffstats
path: root/third_party/rust/sync15/src/engine/changeset.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/sync15/src/engine/changeset.rs')
-rw-r--r--third_party/rust/sync15/src/engine/changeset.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/third_party/rust/sync15/src/engine/changeset.rs b/third_party/rust/sync15/src/engine/changeset.rs
new file mode 100644
index 0000000000..f69ce1b8fa
--- /dev/null
+++ b/third_party/rust/sync15/src/engine/changeset.rs
@@ -0,0 +1,42 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use crate::bso::{IncomingBso, OutgoingBso};
+use crate::ServerTimestamp;
+
+#[derive(Debug, Clone)]
+pub struct RecordChangeset<T> {
+ pub changes: Vec<T>,
+ /// For GETs, the last sync timestamp that should be persisted after
+ /// applying the records.
+ /// For POSTs, this is the XIUS timestamp.
+ pub timestamp: ServerTimestamp,
+ pub collection: std::borrow::Cow<'static, str>,
+}
+
+pub type IncomingChangeset = RecordChangeset<IncomingBso>;
+pub type OutgoingChangeset = RecordChangeset<OutgoingBso>;
+
+impl<T> RecordChangeset<T> {
+ #[inline]
+ pub fn new(
+ collection: impl Into<std::borrow::Cow<'static, str>>,
+ timestamp: ServerTimestamp,
+ ) -> RecordChangeset<T> {
+ Self::new_with_changes(collection, timestamp, Vec::new())
+ }
+
+ #[inline]
+ pub fn new_with_changes(
+ collection: impl Into<std::borrow::Cow<'static, str>>,
+ timestamp: ServerTimestamp,
+ changes: Vec<T>,
+ ) -> RecordChangeset<T> {
+ RecordChangeset {
+ changes,
+ timestamp,
+ collection: collection.into(),
+ }
+ }
+}