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 65 66 67 68 69 70
use error::{TorrentError, BlockError}; use memory::block::{Block, BlockMut}; use bip_metainfo::Metainfo; use bip_util::bt::{InfoHash}; pub mod builder; pub mod manager; pub mod fs; mod tasks; //----------------------------------------------------------------------------// /// Messages that can be sent to the `DiskManager`. #[derive(Debug)] pub enum IDiskMessage { /// Message to add a torrent to the disk manager. AddTorrent(Metainfo), /// Message to remove a torrent from the disk manager. /// /// Note, this will NOT remove any data from the `FileSystem`, /// and as an added convenience, this message will also trigger /// a `IDiskMessage::SyncTorrent` message. RemoveTorrent(InfoHash), /// Message to tell the `FileSystem` to sync the torrent. /// /// This message will trigger a call to `FileSystem::sync` for every /// file in the torrent, so the semantics will differ depending on the /// `FileSystem` in use. /// /// In general, if a torrent has finished downloading, but will be kept /// in the `DiskManager` to, for example, seed the torrent, then this /// message should be sent, otherwise, `IDiskMessage::RemoveTorrent` is /// sufficient. SyncTorrent(InfoHash), /// Message to load the given block in to memory. LoadBlock(BlockMut), /// Message to process the given block and persist it. ProcessBlock(Block) } /// Messages that can be received from the `DiskManager`. #[derive(Debug)] pub enum ODiskMessage { /// Message indicating that the torrent has been added. /// /// Any good pieces already existing for the torrent will be sent /// as `FoundGoodPiece` messages BEFORE this message is sent. TorrentAdded(InfoHash), /// Message indicating that the torrent has been removed. TorrentRemoved(InfoHash), /// Message indicating that the torrent has been synced. TorrentSynced(InfoHash), /// Message indicating that a good piece has been identified for /// the given torrent (hash), as well as the piece index. FoundGoodPiece(InfoHash, u64), /// Message indicating that a bad piece has been identified for /// the given torrent (hash), as well as the piece index. FoundBadPiece(InfoHash, u64), /// Message indicating that the given block has been loaded. BlockLoaded(BlockMut), /// Message indicating that the given block has been processed. BlockProcessed(Block), /// Error occurring from a `AddTorrent` or `RemoveTorrent` message. TorrentError(InfoHash, TorrentError), /// Error occurring from a `LoadBlock` message. LoadBlockError(BlockMut, BlockError), /// Error occurring from a `ProcessBlock` message. ProcessBlockError(Block, BlockError) }