pub trait CandidateBytes {
// Required method
fn candidate_bytes(
&mut self,
candidate: &Candidate,
) -> Result<Rc<[u8]>, CandidateError>;
}Expand description
What:
Where a scan pass reads candidate bytes.
A trait is an interface.
Why:
The candidate store reads the version’s objects;
a direct fix reads the same
objects with its in-memory corrections laid over them,
and its later passes
must scan the corrected bytes.
In TS you’d write (pseudocode):
interface CandidateBytes { bytes(candidate: Candidate): Promise<Uint8Array> }Required Methods§
Sourcefn candidate_bytes(
&mut self,
candidate: &Candidate,
) -> Result<Rc<[u8]>, CandidateError>
fn candidate_bytes( &mut self, candidate: &Candidate, ) -> Result<Rc<[u8]>, CandidateError>
What: The bytes the candidate holds for this reader. Why: the scan’s only input.
In TS you’d write (pseudocode):
bytes(candidate: Candidate): Promise<Uint8Array>; // throws CandidateErrorDyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl CandidateBytes for CandidateStore
What:
impl CandidateBytes for CandidateStore reads through the store itself.
Why:
Without corrections the store’s objects are the bytes to scan.
In TS you’d write (pseudocode):
class CandidateStore implements CandidateBytes {}