Skip to main content

librqbit_core/
error.rs

1#[derive(thiserror::Error, Debug)]
2pub enum Error {
3    #[error("expected multi-file torrent to have at least one file")]
4    BadTorrentMultiFileEmpty,
5    #[error("torrent has a file with no name")]
6    BadTorrentFileNoName,
7    #[error("torrent can't be both in single and multi-file mode")]
8    BadTorrentBothSingleAndMultiFile,
9    #[error("path traversal detected, \"..\" in filename")]
10    BadTorrentPathTraversal,
11    #[error("suspicious separator in filename")]
12    BadTorrentSeparatorInName,
13    #[error("torrent with 0 length is useless")]
14    BadTorrentZeroLength,
15    #[error("invalid piece index {0}")]
16    InvalidPieceIndex(u32),
17    #[error("no files in torrent")]
18    BadTorrentNoFiles,
19    #[error("duplicate filenames in torrent")]
20    BadTorrentDuplicateFilenames,
21    #[error("empty filename in torrent")]
22    BadTorrentEmptyFilename,
23
24    // BEP 52 (v2) errors
25    #[error("v2 torrent missing file_tree")]
26    V2MissingFileTree,
27    #[error("v2 torrent file_tree root must be a directory, not a file")]
28    V2FileTreeRootIsFile,
29    #[error("v2 file_tree has \".\" path component")]
30    V2FileTreeDotComponent,
31    #[error("v2 torrent missing meta_version")]
32    V2MissingMetaVersion,
33    #[error("unsupported meta_version: {0}")]
34    V2UnsupportedMetaVersion(u32),
35    #[error("v2 torrent missing piece_layers")]
36    V2MissingPieceLayers,
37    #[error("v2 piece_layers missing entry for file: {0}")]
38    V2MissingPieceLayersEntry(String),
39    #[error("v2 piece_layers entry has wrong size: expected {expected}, got {actual}")]
40    V2PieceLayersWrongSize { expected: usize, actual: usize },
41    #[error("v2 piece_layers count mismatch: expected {expected}, got {actual}")]
42    V2PieceLayerCountMismatch { expected: usize, actual: usize },
43    #[error("v2 piece_layers merkle root mismatch for file")]
44    V2PieceLayersRootMismatch,
45    #[error("v2 small file should not have piece_layers entry")]
46    V2SmallFileShouldNotHavePieceLayers,
47    #[error("v2 small file missing pieces_root")]
48    V2SmallFileMissingPiecesRoot,
49    #[error("v2 zero-length file should not have pieces_root")]
50    V2ZeroLengthFileHasPiecesRoot,
51    #[error("invalid v2 piece length {0}: must be power of two and >= 16384")]
52    V2InvalidPieceLength(u32),
53    #[error("invalid v2 torrent: has meta_version but no pieces and no file_tree")]
54    V2InvalidTorrent,
55    #[error("v2 hybrid file list mismatch: {0}")]
56    V2HybridFileListMismatch(String),
57}