pub trait Negotiator {
// Required methods
fn known_common(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<(), Error>;
fn add_tip(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<(), Error>;
fn next_have(
&mut self,
graph: &mut Graph<'_, '_>,
) -> Option<Result<ObjectId, Error>>;
fn in_common_with_remote(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<bool, Error>;
}
Expand description
A delegate to implement a negotiation algorithm.
Required Methods§
sourcefn known_common(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<(), Error>
fn known_common( &mut self, id: ObjectId, graph: &mut Graph<'_, '_>, ) -> Result<(), Error>
Mark id
as common between the remote and us.
These ids are typically the local tips of remote tracking branches.
sourcefn add_tip(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<(), Error>
fn add_tip( &mut self, id: ObjectId, graph: &mut Graph<'_, '_>, ) -> Result<(), Error>
Add id
as starting point of a traversal across commits that aren’t necessarily common between the remote and us.
These tips are usually the commits of local references whose tips should lead to objects that we have in common with the remote.
sourcefn next_have(
&mut self,
graph: &mut Graph<'_, '_>,
) -> Option<Result<ObjectId, Error>>
fn next_have( &mut self, graph: &mut Graph<'_, '_>, ) -> Option<Result<ObjectId, Error>>
Produce the next id of an object that we want the server to know we have. It’s an object we don’t know we have in common or not.
Returns None
if we have exhausted all options, which might mean we have traversed the entire commit graph.
sourcefn in_common_with_remote(
&mut self,
id: ObjectId,
graph: &mut Graph<'_, '_>,
) -> Result<bool, Error>
fn in_common_with_remote( &mut self, id: ObjectId, graph: &mut Graph<'_, '_>, ) -> Result<bool, Error>
Mark id
as being common with the remote (as informed by the remote itself) and return true
if we knew it was common already.
We can assume to have already seen id
as we were the one to inform the remote in a prior have
.