pub trait DelegateBlocking {
// Required method
fn negotiate(
&mut self,
refs: &[Ref],
arguments: &mut Arguments,
previous_response: Option<&Response>,
) -> Result<Action>;
// Provided methods
fn handshake_extra_parameters(&self) -> Vec<(String, Option<String>)> { ... }
fn prepare_ls_refs(
&mut self,
_server: &Capabilities,
_arguments: &mut Vec<BString>,
_features: &mut Vec<(&str, Option<Cow<'_, str>>)>,
) -> Result<Action> { ... }
fn prepare_fetch(
&mut self,
_version: Protocol,
_server: &Capabilities,
_features: &mut Vec<(&str, Option<Cow<'_, str>>)>,
_refs: &[Ref],
) -> Result<Action> { ... }
}
blocking-client
or async-client
only.Expand description
Required Methods§
sourcefn negotiate(
&mut self,
refs: &[Ref],
arguments: &mut Arguments,
previous_response: Option<&Response>,
) -> Result<Action>
fn negotiate( &mut self, refs: &[Ref], arguments: &mut Arguments, previous_response: Option<&Response>, ) -> Result<Action>
A method called repeatedly to negotiate the objects to receive in receive_pack(…)
.
The first call has previous_response
set to None
as there was no previous response. Every call that follows previous_response
will be set to Some
.
§If previous_response
is None
…
Given a list of arguments
to populate with wants, want-refs, shallows, filters and other contextual information to be
sent to the server. This method is called once.
Send the objects you have
have afterwards based on the tips of your refs, in preparation to walk down their parents
with each call to negotiate
to find the common base(s).
Note that you should not want
and object that you already have.
refs
are the tips of on the server side, effectively the latest objects they have.
Return Action::Close
if you know that there are no haves
on your end to allow the server to send all of its objects
as is the case during initial clones.
§If previous_response
is Some
…
Populate arguments
with the objects you have
starting from the tips of your refs, taking into consideration
the previous_response
response of the server to see which objects they acknowledged to have. You have to maintain
enough state to be able to walk down from your tips on each call, if they are not in common, and keep setting have
for those which are in common if that helps teaching the server about our state and to acknowledge their existence on their end.
This method is called until the other side signals they are ready to send a pack.
Return Action::Close
if you want to give up before finding a common base. This can happen if the remote repository
has radically changed so there are no bases, or they are very far in the past, causing all objects to be sent.
Provided Methods§
sourcefn handshake_extra_parameters(&self) -> Vec<(String, Option<String>)>
fn handshake_extra_parameters(&self) -> Vec<(String, Option<String>)>
Return extra parameters to be provided during the handshake.
Note that this method is only called once and the result is reused during subsequent handshakes which may happen if there is an authentication failure.
sourcefn prepare_ls_refs(
&mut self,
_server: &Capabilities,
_arguments: &mut Vec<BString>,
_features: &mut Vec<(&str, Option<Cow<'_, str>>)>,
) -> Result<Action>
fn prepare_ls_refs( &mut self, _server: &Capabilities, _arguments: &mut Vec<BString>, _features: &mut Vec<(&str, Option<Cow<'_, str>>)>, ) -> Result<Action>
Called before invoking ‘ls-refs’ on the server to allow providing it with additional arguments
and to enable features
.
If the server capabilities
don’t match the requirements abort with an error to abort the entire fetch operation.
Note that some arguments are preset based on typical use, and features
are preset to maximize options.
The server
capabilities can be used to see which additional capabilities the server supports as per the handshake which happened prior.
If the delegate returns ls_refs::Action::Skip
, no ls-refs
command is sent to the server.
Note that this is called only if we are using protocol version 2.
sourcefn prepare_fetch(
&mut self,
_version: Protocol,
_server: &Capabilities,
_features: &mut Vec<(&str, Option<Cow<'_, str>>)>,
_refs: &[Ref],
) -> Result<Action>
fn prepare_fetch( &mut self, _version: Protocol, _server: &Capabilities, _features: &mut Vec<(&str, Option<Cow<'_, str>>)>, _refs: &[Ref], ) -> Result<Action>
Called before invoking the ‘fetch’ interaction with features
pre-filled for typical use
and to maximize capabilities to allow aborting an interaction early.
refs
is a list of known references on the remote based on the handshake or a prior call to ls_refs
.
These can be used to abort early in case the refs are already known here.
As there will be another call allowing to post arguments conveniently in the correct format, i.e. want hex-oid
,
there is no way to set arguments at this time.
version
is the actually supported version as reported by the server, which is relevant in case the server requested a downgrade.
server
capabilities is a list of features the server supports for your information, along with enabled features
that the server knows about.