fix clippy lints
This commit is contained in:
@@ -104,7 +104,7 @@ impl TCString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub enum RustString<'a> {
|
pub enum RustString<'a> {
|
||||||
Null,
|
Null,
|
||||||
CString(CString),
|
CString(CString),
|
||||||
@@ -600,7 +600,7 @@ mod test {
|
|||||||
|
|
||||||
fn make_cstr() -> RustString<'static> {
|
fn make_cstr() -> RustString<'static> {
|
||||||
let cstr = CStr::from_bytes_with_nul(b"a string\0").unwrap();
|
let cstr = CStr::from_bytes_with_nul(b"a string\0").unwrap();
|
||||||
RustString::CStr(&cstr)
|
RustString::CStr(cstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_string() -> RustString<'static> {
|
fn make_string() -> RustString<'static> {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ impl Default for ServerConfig {
|
|||||||
impl ServerConfig {
|
impl ServerConfig {
|
||||||
pub fn from_args(snapshot_days: i64, snapshot_versions: u32) -> anyhow::Result<ServerConfig> {
|
pub fn from_args(snapshot_days: i64, snapshot_versions: u32) -> anyhow::Result<ServerConfig> {
|
||||||
Ok(ServerConfig {
|
Ok(ServerConfig {
|
||||||
snapshot_days: snapshot_days,
|
snapshot_days,
|
||||||
snapshot_versions: snapshot_versions,
|
snapshot_versions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1021,7 +1021,7 @@ mod test {
|
|||||||
let client = txn.get_client(client_key)?.unwrap();
|
let client = txn.get_client(client_key)?.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_snapshot(txn, &ServerConfig::default(), client_key, client)?,
|
get_snapshot(txn, &ServerConfig::default(), client_key, client)?,
|
||||||
Some((snapshot_version_id, data.clone()))
|
Some((snapshot_version_id, data))
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pub use inmemory::InMemoryStorage;
|
|||||||
mod sqlite;
|
mod sqlite;
|
||||||
pub use self::sqlite::SqliteStorage;
|
pub use self::sqlite::SqliteStorage;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
/// The latest version for this client (may be the nil version)
|
/// The latest version for this client (may be the nil version)
|
||||||
pub latest_version_id: Uuid,
|
pub latest_version_id: Uuid,
|
||||||
@@ -18,7 +18,7 @@ pub struct Client {
|
|||||||
pub snapshot: Option<Snapshot>,
|
pub snapshot: Option<Snapshot>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Snapshot {
|
pub struct Snapshot {
|
||||||
/// ID of the version at which this snapshot was made
|
/// ID of the version at which this snapshot was made
|
||||||
pub version_id: Uuid,
|
pub version_id: Uuid,
|
||||||
@@ -30,7 +30,7 @@ pub struct Snapshot {
|
|||||||
pub versions_since: u32,
|
pub versions_since: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Version {
|
pub struct Version {
|
||||||
pub version_id: Uuid,
|
pub version_id: Uuid,
|
||||||
pub parent_version_id: Uuid,
|
pub parent_version_id: Uuid,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use uuid::Uuid;
|
|||||||
///
|
///
|
||||||
/// This information requires a scan of the working set to generate, so it is
|
/// This information requires a scan of the working set to generate, so it is
|
||||||
/// typically calculated once and re-used.
|
/// typically calculated once and re-used.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct DependencyMap {
|
pub struct DependencyMap {
|
||||||
/// Edges of the dependency graph. If (a, b) is in this array, then task a depends on tsak b.
|
/// Edges of the dependency graph. If (a, b) is in this array, then task a depends on tsak b.
|
||||||
edges: Vec<(Uuid, Uuid)>,
|
edges: Vec<(Uuid, Uuid)>,
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ mod test {
|
|||||||
|
|
||||||
let unsealed = Unsealed {
|
let unsealed = Unsealed {
|
||||||
version_id,
|
version_id,
|
||||||
payload: payload.clone(),
|
payload: payload,
|
||||||
};
|
};
|
||||||
let sealed = cryptor.seal(unsealed).unwrap();
|
let sealed = cryptor.seal(unsealed).unwrap();
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ mod test {
|
|||||||
|
|
||||||
let unsealed = Unsealed {
|
let unsealed = Unsealed {
|
||||||
version_id,
|
version_id,
|
||||||
payload: payload.clone(),
|
payload: payload,
|
||||||
};
|
};
|
||||||
let mut sealed = cryptor.seal(unsealed).unwrap();
|
let mut sealed = cryptor.seal(unsealed).unwrap();
|
||||||
sealed.version_id = Uuid::new_v4(); // change the version_id
|
sealed.version_id = Uuid::new_v4(); // change the version_id
|
||||||
@@ -309,7 +309,7 @@ mod test {
|
|||||||
|
|
||||||
let unsealed = Unsealed {
|
let unsealed = Unsealed {
|
||||||
version_id,
|
version_id,
|
||||||
payload: payload.clone(),
|
payload: payload,
|
||||||
};
|
};
|
||||||
let sealed = cryptor.seal(unsealed).unwrap();
|
let sealed = cryptor.seal(unsealed).unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ mod test {
|
|||||||
|
|
||||||
// then add another, not based on that one
|
// then add another, not based on that one
|
||||||
if let (AddVersionResult::Ok(_), SnapshotUrgency::None) =
|
if let (AddVersionResult::Ok(_), SnapshotUrgency::None) =
|
||||||
server.add_version(parent_version_id, history.clone())?
|
server.add_version(parent_version_id, history)?
|
||||||
{
|
{
|
||||||
panic!("should not have accepted the version")
|
panic!("should not have accepted the version")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
/// A SyncOp defines a single change to the task database, that can be synchronized
|
/// A SyncOp defines a single change to the task database, that can be synchronized
|
||||||
/// via a server.
|
/// via a server.
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub enum SyncOp {
|
pub enum SyncOp {
|
||||||
/// Create a new task.
|
/// Create a new task.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub type HistorySegment = Vec<u8>;
|
|||||||
pub type Snapshot = Vec<u8>;
|
pub type Snapshot = Vec<u8>;
|
||||||
|
|
||||||
/// AddVersionResult is the response type from [`crate::server::Server::add_version`].
|
/// AddVersionResult is the response type from [`crate::server::Server::add_version`].
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum AddVersionResult {
|
pub enum AddVersionResult {
|
||||||
/// OK, version added with the given ID
|
/// OK, version added with the given ID
|
||||||
Ok(VersionId),
|
Ok(VersionId),
|
||||||
@@ -35,7 +35,7 @@ pub enum SnapshotUrgency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A version as downloaded from the server
|
/// A version as downloaded from the server
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum GetVersionResult {
|
pub enum GetVersionResult {
|
||||||
/// No such version exists
|
/// No such version exists
|
||||||
NoSuchVersion,
|
NoSuchVersion,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
/// A ReplicaOp defines a single change to the task database, as stored locally in the replica.
|
/// A ReplicaOp defines a single change to the task database, as stored locally in the replica.
|
||||||
/// This contains additional information not included in SyncOp.
|
/// This contains additional information not included in SyncOp.
|
||||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub enum ReplicaOp {
|
pub enum ReplicaOp {
|
||||||
/// Create a new task.
|
/// Create a new task.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -532,14 +532,14 @@ mod test {
|
|||||||
let uuid2 = Uuid::new_v4();
|
let uuid2 = Uuid::new_v4();
|
||||||
{
|
{
|
||||||
let mut txn = storage.txn()?;
|
let mut txn = storage.txn()?;
|
||||||
assert!(txn.create_task(uuid1.clone())?);
|
assert!(txn.create_task(uuid1)?);
|
||||||
txn.set_task(
|
txn.set_task(
|
||||||
uuid1.clone(),
|
uuid1,
|
||||||
taskmap_with(vec![("num".to_string(), "1".to_string())]),
|
taskmap_with(vec![("num".to_string(), "1".to_string())]),
|
||||||
)?;
|
)?;
|
||||||
assert!(txn.create_task(uuid2.clone())?);
|
assert!(txn.create_task(uuid2)?);
|
||||||
txn.set_task(
|
txn.set_task(
|
||||||
uuid2.clone(),
|
uuid2,
|
||||||
taskmap_with(vec![("num".to_string(), "2".to_string())]),
|
taskmap_with(vec![("num".to_string(), "2".to_string())]),
|
||||||
)?;
|
)?;
|
||||||
txn.commit()?;
|
txn.commit()?;
|
||||||
@@ -553,11 +553,11 @@ mod test {
|
|||||||
|
|
||||||
let mut exp = vec![
|
let mut exp = vec![
|
||||||
(
|
(
|
||||||
uuid1.clone(),
|
uuid1,
|
||||||
taskmap_with(vec![("num".to_string(), "1".to_string())]),
|
taskmap_with(vec![("num".to_string(), "1".to_string())]),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
uuid2.clone(),
|
uuid2,
|
||||||
taskmap_with(vec![("num".to_string(), "2".to_string())]),
|
taskmap_with(vec![("num".to_string(), "2".to_string())]),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@@ -570,7 +570,7 @@ mod test {
|
|||||||
let mut uuids = txn.all_task_uuids()?;
|
let mut uuids = txn.all_task_uuids()?;
|
||||||
uuids.sort();
|
uuids.sort();
|
||||||
|
|
||||||
let mut exp = vec![uuid1.clone(), uuid2.clone()];
|
let mut exp = vec![uuid1, uuid2];
|
||||||
exp.sort();
|
exp.sort();
|
||||||
|
|
||||||
assert_eq!(uuids, exp);
|
assert_eq!(uuids, exp);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/// The status of a task, as defined by the task data model.
|
/// The status of a task, as defined by the task data model.
|
||||||
#[derive(Debug, PartialEq, Clone, strum_macros::Display)]
|
#[derive(Debug, PartialEq, Eq, Clone, strum_macros::Display)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
Pending,
|
Pending,
|
||||||
|
|||||||
@@ -887,7 +887,7 @@ mod test {
|
|||||||
with_mut_task(|mut task| {
|
with_mut_task(|mut task| {
|
||||||
let property = "property-name";
|
let property = "property-name";
|
||||||
task.set_value(property, Some("value".into())).unwrap();
|
task.set_value(property, Some("value".into())).unwrap();
|
||||||
assert_eq!(task.get_value(property), Some("value".into()));
|
assert_eq!(task.get_value(property), Some("value"));
|
||||||
task.set_value(property, None).unwrap();
|
task.set_value(property, None).unwrap();
|
||||||
assert_eq!(task.get_value(property), None);
|
assert_eq!(task.get_value(property), None);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ mod tests {
|
|||||||
let op = SyncOp::Create { uuid };
|
let op = SyncOp::Create { uuid };
|
||||||
{
|
{
|
||||||
let mut txn = db.storage.txn()?;
|
let mut txn = db.storage.txn()?;
|
||||||
let taskmap = apply_and_record(txn.as_mut(), op.clone())?;
|
let taskmap = apply_and_record(txn.as_mut(), op)?;
|
||||||
|
|
||||||
assert_eq!(taskmap.len(), 1);
|
assert_eq!(taskmap.len(), 1);
|
||||||
assert_eq!(taskmap.get("foo").unwrap(), "bar");
|
assert_eq!(taskmap.get("foo").unwrap(), "bar");
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl TaskDb {
|
|||||||
.map(|(p, v)| (p.clone(), v.clone()))
|
.map(|(p, v)| (p.clone(), v.clone()))
|
||||||
.collect::<Vec<(String, String)>>();
|
.collect::<Vec<(String, String)>>();
|
||||||
t.sort();
|
t.sort();
|
||||||
(u.clone(), t)
|
(*u, t)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
res.sort();
|
res.sort();
|
||||||
@@ -175,8 +175,7 @@ impl TaskDb {
|
|||||||
let mut txn = self.storage.txn().unwrap();
|
let mut txn = self.storage.txn().unwrap();
|
||||||
txn.operations()
|
txn.operations()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter().cloned()
|
||||||
.map(|o| o.clone())
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +197,7 @@ mod tests {
|
|||||||
let mut db = TaskDb::new_inmemory();
|
let mut db = TaskDb::new_inmemory();
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
let op = SyncOp::Create { uuid };
|
let op = SyncOp::Create { uuid };
|
||||||
db.apply(op.clone()).unwrap();
|
db.apply(op).unwrap();
|
||||||
|
|
||||||
assert_eq!(db.sorted_tasks(), vec![(uuid, vec![]),]);
|
assert_eq!(db.sorted_tasks(), vec![(uuid, vec![]),]);
|
||||||
assert_eq!(db.operations(), vec![ReplicaOp::Create { uuid }]);
|
assert_eq!(db.operations(), vec![ReplicaOp::Create { uuid }]);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
for i in &[0usize, 1, 4] {
|
for i in &[0usize, 1, 4] {
|
||||||
db.apply(SyncOp::Update {
|
db.apply(SyncOp::Update {
|
||||||
uuid: uuids[*i].clone(),
|
uuid: uuids[*i],
|
||||||
property: String::from("status"),
|
property: String::from("status"),
|
||||||
value: Some("pending".into()),
|
value: Some("pending".into()),
|
||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
@@ -121,9 +121,9 @@ mod test {
|
|||||||
db.working_set()?,
|
db.working_set()?,
|
||||||
vec![
|
vec![
|
||||||
None,
|
None,
|
||||||
Some(uuids[1].clone()),
|
Some(uuids[1]),
|
||||||
Some(uuids[3].clone()),
|
Some(uuids[3]),
|
||||||
Some(uuids[4].clone())
|
Some(uuids[4])
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -144,19 +144,19 @@ mod test {
|
|||||||
// to the top, and then uuids[0] is added.
|
// to the top, and then uuids[0] is added.
|
||||||
vec![
|
vec![
|
||||||
None,
|
None,
|
||||||
Some(uuids[1].clone()),
|
Some(uuids[1]),
|
||||||
Some(uuids[4].clone()),
|
Some(uuids[4]),
|
||||||
Some(uuids[0].clone()),
|
Some(uuids[0]),
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
// uuids[1] and uuids[4] are already in the working set, at indexes 1 and 3,
|
// uuids[1] and uuids[4] are already in the working set, at indexes 1 and 3,
|
||||||
// and then uuids[0] is added.
|
// and then uuids[0] is added.
|
||||||
vec![
|
vec![
|
||||||
None,
|
None,
|
||||||
Some(uuids[1].clone()),
|
Some(uuids[1]),
|
||||||
None,
|
None,
|
||||||
Some(uuids[4].clone()),
|
Some(uuids[4]),
|
||||||
Some(uuids[0].clone()),
|
Some(uuids[0]),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user