Skip to content

Commit

Permalink
docs: unify docs for callback types and functions that set callbacks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ilyagr committed Apr 14, 2024
1 parent 5a5c86d commit 08c18ed
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/remote_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ pub type PushTransferProgress<'a> = dyn FnMut(usize, usize, usize) + 'a;

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

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

/// The callback through which progress of push transfer is monitored
///
/// Parameters:
/// * current
/// * total
/// * bytes
pub fn push_transfer_progress<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a>
where
F: FnMut(usize, usize, usize) + 'a,
Expand All @@ -213,8 +221,14 @@ impl<'a> RemoteCallbacks<'a> {
}

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

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

0 comments on commit 08c18ed

Please sign in to comment.