Skip to main content

MmapDiskIo

Struct MmapDiskIo 

Source
pub struct MmapDiskIo { /* private fields */ }
Expand description

Memory-mapped disk I/O backend with no user-space cache.

Relies entirely on the kernel page cache via mmap. All reads and writes go directly to storage with no write buffering.

Implementations§

Source§

impl MmapDiskIo

Source

pub fn new() -> Self

Create a new mmap disk I/O backend.

Trait Implementations§

Source§

impl Default for MmapDiskIo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DiskIoBackend for MmapDiskIo

Source§

fn name(&self) -> &'static str

Human-readable backend name (e.g., “posix”, “mmap”, “disabled”).
Source§

fn register(&self, info_hash: Id20, storage: Arc<dyn TorrentStorage>)

Register a torrent’s storage for I/O operations.
Source§

fn unregister(&self, info_hash: Id20)

Unregister a torrent’s storage.
Source§

fn write_chunk( &self, info_hash: Id20, piece: u32, begin: u32, data: Bytes, _flush: bool, ) -> Result<()>

Write a chunk of piece data. If flush is true, persist immediately. Read more
Source§

fn read_chunk( &self, info_hash: Id20, piece: u32, begin: u32, length: u32, _volatile: bool, ) -> Result<Bytes>

Read a chunk of piece data. volatile hints the data won’t be re-read soon. Read more
Source§

fn read_piece(&self, info_hash: Id20, piece: u32) -> Result<Vec<u8>>

Read an entire piece from storage, returning its raw bytes. Read more
Source§

fn hash_piece( &self, info_hash: Id20, piece: u32, expected: &Id20, ) -> Result<bool>

Verify a piece against its expected SHA-1 hash. Read more
Source§

fn hash_piece_v2( &self, info_hash: Id20, piece: u32, expected: &Id32, ) -> Result<bool>

Verify a piece against its expected SHA-256 hash (BEP 52). Read more
Source§

fn hash_block( &self, info_hash: Id20, piece: u32, begin: u32, length: u32, ) -> Result<Id32>

Compute SHA-256 hash of a single block within a piece (BEP 52 Merkle). Read more
Source§

fn clear_piece(&self, _info_hash: Id20, _piece: u32)

Discard buffered data for a piece (e.g., after hash failure).
Source§

fn flush_piece(&self, _info_hash: Id20, _piece: u32) -> Result<()>

Flush buffered writes for a piece to persistent storage. Read more
Source§

fn flush_all(&self) -> Result<()>

Flush all buffered writes across all torrents. Read more
Source§

fn cached_pieces(&self, _info_hash: Id20) -> Vec<u32>

Return piece indices currently held in cache (for SuggestPiece, M44).
Source§

fn stats(&self) -> DiskIoStats

Return current I/O statistics.
Source§

fn write_block_direct( &self, info_hash: Id20, piece: u32, begin: u32, s0: &[u8], s1: &[u8], ) -> Result<()>

Write a block directly to storage from two slices (vectored write). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more