|
|
@ -51,14 +51,22 @@ impl From<apt::APT_AppStatus> for AppStatus { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub struct Apt { |
|
|
|
pub struct Apt { |
|
|
|
pd: PhantomData<()>, |
|
|
|
pd: PhantomData<i32> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Apt { |
|
|
|
impl Apt { |
|
|
|
pub fn new() -> Apt { |
|
|
|
pub fn new() -> Result<Apt, i32> { |
|
|
|
Apt { pd: PhantomData } |
|
|
|
unsafe { |
|
|
|
|
|
|
|
let r = apt::aptInit(); |
|
|
|
|
|
|
|
if r < 0 { |
|
|
|
|
|
|
|
Err(r) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Ok(Apt { pd: PhantomData }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn get_status(&self) -> AppStatus { |
|
|
|
pub fn get_status(&self) -> AppStatus { |
|
|
|
unsafe { apt::aptGetStatus().into() } |
|
|
|
unsafe { apt::aptGetStatus().into() } |
|
|
|
} |
|
|
|
} |
|
|
@ -88,3 +96,9 @@ impl Apt { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Drop for Apt { |
|
|
|
|
|
|
|
fn drop(&mut self) { |
|
|
|
|
|
|
|
unsafe { apt::aptExit() }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|