Skip to content

Commit cc19efa

Browse files
committed
ffi: fix clippy
1 parent 604408e commit cc19efa

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ precommit:
22
cargo fmt --all -- --config format_code_in_doc_comments=true
33
cargo clippy -p negentropy && cargo clippy -p negentropy --no-default-features
44
cargo test -p negentropy && cargo test -p negentropy --no-default-features
5+
cargo build -p negentropy-ffi && cargo clippy -p negentropy-ffi && cargo test -p negentropy-ffi
56

67
bench:
78
RUSTFLAGS='--cfg=bench' cargo +nightly bench -p negentropy

negentropy-ffi/src/bytes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ impl From<negentropy::Bytes> for Bytes {
2525
impl Bytes {
2626
pub fn new(bytes: Vec<u8>) -> Self {
2727
Self {
28-
inner: negentropy::Bytes::new(bytes)
28+
inner: negentropy::Bytes::new(bytes),
2929
}
3030
}
3131

3232
pub fn from_hex(data: String) -> Result<Self> {
3333
Ok(Self {
34-
inner: negentropy::Bytes::from_hex(data)?
34+
inner: negentropy::Bytes::from_hex(data)?,
3535
})
3636
}
3737

@@ -42,4 +42,4 @@ impl Bytes {
4242
pub fn as_bytes(&self) -> Vec<u8> {
4343
self.inner.as_bytes().to_vec()
4444
}
45-
}
45+
}

negentropy-ffi/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ impl From<negentropy::Error> for NegentropyError {
2222
fn from(e: negentropy::Error) -> Self {
2323
Self::Generic { err: e.to_string() }
2424
}
25-
}
25+
}

negentropy-ffi/src/lib.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use std::sync::Arc;
66

77
use parking_lot::RwLock;
88

9-
mod error;
109
mod bytes;
10+
mod error;
1111

12-
use self::error::Result;
1312
pub use self::bytes::Bytes;
1413
pub use self::error::NegentropyError;
14+
use self::error::Result;
1515

1616
pub struct ReconcileWithIds {
1717
pub have_ids: Vec<Arc<Bytes>>,
@@ -26,7 +26,10 @@ pub struct Negentropy {
2626
impl Negentropy {
2727
pub fn new(id_size: u8, frame_size_limit: Option<u64>) -> Result<Self> {
2828
Ok(Self {
29-
inner: RwLock::new(negentropy::Negentropy::new(id_size as usize, frame_size_limit)?)
29+
inner: RwLock::new(negentropy::Negentropy::new(
30+
id_size as usize,
31+
frame_size_limit,
32+
)?),
3033
})
3134
}
3235

@@ -67,25 +70,24 @@ impl Negentropy {
6770

6871
pub fn reconcile(&self, query: Arc<Bytes>) -> Result<Arc<Bytes>> {
6972
let mut negentropy = self.inner.write();
70-
Ok(Arc::new(negentropy.reconcile(query.as_ref().deref())?.into()))
73+
Ok(Arc::new(
74+
negentropy.reconcile(query.as_ref().deref())?.into(),
75+
))
7176
}
7277

73-
pub fn reconcile_with_ids(
74-
&self,
75-
query: Arc<Bytes>,
76-
) -> Result<ReconcileWithIds> {
78+
pub fn reconcile_with_ids(&self, query: Arc<Bytes>) -> Result<ReconcileWithIds> {
7779
let mut negentropy = self.inner.write();
7880
let mut have_ids: Vec<negentropy::Bytes> = Vec::new();
7981
let mut need_ids: Vec<negentropy::Bytes> = Vec::new();
80-
let output: Option<negentropy::Bytes> = negentropy.reconcile_with_ids(query.as_ref().deref(), &mut have_ids, &mut need_ids)?;
81-
Ok(ReconcileWithIds {
82-
have_ids: have_ids.into_iter().map(|id| Arc::new(id.into())).collect(),
83-
need_ids: need_ids.into_iter().map(|id| Arc::new(id.into())).collect(),
84-
output: output.map(|o| Arc::new(o.into()))
82+
let output: Option<negentropy::Bytes> =
83+
negentropy.reconcile_with_ids(query.as_ref().deref(), &mut have_ids, &mut need_ids)?;
84+
Ok(ReconcileWithIds {
85+
have_ids: have_ids.into_iter().map(|id| Arc::new(id.into())).collect(),
86+
need_ids: need_ids.into_iter().map(|id| Arc::new(id.into())).collect(),
87+
output: output.map(|o| Arc::new(o.into())),
8588
})
8689
}
8790
}
8891

89-
9092
// UDL
9193
uniffi::include_scaffolding!("negentropy");

0 commit comments

Comments
 (0)