use super::package::RawPackage;
#[cxx::bridge]
pub mod raw {
pub struct Cache {
ptr: UniquePtr<PkgCacheFile>,
}
impl UniquePtr<Records> {}
unsafe extern "C++" {
include!("rust-apt/apt-pkg-c/types.h");
include!("rust-apt/apt-pkg-c/package.h");
include!("rust-apt/apt-pkg-c/util.h");
include!("rust-apt/apt-pkg-c/depcache.h");
include!("rust-apt/apt-pkg-c/records.h");
include!("rust-apt/apt-pkg-c/progress.h");
include!("rust-apt/apt-pkg-c/cache.h");
type PkgCacheFile;
type Package = crate::raw::package::raw::Package;
type Version = crate::raw::package::raw::Version;
type PackageFile = crate::raw::package::raw::PackageFile;
type SourceURI = crate::raw::package::raw::SourceURI;
type Records = crate::raw::records::raw::Records;
type DepCache = crate::raw::depcache::raw::DepCache;
type DynAcquireProgress = crate::raw::progress::raw::DynAcquireProgress;
pub fn create_cache(deb_files: &[String]) -> Result<Cache>;
pub fn update(self: &Cache, progress: &mut DynAcquireProgress) -> Result<()>;
pub fn source_uris(self: &Cache) -> Vec<SourceURI>;
pub fn create_depcache(self: &Cache) -> DepCache;
pub fn create_records(self: &Cache) -> UniquePtr<Records>;
pub fn priority(self: &Cache, version: &Version) -> i32;
pub fn find_index(self: &Cache, pkg_file: &mut PackageFile);
pub fn is_trusted(self: &Cache, pkg_file: &mut PackageFile) -> bool;
pub fn unsafe_find_pkg(self: &Cache, name: String) -> Package;
pub fn begin(self: &Cache) -> Result<Package>;
}
}
impl raw::Cache {
pub fn find_pkg(&self, name: &str) -> Option<RawPackage> {
let ptr = self.unsafe_find_pkg(name.to_string());
match ptr.end() {
true => None,
false => Some(ptr),
}
}
}