#
alpm/
sync.rs

    1use crate::{Alpm, AlpmList, AlpmListMut, AsAlpmList, Db, Package, Result};
    2
    3use std::ffi::CString;
    4
    5use alpm_sys::*;
    6
    7impl Package {
    8    pub fn sync_new_version<'a, T: AsAlpmList<&'a Db>>(&self, dbs: T) -> Option<&'a Package> {
    9        dbs.with(|dbs| {
    10            let ret = unsafe { alpm_sync_get_new_version(self.as_ptr(), dbs.as_ptr()) };
    11
    12            if ret.is_null() {
    13                None
    14            } else {
    15                unsafe { Some(Package::from_ptr(ret)) }
    16            }
    17        })
    18    }
    19
    20    pub fn download_size(&self) -> i64 {
    21        let size = unsafe { alpm_pkg_download_size(self.as_ptr()) };
    22        size as i64
    23    }
    24}
    25
    26impl Alpm {
    27    pub fn find_group_pkgs<'a, S: Into<Vec<u8>>>(
    28        &'a self,
    29        dbs: AlpmList<&Db>,
    30        s: S,
    31    ) -> AlpmListMut<&'a Package> {
    32        let name = CString::new(s).unwrap();
    33        let ret = unsafe { alpm_find_group_pkgs(dbs.as_ptr(), name.as_ptr()) };
    34        unsafe { AlpmListMut::from_ptr(ret) }
    35    }
    36}
    37
    38impl Alpm {
    39    pub fn sync_sysupgrade(&self, enable_downgrade: bool) -> Result<()> {
    40        let ret = unsafe { alpm_sync_sysupgrade(self.as_ptr(), enable_downgrade as _) };
    41        self.check_ret(ret)
    42    }
    43}