alpm 0.5.2

Rust bindings for libalpm
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::utils::*;
use crate::{free, Alpm, Result};

use alpm_sys::*;

use std::ffi::{c_void, CString};

impl Alpm {
    pub fn fetch_pkgurl<S: Into<String>>(&self, url: S) -> Result<String> {
        let url = CString::new(url.into()).unwrap();
        let path = unsafe { alpm_fetch_pkgurl(self.handle, url.as_ptr()) };
        self.check_null(path)?;
        let path_str = unsafe { from_cstr(path) };
        let path_string = path_str.to_string();
        unsafe { free(path as *mut c_void) };
        Ok(path_string)
    }
}