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§
Sourcefn write(
&self,
kind: ObjectKind,
data: &[u8],
options: WriteOptions,
) -> Result<ObjectId>
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.
Provided Methods§
Sourcefn write_stream(
&self,
kind: ObjectKind,
size: u64,
reader: &mut dyn Read,
options: WriteOptions,
) -> Result<ObjectId>
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.
Sourcefn flush(&self) -> Result<()>
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.
Sourcefn flush_for_publish(&self) -> Result<()>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".