-
Notifications
You must be signed in to change notification settings - Fork 221
/
bridge.rs
75 lines (59 loc) · 2.12 KB
/
bridge.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* 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 sync15_traits::{self, ApplyResults};
use crate::api;
use crate::db::StorageDb;
use crate::error::{Error, ErrorKind, Result};
/// A bridged engine implements all the methods needed to make the
/// `storage.sync` store work with Desktop's Sync implementation.
/// Conceptually, it's similar to `sync15_traits::Store`, which we
/// should eventually rename and unify with this trait (#2841).
pub struct BridgedEngine<'a> {
db: &'a StorageDb,
}
impl<'a> BridgedEngine<'a> {
/// Creates a bridged engine for syncing.
pub fn new(db: &'a StorageDb) -> Self {
BridgedEngine { db }
}
}
impl<'a> sync15_traits::BridgedEngine for BridgedEngine<'a> {
type Error = Error;
fn last_sync(&self) -> Result<i64> {
Err(ErrorKind::NotImplemented.into())
}
fn set_last_sync(&self, _last_sync_millis: i64) -> Result<()> {
Err(ErrorKind::NotImplemented.into())
}
fn sync_id(&self) -> Result<Option<String>> {
Err(ErrorKind::NotImplemented.into())
}
fn reset_sync_id(&self) -> Result<String> {
Err(ErrorKind::NotImplemented.into())
}
fn ensure_current_sync_id(&self, _new_sync_id: &str) -> Result<String> {
Err(ErrorKind::NotImplemented.into())
}
fn store_incoming(&self, _incoming_cleartexts: &[String]) -> Result<()> {
Err(ErrorKind::NotImplemented.into())
}
fn apply(&self) -> Result<ApplyResults> {
Err(ErrorKind::NotImplemented.into())
}
fn set_uploaded(&self, _server_modified_millis: i64, _ids: &[String]) -> Result<()> {
Err(ErrorKind::NotImplemented.into())
}
fn sync_finished(&self) -> Result<()> {
Err(ErrorKind::NotImplemented.into())
}
fn reset(&self) -> Result<()> {
Err(ErrorKind::NotImplemented.into())
}
fn wipe(&self) -> Result<()> {
let tx = self.db.unchecked_transaction()?;
api::wipe_all(&tx)?;
tx.commit()?;
Ok(())
}
}