Skip to content

Commit b4ec938

Browse files
haecker-felixbilelmoussaoui
authored andcommitted
service: Simplify code by using new_collection func
1 parent bc615db commit b4ec938

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

client/src/dbus/service.rs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,11 @@ impl<'a> Service<'a> {
100100
///
101101
/// Applications should make use of [`Service::default_collection`] instead.
102102
pub async fn with_alias(&self, alias: &str) -> Result<Option<Collection<'a>>, Error> {
103-
Ok(self.inner.read_alias(alias).await?.map(|collection| {
104-
Collection::new(
105-
Arc::clone(&self.inner),
106-
Arc::clone(&self.session),
107-
self.algorithm,
108-
collection,
109-
self.aes_key.clone(), // Cheap clone, it is an Arc,
110-
)
111-
}))
103+
Ok(self
104+
.inner
105+
.read_alias(alias)
106+
.await?
107+
.map(|collection| self.new_collection(collection)))
112108
}
113109

114110
/// Get a list of all the available collections.
@@ -118,15 +114,7 @@ impl<'a> Service<'a> {
118114
.collections()
119115
.await?
120116
.into_iter()
121-
.map(|collection| {
122-
Collection::new(
123-
Arc::clone(&self.inner),
124-
Arc::clone(&self.session),
125-
self.algorithm,
126-
collection,
127-
self.aes_key.clone(), // Cheap clone, it is an Arc,
128-
)
129-
})
117+
.map(|collection| self.new_collection(collection))
130118
.collect::<Vec<_>>())
131119
}
132120

@@ -142,15 +130,7 @@ impl<'a> Service<'a> {
142130
self.inner
143131
.create_collection(label, alias)
144132
.await
145-
.map(|collection| {
146-
Collection::new(
147-
Arc::clone(&self.inner),
148-
Arc::clone(&self.session),
149-
self.algorithm,
150-
collection,
151-
self.aes_key.clone(), // Cheap clone, it is an Arc,
152-
)
153-
})
133+
.map(|collection| self.new_collection(collection))
154134
}
155135

156136
/// Find a collection with it label.

0 commit comments

Comments
 (0)