Skip to content

Commit fbd6f1a

Browse files
committed
Add top level docs to the tags api
1 parent bee5bfa commit fbd6f1a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/rpc/client/tags.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22
//!
33
//! The purpose of tags is to mark information as important to prevent it
44
//! from being garbage-collected (if the garbage collector is turned on).
5-
//! Currently this is used for blobs.
65
//!
7-
//! The main entry point is the [`Client`].
6+
//! A tag has a name that is an arbitrary byte string. In many cases this will be
7+
//! a valid UTF8 string, but there are also use cases where it is useful to have
8+
//! non string data like integer ids in the tag name.
9+
//!
10+
//! Tags point to a [`HashAndFormat`].
11+
//!
12+
//! A tag can point to a hash with format [`BlobFormat::Raw`]. In that case it will
13+
//! protect *just this blob* from being garbage-collected.
814
//!
9-
//! [`Client::list`] can be used to list all tags.
10-
//! [`Client::list_hash_seq`] can be used to list all tags with a hash_seq format.
15+
//! It can also point to a hash in format [`BlobFormat::HashSeq`]. In that case it will
16+
//! protect the blob itself and all hashes in the blob (the blob must be just a sequence of hashes).
17+
//! Using this format it is possible to protect a large number of blobs with a single tag.
1118
//!
12-
//! [`Client::delete`] can be used to delete a tag.
19+
//! Tags can be created, read, renamed and deleted. Tags *do not* have to correspond to
20+
//! already existing data. It is perfectly valid to create a tag for data you don't have yet.
21+
//!
22+
//! The main entry point is the [`Client`].
1323
use std::ops::{Bound, RangeBounds};
1424

1525
use anyhow::Result;
@@ -221,9 +231,9 @@ where
221231
stream.next().await.transpose()
222232
}
223233

224-
/// Rename a tag
234+
/// Rename a tag atomically
225235
///
226-
/// This is done in steps, so it is not atomic!
236+
/// If the tag does not exist, this will return an error.
227237
pub async fn rename(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<()> {
228238
let from = from.as_ref();
229239
let to = to.as_ref();

0 commit comments

Comments
 (0)