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 methods
    fn write_stream(
        &self,
        kind: ObjectKind,
        size: u64,
        reader: &mut dyn Read,
        options: WriteOptions,
    ) -> Result<ObjectId> { ... }
    fn flush(&self) -> Result<()> { ... }
    fn flush_for_publish(&self) -> Result<()> { ... }
    fn rollback(&self) -> Result<()> { ... }
}
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.

Source

fn flush(&self) -> Result<()>

Make prior successful Self::write calls durable (commit a transaction, fsync, …).

Grit calls this after bulk ingest and before ref updates that publish new commits. Reads on this store must observe every write that returned Ok even before Self::flush; flush is the durability barrier for crash recovery.

Default is a no-op. Do not flush automatically from Self::write; backends batch many writes between flush calls.

§Errors

Propagates backend persistence failures.

Source

fn flush_for_publish(&self) -> Result<()>

Like Self::flush, but rolls back the current batch when flush fails.

§Errors

Propagates flush failures after attempting Self::rollback.

Source

fn rollback(&self) -> Result<()>

Discard unflushed writes from the current batch after a failed ingest or similar.

Default is a no-op. After a successful Self::flush, rollback is a no-op.

§Errors

Propagates backend failures while aborting the batch.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: WritableObjectStore + ?Sized> WritableObjectStore for &T

Source§

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

Source§

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

Source§

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

Source§

fn flush(&self) -> Result<()>

Source§

fn flush_for_publish(&self) -> Result<()>

Source§

fn rollback(&self) -> Result<()>

Source§

impl<T: WritableObjectStore + ?Sized> WritableObjectStore for Arc<T>

Source§

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

Source§

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

Source§

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

Source§

fn flush(&self) -> Result<()>

Source§

fn flush_for_publish(&self) -> Result<()>

Source§

fn rollback(&self) -> Result<()>

Source§

impl<T: WritableObjectStore + ?Sized> WritableObjectStore for Box<T>

Source§

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

Source§

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

Source§

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

Source§

fn flush(&self) -> Result<()>

Source§

fn flush_for_publish(&self) -> Result<()>

Source§

fn rollback(&self) -> Result<()>

Implementors§