Skip to content

Commit 83998d7

Browse files
committed
clippy
1 parent 34f915a commit 83998d7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/rpc/client/tags.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use serde::{Deserialize, Serialize};
1919

2020
use crate::{
2121
rpc::proto::{
22-
tags::{DeleteRequest, ListRequest},
22+
tags::{DeleteRequest, ListRequest, SetRequest, SyncMode},
2323
RpcService,
2424
},
25-
BlobFormat, Hash, Tag,
25+
BlobFormat, Hash, HashAndFormat, Tag,
2626
};
2727

2828
/// Iroh tags client.
@@ -179,12 +179,25 @@ where
179179
Ok(stream.map(|res| res.map_err(anyhow::Error::from)))
180180
}
181181

182+
/// Set the value for a single tag
183+
pub async fn set(&self, name: impl AsRef<[u8]>, value: impl Into<HashAndFormat>) -> Result<()> {
184+
self.rpc
185+
.rpc(SetRequest {
186+
name: Tag::from(name.as_ref()),
187+
value: value.into(),
188+
batch: None,
189+
sync: SyncMode::Full,
190+
})
191+
.await??;
192+
Ok(())
193+
}
194+
182195
/// Get the value of a single tag
183196
pub async fn get(&self, name: impl AsRef<[u8]>) -> Result<Option<TagInfo>> {
184197
let mut stream = self
185198
.list_with_opts(ListOptions::single(name.as_ref()))
186199
.await?;
187-
Ok(stream.next().await.transpose()?)
200+
stream.next().await.transpose()
188201
}
189202

190203
/// List a range of tags

0 commit comments

Comments
 (0)