Skip to main content

ArchiveWrite

Trait ArchiveWrite 

Source
pub trait ArchiveWrite: Send + Sync {
    // Required methods
    fn append(&self, bytes: &[u8]) -> Result<Extent>;
    fn name(&self) -> &'static str;
    fn durability(&self) -> &'static str;
    fn blobs_shared(&self) -> Option<Arc<File>>;
}
Expand description

Append pushed packfile bytes to an archive, verbatim.

One trait, three durability contracts. The implementation decides when append is allowed to return; it never decides what the bytes are.

Required Methods§

Source

fn append(&self, bytes: &[u8]) -> Result<Extent>

Append these bytes and return when this implementation’s durability contract is met. Returns the byte extent written.

The bytes are stored exactly as handed over: no compression, no framing, no re-encoding. The returned (offset, len) addresses them inside the archive’s blob region and is the only thing that goes to the indexer.

Source

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

Name it on a bench row.

Source

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

One-line statement of what a crash immediately after append returns does to the bytes. On the bench table next to the throughput, because a throughput without this is not a comparison.

Source

fn blobs_shared(&self) -> Option<Arc<File>>

This arm’s open file description on the blob file, for the readers in the same process.

Every arm opens the file once, read/write, through [open_blobs]; a reader preads at an explicit offset and shares no cursor with append, so handing the same description out is a descriptor saved and nothing else changed. It is on the trait rather than on the three concrete types because the one caller that matters — crate::indexer::PushPath::with_absorber — holds a Box<dyn ArchiveWrite> and would otherwise have to open its own.

None is reserved for an arm that has no such file. There is none today, and an arm that returns it gets its own handle rather than an error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§