1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Rust client library for the Hugging Face Xet storage system.
//!
//! Xet is the storage backend used by the [Hugging Face Hub](https://huggingface.co) for
//! large files. Files are split into variable-size chunks, deduplicated, and stored in CAS
//! (Content-Addressed Storage) server. This crate provides a high-level
//! API for uploading and downloading those files.
//!
//! # Getting started
//!
//! All operations go through [`xet_session::XetSession`], which manages a
//! tokio runtime and shared HTTP settings. Create one with
//! [`XetSessionBuilder`](xet_session::XetSessionBuilder), then use it to
//! build upload commits or download groups:
//!
//! ```rust,no_run
//! use xet::xet_session::{Sha256Policy, XetFileInfo, XetSessionBuilder};
//!
//! # fn example() -> Result<(), xet::xet_session::SessionError> {
//! let session = XetSessionBuilder::new().build()?;
//!
//! // Upload a file
//! let commit = session
//! .new_upload_commit()?
//! .with_endpoint("https://cas.example.com")
//! .with_token_info("write-token", 1_700_000_000)
//! .build_blocking()?;
//! let handle = commit.upload_from_path_blocking("file.bin".into(), Sha256Policy::Compute)?;
//! let report = commit.commit_blocking()?;
//!
//! // Download a file using the metadata from the upload
//! let meta = report.uploads.values().next().unwrap();
//! let group = session
//! .new_file_download_group()?
//! .with_token_info("read-token", 1_700_000_000)
//! .build_blocking()?;
//! group.download_file_to_path_blocking(meta.xet_info.clone(), "out/file.bin".into())?;
//! group.finish_blocking()?;
//! # Ok(())
//! # }
//! ```
//!
//! See the [`xet_session`] module for the full API, including async
//! variants, streaming uploads and downloads, and progress tracking.
//!
//! # Modules
//!
//! - [`xet_session`] — the primary API: [`XetSession`](xet_session::XetSession), upload commits, file download groups,
//! and streaming downloads.
//! - [`error`] — [`XetError`], the unified error type for the public API.
pub use XetError;
pub use ;
// Legacy helpers re-exported for backward compatibility with `hf_xet` (Python bindings)
// and `git_xet`. New code should use the [`xet_session`] API instead.