Skip to content

Commit 08c18ed

Browse files
committed
docs: unify docs for callback types and functions that set callbacks
This was motivated by the observations that: - The [`PushNegotiation` docstring] was previously much more informative than the docstring for `push_negotiation`. - The `PushNegotiation` docstring does not seem to be accessible via https://docs.rs/git2/0.18.3/git2/index.html. Only the less helpful docstring is accessible at https://docs.rs/git2/0.18.3/git2/struct.RemoteCallbacks.html#method.push_negotiation. [`PushNegotiation` docstring]: 920c838#diff-ccd8cf48c67bd6cc71379f93a6b51abdb10954497a0db353908a7cf20995ef61R92-R99
1 parent 5a5c86d commit 08c18ed

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/remote_callbacks.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ pub type PushTransferProgress<'a> = dyn FnMut(usize, usize, usize) + 'a;
8383

8484
/// Callback for pack progress
8585
///
86+
/// Be aware that this is called inline with pack building operations,
87+
/// so performance may be affected.
88+
///
8689
/// Parameters:
8790
/// * stage
8891
/// * current
8992
/// * total
9093
pub type PackProgress<'a> = dyn FnMut(PackBuilderStage, usize, usize) + 'a;
9194

92-
/// Callback used to inform of upcoming updates.
95+
/// The callback is called once between the negotiation step and the upload.
9396
///
9497
/// The argument is a slice containing the updates which will be sent as
9598
/// commands to the destination.
@@ -204,6 +207,11 @@ impl<'a> RemoteCallbacks<'a> {
204207
}
205208

206209
/// The callback through which progress of push transfer is monitored
210+
///
211+
/// Parameters:
212+
/// * current
213+
/// * total
214+
/// * bytes
207215
pub fn push_transfer_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
208216
where
209217
F: FnMut(usize, usize, usize) + 'a,
@@ -213,8 +221,14 @@ impl<'a> RemoteCallbacks<'a> {
213221
}
214222

215223
/// Function to call with progress information during pack building.
224+
///
216225
/// Be aware that this is called inline with pack building operations,
217226
/// so performance may be affected.
227+
///
228+
/// Parameters:
229+
/// * stage
230+
/// * current
231+
/// * total
218232
pub fn pack_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
219233
where
220234
F: FnMut(PackBuilderStage, usize, usize) + 'a,
@@ -224,7 +238,11 @@ impl<'a> RemoteCallbacks<'a> {
224238
}
225239

226240
/// The callback is called once between the negotiation step and the upload.
227-
/// It provides information about what updates will be performed.
241+
///
242+
/// The argument to the callback is a slice containing the updates which
243+
/// will be sent as commands to the destination.
244+
///
245+
/// The push is cancelled if the callback returns an error.
228246
pub fn push_negotiation<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
229247
where
230248
F: FnMut(&[PushUpdate<'_>]) -> Result<(), Error> + 'a,

0 commit comments

Comments
 (0)