pub struct DiskHandle { /* private fields */ }Expand description
Per-torrent handle for async disk I/O.
Implementations§
Source§impl DiskHandle
impl DiskHandle
Sourcepub fn set_hash_pool(&mut self, pool: Arc<HashPool>)
pub fn set_hash_pool(&mut self, pool: Arc<HashPool>)
Set the hash pool reference (M96).
Sourcepub fn set_hash_result_tx(&mut self, tx: Sender<HashResult>)
pub fn set_hash_result_tx(&mut self, tx: Sender<HashResult>)
Set the per-torrent hash result sender (M96).
Sourcepub async fn write_chunk(
&self,
piece: u32,
begin: u32,
data: Bytes,
flags: DiskJobFlags,
) -> Result<()>
pub async fn write_chunk( &self, piece: u32, begin: u32, data: Bytes, flags: DiskJobFlags, ) -> Result<()>
Write a chunk to disk (may be buffered).
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn read_chunk(
&self,
piece: u32,
begin: u32,
length: u32,
flags: DiskJobFlags,
) -> Result<Bytes>
pub async fn read_chunk( &self, piece: u32, begin: u32, length: u32, flags: DiskJobFlags, ) -> Result<Bytes>
Read a chunk from disk (may hit cache or write buffer).
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn verify_piece(
&self,
piece: u32,
expected: Id20,
flags: DiskJobFlags,
) -> Result<bool>
pub async fn verify_piece( &self, piece: u32, expected: Id20, flags: DiskJobFlags, ) -> Result<bool>
Verify a piece hash against an expected value.
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn verify_piece_v2(
&self,
piece: u32,
expected: Id32,
flags: DiskJobFlags,
) -> Result<bool>
pub async fn verify_piece_v2( &self, piece: u32, expected: Id32, flags: DiskJobFlags, ) -> Result<bool>
Verify a piece hash against an expected SHA-256 value (v2).
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn hash_block(
&self,
piece: u32,
begin: u32,
length: u32,
flags: DiskJobFlags,
) -> Result<Id32>
pub async fn hash_block( &self, piece: u32, begin: u32, length: u32, flags: DiskJobFlags, ) -> Result<Id32>
Hash a single block with SHA-256 for Merkle verification (v2).
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn clear_piece(&self, piece: u32)
pub async fn clear_piece(&self, piece: u32)
Clear a piece from cache and write buffer (e.g. on hash failure).
Sourcepub async fn flush_piece(&self, piece: u32) -> Result<()>
pub async fn flush_piece(&self, piece: u32) -> Result<()>
Flush a specific piece from the write buffer to disk.
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub async fn cached_pieces(&self) -> Vec<u32>
pub async fn cached_pieces(&self) -> Vec<u32>
Query which pieces are currently in the read cache for this torrent.
Sourcepub async fn flush_cache(&self) -> Result<()>
pub async fn flush_cache(&self) -> Result<()>
Flush all buffered writes to persistent storage.
§Errors
Returns an error if the disk I/O fails or the disk actor is gone.
Sourcepub fn enqueue_verify(
&self,
piece: u32,
expected: Id20,
generation: u64,
result_tx: &Sender<VerifyResult>,
)
pub fn enqueue_verify( &self, piece: u32, expected: Id20, generation: u64, result_tx: &Sender<VerifyResult>, )
Spawn a non-blocking v1 piece hash verification.
M96: If a hash pool is configured, submits the job to the pool.
M101: Uses HashJob::Streaming to delegate reading + hashing to the
backend, eliminating the full-piece allocation on the caller side.
The generation parameter enables staleness detection by the caller.
Sourcepub fn enqueue_verify_v2(
&self,
piece: u32,
expected: Id32,
result_tx: &Sender<VerifyResult>,
)
pub fn enqueue_verify_v2( &self, piece: u32, expected: Id32, result_tx: &Sender<VerifyResult>, )
Spawn a non-blocking v2 piece hash verification (SHA-256).
Reads the piece from disk via the backend’s read_piece() method.
Trait Implementations§
Source§impl Clone for DiskHandle
impl Clone for DiskHandle
Source§fn clone(&self) -> DiskHandle
fn clone(&self) -> DiskHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more