Skip to main content

ObjectSource

Trait ObjectSource 

Source
pub trait ObjectSource: Send + Sync {
    // Required methods
    fn objects<'a>(
        &'a self,
        commit: &'a Checksum,
    ) -> BoxFuture<'a, Result<Vec<ObjectName>>>;
    fn open<'a>(
        &'a self,
        name: &'a ObjectName,
        encoding: Encoding,
    ) -> BoxFuture<'a, Result<ObjectData>>;
    fn detached_metadata<'a>(
        &'a self,
        commit: &'a Checksum,
    ) -> BoxFuture<'a, Result<Option<Value>>>;

    // Provided methods
    fn detached_metadata_encoded<'a>(
        &'a self,
        commit: &'a Checksum,
    ) -> BoxFuture<'a, Result<Option<DetachedMetadata>>> { ... }
    fn content_size<'a>(
        &'a self,
        names: &'a [ObjectName],
        encoding: Encoding,
    ) -> BoxFuture<'a, Result<Option<u64>>> { ... }
}
Expand description

A source of the objects that a session sends.

Required Methods§

Source

fn objects<'a>( &'a self, commit: &'a Checksum, ) -> BoxFuture<'a, Result<Vec<ObjectName>>>

Returns the name of each object that commit reaches, and of the commit.

No session method calls objects. A caller gives the list to missing to find the objects to send.

§Errors

The error depends on the implementation:

Source

fn open<'a>( &'a self, name: &'a ObjectName, encoding: Encoding, ) -> BoxFuture<'a, Result<ObjectData>>

Returns the data of the object name.

encoding is the encoding in which the session sends the object: deflate for a content object if the session deflates, and raw for all other objects. A source that holds the object in that encoding can give its bytes as ObjectData::Encoded.

§Errors

An error of the source stops the object stream. send and export_stream return it as Error::Source.

Source

fn detached_metadata<'a>( &'a self, commit: &'a Checksum, ) -> BoxFuture<'a, Result<Option<Value>>>

Returns the detached metadata for commit, an a{sv} dict.

The source applies its own filter first. For None, the session sends no detached metadata for commit. DetachedMetadata gives the checks of the dict.

The session calls this method only through the default implementation of detached_metadata_encoded. A source that overrides that method must still implement this one.

§Errors

An error of the source stops the object stream. send and export_stream return it as Error::Source.

Provided Methods§

Source

fn detached_metadata_encoded<'a>( &'a self, commit: &'a Checksum, ) -> BoxFuture<'a, Result<Option<DetachedMetadata>>>

Returns the detached metadata for commit, as a dict or as its bytes.

The session sends the detached metadata of each commit through this method. The default implementation calls detached_metadata and gives its dict as DetachedMetadata::Dict. A source that holds the bytes of the dict can give them as DetachedMetadata::Encoded.

For None, the session sends no detached metadata for commit. DetachedMetadata gives the checks of each form.

§Errors

An error of the source stops the object stream. send and export_stream return it as Error::Source.

Source

fn content_size<'a>( &'a self, names: &'a [ObjectName], encoding: Encoding, ) -> BoxFuture<'a, Result<Option<u64>>>

Returns the content bytes of the file objects of names in encoding.

None means that the source does not know the number. The names that are not file objects count no byte. The default implementation returns None.

The content bytes of one file object are the bytes that the session reads from the reader that open gives for it with the same encoding:

If the session has a PushProgress and names holds at least one file object, each send call and each export_stream call asks once, before the first object. The call adds the answer to bytes_total.

The method must not read the content of an object. It reads what the source already holds, or the metadata of each object.

§Errors

The session treats an error as None. The call adds nothing to the total and sends the objects.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§