Skip to content

Commit

Permalink
format and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Mar 13, 2024
1 parent 55119a5 commit f3af52a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/examples/z_get_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn main() {
.unwrap();
while let Ok(reply) = replies.recv_async().await {
match reply.sample {
Ok(sample) => println!(">> Alive token ('{}')", sample.key_expr.as_str(),),
Ok(sample) => println!(">> Alive token ('{}')", sample.key_expr().as_str(),),
Err(err) => {
let payload = err
.payload
Expand Down
6 changes: 3 additions & 3 deletions examples/examples/z_sub_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ async fn main() {
select!(
sample = subscriber.recv_async() => {
let sample = sample.unwrap();
match sample.kind {
match sample.kind() {
SampleKind::Put => println!(
">> [LivelinessSubscriber] New alive token ('{}')",
sample.key_expr.as_str()),
sample.key_expr().as_str()),
SampleKind::Delete => println!(
">> [LivelinessSubscriber] Dropped token ('{}')",
sample.key_expr.as_str()),
sample.key_expr().as_str()),
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ impl AlignQueryable {
let entry = entry.unwrap();
result.push(AlignData::Data(
OwnedKeyExpr::from(entry.key_expr().clone()),
(
Value::from(entry),
each.timestamp,
),
(Value::from(entry), each.timestamp),
));
}
}
Expand Down
5 changes: 1 addition & 4 deletions plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ impl Aligner {
for sample in replies {
result.insert(
sample.key_expr().clone().into(),
(
sample.timestamp().unwrap().clone(),
Value::from(sample),
),
(*sample.timestamp().unwrap(), Value::from(sample)),
);
}
(result, no_err)
Expand Down
29 changes: 12 additions & 17 deletions plugins/zenoh-plugin-storage-manager/src/replica/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl StorageService {
}

let matching_keys = if sample.key_expr().is_wild() {
self.get_matching_keys(&sample.key_expr()).await
self.get_matching_keys(sample.key_expr()).await
} else {
vec![sample.key_expr().clone().into()]
};
Expand Down Expand Up @@ -309,20 +309,15 @@ impl StorageService {
let Value {
payload, encoding, ..
} = overriding_update.data.value;
let sample_to_store = Sample::new(KeyExpr::from(k.clone()), payload)
Sample::new(KeyExpr::from(k.clone()), payload)
.with_encoding(encoding)
.with_timestamp(overriding_update.data.timestamp)
.with_kind(overriding_update.kind);
sample_to_store
}
None => {
let sample_to_store =
Sample::new(KeyExpr::from(k.clone()), sample.payload().clone())
.with_encoding(sample.encoding().clone())
.with_timestamp(sample.timestamp().unwrap().clone())
.with_kind(sample.kind());
sample_to_store
.with_kind(overriding_update.kind)
}
None => Sample::new(KeyExpr::from(k.clone()), sample.payload().clone())
.with_encoding(sample.encoding().clone())
.with_timestamp(*sample.timestamp().unwrap())
.with_kind(sample.kind()),
};

let stripped_key = match self.strip_prefix(sample_to_store.key_expr()) {
Expand All @@ -340,16 +335,16 @@ impl StorageService {
stripped_key,
Value::new(sample_to_store.payload().clone())
.with_encoding(sample_to_store.encoding().clone()),
sample_to_store.timestamp().unwrap().clone(),
*sample_to_store.timestamp().unwrap(),
)
.await
}
SampleKind::Delete => {
// register a tombstone
self.mark_tombstone(&k, sample_to_store.timestamp().unwrap().clone())
self.mark_tombstone(&k, *sample_to_store.timestamp().unwrap())
.await;
storage
.delete(stripped_key, sample_to_store.timestamp().unwrap().clone())
.delete(stripped_key, *sample_to_store.timestamp().unwrap())
.await
}
};
Expand All @@ -363,7 +358,7 @@ impl StorageService {
.as_ref()
.unwrap()
.log_propagation
.send((k.clone(), sample_to_store.timestamp().unwrap().clone()));
.send((k.clone(), *sample_to_store.timestamp().unwrap()));
match sending {
Ok(_) => (),
Err(e) => {
Expand Down Expand Up @@ -398,7 +393,7 @@ impl StorageService {
// @TODO: change into a better store that does incremental writes
let key = sample.key_expr().clone();
let mut wildcards = self.wildcard_updates.write().await;
let timestamp = sample.timestamp().unwrap().clone();
let timestamp = *sample.timestamp().unwrap();
wildcards.insert(
&key,
Update {
Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl MergeQueue {

fn push(&mut self, sample: Sample) {
if let Some(ts) = sample.timestamp() {
self.timstamped.entry(ts.clone()).or_insert(sample);
self.timstamped.entry(*ts).or_insert(sample);
} else {
self.untimestamped.push_back(sample);
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh/tests/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ fn pubsub() {
task::sleep(SLEEP).await;

ztimeout!(publisher1.put("qos").res_async()).unwrap();
let qos = ztimeout!(subscriber.recv_async()).unwrap().qos().clone();
let qos = *ztimeout!(subscriber.recv_async()).unwrap().qos();

assert_eq!(qos.priority(), Priority::DataHigh);
assert_eq!(qos.congestion_control(), CongestionControl::Drop);

ztimeout!(publisher2.put("qos").res_async()).unwrap();
let qos = ztimeout!(subscriber.recv_async()).unwrap().qos().clone();
let qos = *ztimeout!(subscriber.recv_async()).unwrap().qos();

assert_eq!(qos.priority(), Priority::DataLow);
assert_eq!(qos.congestion_control(), CongestionControl::Block);
Expand Down

0 comments on commit f3af52a

Please sign in to comment.