pub struct RepoFetchDetector {
pub threshold: usize,
/* private fields */
}Expand description
Detects repeated HTTP fetches from the same GitHub repository and suggests cloning it locally once the fetch count exceeds a threshold.
Fields§
§threshold: usizeMinimum number of fetches before a suggestion is emitted.
Implementations§
Source§impl RepoFetchDetector
impl RepoFetchDetector
Sourcepub fn new(threshold: usize) -> Self
pub fn new(threshold: usize) -> Self
Construct a detector with the given threshold.
A threshold of 3 means a suggestion is emitted on the third fetch
from the same repository.
Sourcepub fn record_fetch(&mut self, url: &str)
pub fn record_fetch(&mut self, url: &str)
Record a single HTTP fetch from url.
Recognised URL patterns:
raw.githubusercontent.com/<owner>/<repo>/…github.com/<owner>/<repo>/blob/…
Unrecognised URLs are silently ignored.
Sourcepub fn should_suggest(&self, owner_repo: &str) -> bool
pub fn should_suggest(&self, owner_repo: &str) -> bool
Return true if the fetch count for owner_repo meets or exceeds the threshold.
Sourcepub fn suggestions(&self) -> Vec<String>
pub fn suggestions(&self) -> Vec<String>
Return clone suggestions for every repository that has reached the threshold.
Trait Implementations§
Source§impl Clone for RepoFetchDetector
impl Clone for RepoFetchDetector
Source§fn clone(&self) -> RepoFetchDetector
fn clone(&self) -> RepoFetchDetector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RepoFetchDetector
impl RefUnwindSafe for RepoFetchDetector
impl Send for RepoFetchDetector
impl Sync for RepoFetchDetector
impl Unpin for RepoFetchDetector
impl UnsafeUnpin for RepoFetchDetector
impl UnwindSafe for RepoFetchDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more