Skip to content

Commit c3454fe

Browse files
authored
Merge pull request #1044 from ilyagr/docs
Improve docs for PushUpdate, push_negotiation, plus a bit more
2 parents 04427a3 + 9c9305e commit c3454fe

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/push_update.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ impl PushUpdate<'_> {
2828
unsafe { crate::opt_bytes(self, (*self.raw).src_refname).unwrap() }
2929
}
3030

31-
/// Returns the source name of the reference.
31+
/// Returns the source name of the reference, or None if it is not valid UTF-8.
3232
pub fn src_refname(&self) -> Option<&str> {
3333
str::from_utf8(self.src_refname_bytes()).ok()
3434
}
3535

36-
/// Returns the destination name of the reference as a byte slice.
36+
/// Returns the name of the reference to update on the server as a byte slice.
3737
pub fn dst_refname_bytes(&self) -> &[u8] {
3838
unsafe { crate::opt_bytes(self, (*self.raw).dst_refname).unwrap() }
3939
}
4040

41-
/// Returns the destination name of the reference.
41+
/// Returns the name of the reference to update on the server, or None if it is not valid UTF-8.
4242
pub fn dst_refname(&self) -> Option<&str> {
4343
str::from_utf8(self.dst_refname_bytes()).ok()
4444
}

src/remote_callbacks.rs

+26-8
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,23 @@ pub type PushUpdateReference<'a> = dyn FnMut(&str, Option<&str>) -> Result<(), E
7676
/// Callback for push transfer progress
7777
///
7878
/// Parameters:
79-
/// * current
80-
/// * total
81-
/// * bytes
79+
/// * current
80+
/// * total
81+
/// * bytes
8282
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:
87-
/// * stage
88-
/// * current
89-
/// * total
90+
/// * stage
91+
/// * current
92+
/// * 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)