Skip to main content

WritableObjectStore

Trait WritableObjectStore 

Source
pub trait WritableObjectStore: ObjectStore {
    // Required methods
    fn write(
        &self,
        kind: ObjectKind,
        data: &[u8],
        options: WriteOptions,
    ) -> Result<ObjectId>;
    fn freshen(&self, oid: &ObjectId) -> Result<bool>;

    // Provided method
    fn write_stream(
        &self,
        kind: ObjectKind,
        size: u64,
        reader: &mut dyn Read,
        options: WriteOptions,
    ) -> Result<ObjectId> { ... }
}
Expand description

Object storage that supports inserting new objects.

Required Methods§

Source

fn write( &self, kind: ObjectKind, data: &[u8], options: WriteOptions, ) -> Result<ObjectId>

Store canonical object bytes and return the object id.

If the object already exists, returns the existing id without replacing stored bytes (Git loose-store idempotence).

§Errors

Returns I/O, hashing, or validation errors from the backend.

Source

fn freshen(&self, oid: &ObjectId) -> Result<bool>

Mark oid as recently used so retention policies keep it (Git freshen).

Returns true when the object was present and the backend recorded the touch.

§Errors

Propagates backend failures.

Provided Methods§

Source

fn write_stream( &self, kind: ObjectKind, size: u64, reader: &mut dyn Read, options: WriteOptions, ) -> Result<ObjectId>

Store an object from a byte stream of known uncompressed size.

Default implementation reads the stream into memory and calls Self::write.

§Errors

Same as Self::write, plus stream read failures.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§