Skip to main content

ObjectReader

Trait ObjectReader 

Source
pub trait ObjectReader {
    // Required methods
    fn blob(
        &self,
        rev: &str,
        path: &[u8],
    ) -> Result<Option<Vec<u8>>, EngineError>;
    fn blobs(
        &self,
        specs: &[(&str, &[u8])],
    ) -> Result<Vec<Option<Vec<u8>>>, EngineError>;
    fn require_object(&self, oid: &str) -> Result<(), EngineError>;
}
Expand description

Reading objects out of the odb.

Required Methods§

Source

fn blob(&self, rev: &str, path: &[u8]) -> Result<Option<Vec<u8>>, EngineError>

Blob content at rev:path, with path kept as raw bytes.

Ok(None) when the path does not exist at that revision. Any other failure is a real error — an absent file and a broken repository must never render identically.

Source

fn blobs( &self, specs: &[(&str, &[u8])], ) -> Result<Vec<Option<Vec<u8>>>, EngineError>

The same, for several specs at once, answered in the order given.

Reading a blob costs a process, and a process costs milliseconds — so a caller that already knows every file it is about to draw should say so rather than paying that per file. Measured on a 120-file range: 240 one-at-a-time reads took a second, against one call for the lot (ADR 0021’s “what is left is process spawns”).

Bulk is the SAME need as blob, not a different one, which is why it sits on this port rather than earning its own.

Source

fn require_object(&self, oid: &str) -> Result<(), EngineError>

Assert oid is present in the odb.

Invariant 1 verifies binary files this way, since they carry no hunks to reconstruct from. Deliberately not -> Result<bool>: a recorded oid missing from the odb is a broken repository, not a failed invariant.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§