pub trait ModuleReader: Send + Sync {
// Required methods
fn len(&self) -> u64;
fn read_at<'life0, 'async_trait>(
&'life0 self,
offset: u64,
len: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, DownloadError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Random-access read over the module bytes a pull has staged — the seam the anchor gate sees
INSTEAD of a &[u8] of the whole module (#1610).
A &[u8] parameter forced the puller to hold the entire module in RAM before it could ask the one
question that decides the pull, so peak RSS was the module size and a small host simply could not
reshare a large capsule. Behind this trait the same gate reads the staging area on demand, so peak
RSS is one chunk.
§What an implementation MUST guarantee
Every byte this reader returns is already chunk-hash-verified against the descriptor, and the
readable window is exactly the total_size the whole-module-hash gate has already accepted — the
gate never sees an unverified or out-of-window byte (StagedModuleReader is this crate’s
implementation and enforces both).
Required Methods§
Sourcefn read_at<'life0, 'async_trait>(
&'life0 self,
offset: u64,
len: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_at<'life0, 'async_trait>(
&'life0 self,
offset: u64,
len: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, DownloadError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read the [offset, offset + len) window of the module.
§Errors
DownloadError::Sink when the window falls outside the module or the staged bytes cannot be
read back / no longer match the descriptor’s chunk hashes. A read error is never “zeroes”: the
caller MUST treat it as a failure to verify, never as absent content.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".