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
60
61
62
63
64
//! Peer-to-peer and swarm file transfer over Iroh/QUIC.
//!
//! Share a file or folder and get a share code; anyone with the code can
//! download it. Files are split into 64 KiB pieces, each verified against a
//! BLAKE3/Bao hash as it arrives, and pulled from every peer in the swarm at
//! once. Downloaders serve what they have to each other (reseeding), and with
//! a data dir, downloads resume after a restart.
//!
//! ```no_run
//! # async fn demo() -> chorrent::Result<()> {
//! // Seeder
//! let client = chorrent::Client::new().await?;
//! let seed = client.seed("holiday-photos/").await?;
//! println!("share this: {}", seed.share_code());
//!
//! // Downloader (another process or machine)
//! let client = chorrent::Client::new().await?;
//! let code: chorrent::ShareCode = "chr2...".parse()?;
//! let download = client.download(&code, None).await?;
//! let mut events = download.events(); // progress, peers, ...
//! let done = download.finished().await?;
//! if let Some(path) = &done.path {
//! println!("saved to {}", path.display());
//! }
//! # Ok(()) }
//! ```
/// Error types. [`Error`] is the one most callers need.
pub use ;
pub use ;
pub use Event;
/// Re-exported so embedding apps name the same types (keep your iroh
/// dependency semver-compatible with chorrent's).
pub use ;
pub use ;
pub use ShareCode;
pub use SavedTransfer;
/// The ALPN chorrent's protocol uses; see [`Client::alpns`] for the full list.
pub const ALPN: & = ALPN;
/// Size of one piece, in bytes.
pub const PIECE_SIZE: u64 = BLOCK_SIZE.bytes as u64;