pub trait Transport: Send + Sync {
// Required methods
fn upload_pack(&self, bytes: &[u8], key: &PackKey) -> TransportResult<()>;
fn download_pack(&self, key: &PackKey) -> TransportResult<Vec<u8>>;
fn pack_exists(&self, key: &PackKey) -> TransportResult<bool>;
fn update_ref(
&self,
name: &str,
condition: RefWriteCondition,
hash: &Hash,
) -> TransportResult<()>;
fn read_ref(&self, name: &str) -> TransportResult<Option<Hash>>;
fn list_refs(&self, prefix: &str) -> TransportResult<Vec<Ref>>;
// Provided method
fn write_ref(&self, name: &str, hash: &Hash) -> TransportResult<()> { ... }
}Expand description
The mkit transport vtable.
Every transport (memory, file, HTTP, S3, SSH) implements this trait.
Methods are synchronous and take &self; transports that need
interior mutability (e.g. connection pools) MUST use a Mutex /
RwLock internally. This keeps the trait object-safe.
All implementations MUST honour the retry policy in
SPEC-TRANSPORT §7 internally OR document that the caller is
responsible — the abstract trait takes no position. The
is_retryable and BackoffIterator helpers are provided for
implementations that embed the policy.
Required Methods§
Sourcefn upload_pack(&self, bytes: &[u8], key: &PackKey) -> TransportResult<()>
fn upload_pack(&self, bytes: &[u8], key: &PackKey) -> TransportResult<()>
Upload a pack. The digest is computed by the caller (BLAKE3 of the full pack bytes) and used as the object key — servers MAY dedupe on this key.
Sourcefn download_pack(&self, key: &PackKey) -> TransportResult<Vec<u8>>
fn download_pack(&self, key: &PackKey) -> TransportResult<Vec<u8>>
Download a pack by its digest.
Returns TransportError::PackNotFound if the remote does not
hold this digest.
Sourcefn pack_exists(&self, key: &PackKey) -> TransportResult<bool>
fn pack_exists(&self, key: &PackKey) -> TransportResult<bool>
HEAD-check a pack. Cheaper than Self::download_pack on
network transports.
Sourcefn update_ref(
&self,
name: &str,
condition: RefWriteCondition,
hash: &Hash,
) -> TransportResult<()>
fn update_ref( &self, name: &str, condition: RefWriteCondition, hash: &Hash, ) -> TransportResult<()>
CAS ref write. See RefWriteCondition.
On .missing / .match CAS failure, returns
TransportError::RefConflict. Callers retrying after a
timeout MUST follow up with Self::read_ref to confirm
whether the first attempt actually landed (SPEC-TRANSPORT §7).
Provided Methods§
Sourcefn write_ref(&self, name: &str, hash: &Hash) -> TransportResult<()>
fn write_ref(&self, name: &str, hash: &Hash) -> TransportResult<()>
Unconditional ref write — equivalent to
update_ref(name, RefWriteCondition::Any, hash).
Default impl delegates to Self::update_ref so transports only
implement one entry point.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".