Struct git_protocol::RemoteProgress
source · pub struct RemoteProgress<'a> {
pub action: &'a BStr,
pub percent: Option<u32>,
pub step: Option<usize>,
pub max: Option<usize>,
}
Expand description
The information usually found in remote progress messages as sent by a git server during fetch, clone and push operations.
Fields§
§action: &'a BStr
The name of the action, like “clone”.
percent: Option<u32>
The percentage to indicate progress, between 0 and 100.
step: Option<usize>
The amount of items already processed.
max: Option<usize>
The maximum expected amount of items. step
/ max
* 100 = percent
.
Implementations§
source§impl<'a> RemoteProgress<'a>
impl<'a> RemoteProgress<'a>
sourcepub fn from_bytes(line: &[u8]) -> Option<RemoteProgress<'_>>
pub fn from_bytes(line: &[u8]) -> Option<RemoteProgress<'_>>
Parse the progress from a typical git progress line
as sent by the remote.
Examples found in repository?
src/remote_progress.rs (line 57)
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
pub fn translate_to_progress(is_error: bool, text: &[u8], progress: &mut impl git_features::progress::Progress) {
fn progress_name(current: Option<String>, action: &[u8]) -> String {
match current {
Some(current) => format!(
"{}: {}",
current.split_once(':').map_or(&*current, |x| x.0),
action.as_bstr()
),
None => action.as_bstr().to_string(),
}
}
if is_error {
// ignore keep-alive packages sent with 'sideband-all'
if !text.is_empty() {
progress.fail(progress_name(None, text));
}
} else {
match RemoteProgress::from_bytes(text) {
Some(RemoteProgress {
action,
percent: _,
step,
max,
}) => {
progress.set_name(progress_name(progress.name(), action));
progress.init(max, git_features::progress::count("objects"));
if let Some(step) = step {
progress.set(step);
}
}
None => progress.set_name(progress_name(progress.name(), text)),
};
}
}
sourcepub fn translate_to_progress(
is_error: bool,
text: &[u8],
progress: &mut impl Progress
)
pub fn translate_to_progress(
is_error: bool,
text: &[u8],
progress: &mut impl Progress
)
Parse text
, which is interpreted as error if is_error
is true, as RemoteProgress
and call the respective
methods on the given progress
instance.
Examples found in repository?
src/fetch_fn.rs (line 165)
157 158 159 160 161 162 163 164 165 166 167 168
fn setup_remote_progress<P>(progress: &mut P, reader: &mut Box<dyn git_transport::client::ExtendedBufRead + Unpin + '_>)
where
P: Progress,
P::SubProgress: 'static,
{
reader.set_progress_handler(Some(Box::new({
let mut remote_progress = progress.add_child("remote");
move |is_err: bool, data: &[u8]| {
crate::RemoteProgress::translate_to_progress(is_err, data, &mut remote_progress)
}
}) as git_transport::client::HandleProgress));
}
Trait Implementations§
source§impl<'a> Clone for RemoteProgress<'a>
impl<'a> Clone for RemoteProgress<'a>
source§fn clone(&self) -> RemoteProgress<'a>
fn clone(&self) -> RemoteProgress<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a> Debug for RemoteProgress<'a>
impl<'a> Debug for RemoteProgress<'a>
source§impl<'de: 'a, 'a> Deserialize<'de> for RemoteProgress<'a>
impl<'de: 'a, 'a> Deserialize<'de> for RemoteProgress<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a> Hash for RemoteProgress<'a>
impl<'a> Hash for RemoteProgress<'a>
source§impl<'a> Ord for RemoteProgress<'a>
impl<'a> Ord for RemoteProgress<'a>
source§fn cmp(&self, other: &RemoteProgress<'a>) -> Ordering
fn cmp(&self, other: &RemoteProgress<'a>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<'a> PartialEq<RemoteProgress<'a>> for RemoteProgress<'a>
impl<'a> PartialEq<RemoteProgress<'a>> for RemoteProgress<'a>
source§fn eq(&self, other: &RemoteProgress<'a>) -> bool
fn eq(&self, other: &RemoteProgress<'a>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialOrd<RemoteProgress<'a>> for RemoteProgress<'a>
impl<'a> PartialOrd<RemoteProgress<'a>> for RemoteProgress<'a>
source§fn partial_cmp(&self, other: &RemoteProgress<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &RemoteProgress<'a>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more