Trait Write

Source
pub trait Write {
    type Error: Error + From<Error>;

    // Required method
    fn write_stream(
        &self,
        kind: Kind,
        size: u64,
        from: impl Read,
    ) -> Result<ObjectId, Self::Error>;

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

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

Required Associated Types§

Source

type Error: Error + From<Error>

The error type used for all trait methods.

Note the default implementations require the From<io::Error> bound.

Required Methods§

Source

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

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

Provided Methods§

Source

fn write(&self, object: impl WriteTo) -> Result<ObjectId, Self::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, Self::Error>

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

type Error = <T as Write>::Error

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Error = <T as Write>::Error

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Error = <T as Write>::Error

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl Write for Store

Source§

impl Write for Sink

Source§

impl<S> Write for Handle<S>
where S: Deref<Target = Store> + Clone,

Source§

impl<S> Write for Cache<S>
where S: Write,

Source§

type Error = <S as Write>::Error