Trait EntityRead

Source
pub trait EntityRead: Entity {
    type CustomReadError: Debug + Error;

    // Provided methods
    fn last_git_commit(
        replica: &Replica,
        id: EntityId<Self>,
    ) -> Result<ObjectId, Error> { ... }
    fn breadth_first_search(
        repo: &Repository,
        root_id: ObjectId,
    ) -> Result<Vec<Commit<'_>>, Error> { ... }
    fn read(replica: &Replica, id: EntityId<Self>) -> Result<Self, Error<Self>>
       where Self: Sized { ... }
}
Expand description

Extension trait for Entities.

These functions are responsible for reading and writing the Entity to the git repository.

Required Associated Types§

Source

type CustomReadError: Debug + Error

An error that can be used to add to the default Error in read.

Defining this is only really useful, if you override the default read method. Otherwise, you can set this to std::convert::Infallible (we would do this here, but default associated types are not stable yet).

Provided Methods§

Source

fn last_git_commit( replica: &Replica, id: EntityId<Self>, ) -> Result<ObjectId, Error>

Get the commit associated with the last entry of this Entity's Operations.

Conceptually, this just resolves the git reference at refs/Self::NAMESPACE/id.

§Errors

If the reference could not be resolved (e.g., it was missing.)

A breadth-first search to get a topological order of the Operations DAG where we discover the parents commit and go back in time up to the chronological root

§Errors

If one of the git Ids has no commit object attached to it.

Source

fn read(replica: &Replica, id: EntityId<Self>) -> Result<Self, Error<Self>>
where Self: Sized,

Fetch this Entity from a git repository and decode it.

§Errors

If the associated git operations fail.

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.

Implementors§