Skip to main content

Write

Trait Write 

Source
pub trait Write {
    // Required methods
    fn write_buf_with_known_id(
        &self,
        object: Kind,
        from: &[u8],
        id: ObjectId,
    ) -> Result<ObjectId, Error>;
    fn write_stream(
        &self,
        kind: Kind,
        size: u64,
        from: &mut dyn Read,
    ) -> Result<ObjectId, Error>;
    fn write_stream_with_known_id(
        &self,
        kind: Kind,
        size: u64,
        from: &mut dyn Read,
        id: ObjectId,
    ) -> Result<ObjectId, Error>;

    // Provided methods
    fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error> { ... }
    fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error> { ... }
}
Expand description

Describe the capability to write git objects into an object store.

Required Methods§

Source

fn write_buf_with_known_id( &self, object: Kind, from: &[u8], id: ObjectId, ) -> Result<ObjectId, Error>

As write_buf, but the object id has already been computed by the caller.

Implementations may trust the given id and avoid computing it again. Callers must make sure id matches the provided object and from bytes.

Source

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

As write, but takes an input stream. This is commonly used for writing blobs directly without reading them to memory first.

Source

fn write_stream_with_known_id( &self, kind: Kind, size: u64, from: &mut dyn Read, id: ObjectId, ) -> Result<ObjectId, Error>

As write_stream, but the object id has already been computed by the caller.

Implementations may trust the given id and avoid computing it again. Callers must make sure id matches the provided kind, size and stream contents.

Provided Methods§

Source

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Write objects using the intrinsic kind of hash into the database, returning id to reference it in subsequent reads.

Source

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

As write, but takes an object kind along with its encoded bytes.

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> Write for &T
where T: Write,

Source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Source§

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

Source§

fn write_buf_with_known_id( &self, object: Kind, from: &[u8], id: ObjectId, ) -> Result<ObjectId, Error>

Source§

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

Source§

fn write_stream_with_known_id( &self, kind: Kind, size: u64, from: &mut dyn Read, id: ObjectId, ) -> Result<ObjectId, Error>

Source§

impl<T> Write for Arc<T>
where T: Write,

Source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Source§

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

Source§

fn write_buf_with_known_id( &self, object: Kind, from: &[u8], id: ObjectId, ) -> Result<ObjectId, Error>

Source§

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

Source§

fn write_stream_with_known_id( &self, kind: Kind, size: u64, from: &mut dyn Read, id: ObjectId, ) -> Result<ObjectId, Error>

Source§

impl<T> Write for Rc<T>
where T: Write,

Source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

Source§

fn write_buf(&self, object: Kind, from: &[u8]) -> Result<ObjectId, Error>

Source§

fn write_buf_with_known_id( &self, object: Kind, from: &[u8], id: ObjectId, ) -> Result<ObjectId, Error>

Source§

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

Source§

fn write_stream_with_known_id( &self, kind: Kind, size: u64, from: &mut dyn Read, id: ObjectId, ) -> Result<ObjectId, Error>

Implementors§