aur_fetch

Struct Fetch

Source
pub struct Fetch {
    pub clone_dir: PathBuf,
    pub diff_dir: PathBuf,
    pub git: PathBuf,
    pub git_flags: Vec<String>,
    pub aur_url: Url,
}
Expand description

Handle to the current configuration.

This handle is used to configure parts of the fetching process. All the features of this crate must be done through this handle.

Fields§

§clone_dir: PathBuf

The directory to place AUR packages in.

§diff_dir: PathBuf

The directory to place diffs in.

§git: PathBuf

The git command to run.

§git_flags: Vec<String>

Flags passed to git.

§aur_url: Url

The AUR URL.

Implementations§

Source§

impl Fetch

Source

pub fn new() -> Result<Self>

Create a new Handle with working defaults.

This Inializes the clone and diff dir to the current dirrectory. If you want to configure a cache directory you will need to do that yourself.

Source

pub fn with_cache_dir<P: AsRef<Path>>(path: P) -> Self

Create a new handle with a specified cache dir.

clone_dir will be a subdirectory named clone inside of the specified path. diff_dir will be a subdirectory named diff inside of the specified path.

Source

pub fn with_combined_cache_dir<P: AsRef<Path>>(path: P) -> Self

Create a new handle with a specified cache dir.

Both diffs and cloned packages will be places in the provided dir.

Source

pub fn download<S: AsRef<str> + Send + Sync>( &self, pkgs: &[S], ) -> Result<Vec<String>>

Downloads a list of packages to the cache dir.

This downloads packages from the AUR using git. New packages will be cloned, while packages that already exist in cache will be fetched. Merging will need to be done in a separate step.

Each package is downloaded concurrently which givess a major speedup

Depending on how many packages are being downloaded and connection speed this function may take a little while to complete. See download_cb if you wish track the progress of each download.

This also filters the input list to packages that were already in cache. This filtered list can then be passed on to merge as freshly cloned packages will not need to be merged.

Source

pub fn download_cb<S: AsRef<str> + Send + Sync, F: Fn(Callback<'_>)>( &self, pkgs: &[S], f: F, ) -> Result<Vec<String>>

The same as download but calls a Callback after each download.

The callback is called each time a package download is completed.

Source

pub fn download_repos<F: Fn(Callback<'_>)>( &self, repos: &[Repo], ) -> Result<Vec<String>>

The same as download but downloads a specified list of repos instead of AUR packages.

Source

pub fn download_repos_cb<F: Fn(Callback<'_>)>( &self, repos: &[Repo], f: F, ) -> Result<Vec<String>>

The same as download_repos but calls a Callback after each download.

The callback is called each time a package download is completed.

Source

pub fn has_diff<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>

Filters a list of packages, keep ones that have a diff.

A reoo has a diff if AUR_SEEN is defined and is different to the upstram HEAD.

Source

pub fn unseen<'a, S: AsRef<str>>(&self, pkgs: &'a [S]) -> Result<Vec<&'a str>>

Filterrs a list of packages, keeping ones that have not yet been seen.

A repo is seen if AUR_SEEN exists and is equal to the upstram HEAD.

Source

pub fn diff<S: AsRef<str>>( &self, pkgs: &[S], color: bool, ) -> Result<Vec<String>>

Diff a list of packages returning the diffs as strings.

Diffing a package that is already up to date will generate a diff against an empty git tree

Additionally this function gives you the ability to force color. This is useful if you intend to print the diffs to stdout.

Source

pub fn print_diff<S: AsRef<str>>(&self, pkg: S) -> Result<()>

Diff a single package.

Relies on git diff for printing. This means output will likley be coloured and ran through less. Although this is dependent on the user’s git config

Source

pub fn save_diffs<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>

Diff a list of packages and save them to diff_dir.

Diffing a package that is already up to date will generate a diff against an empty git tree

Source

pub fn make_view<P: AsRef<Path>, S1: AsRef<str>, S2: AsRef<str>>( &self, dir: P, pkgs: &[S1], diffs: &[S2], ) -> Result<()>

Makes a view of newly downloaded files.

This view is a dir containing the packages downloaded/fetched and diffs for packages that have diffs.

Files are symlinked from the cache dirs so there is no duplication of files.

Source

pub fn merge<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>

Merge a list of packages with their upstream.

Source

pub fn merge_cb<S: AsRef<str>, F: Fn(Callback<'_>)>( &self, pkgs: &[S], cb: F, ) -> Result<()>

Merge a list of packages with their upstream, calling callback for each merge.

Source

pub fn mark_seen<S: AsRef<str>>(&self, pkgs: &[S]) -> Result<()>

Marks a list of repos as seen.

This updates AUR_SEEN to the upstream HEAD

Source

pub fn commit<S1: AsRef<str>, S2: AsRef<str>>( &self, pkgs: &[S1], message: S2, ) -> Result<()>

Commits changes to list of packages

This is intended to allow saving changes made by the user after reviewing.

Source

pub fn is_git_repo<S: AsRef<str>>(&self, pkg: S) -> bool

Check if a package is already cloned.

Trait Implementations§

Source§

impl Clone for Fetch

Source§

fn clone(&self) -> Fetch

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Fetch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Fetch

§

impl RefUnwindSafe for Fetch

§

impl Send for Fetch

§

impl Sync for Fetch

§

impl Unpin for Fetch

§

impl UnwindSafe for Fetch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T