-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdc8bdb
commit 275f249
Showing
5 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Sys Crate for Agama Zypp | ||
|
||
Low level FFI bindings to agama-zypp c layer. | ||
|
||
How to regenerate bindings ( using bindgen-cli ): | ||
|
||
``` | ||
bindgen --merge-extern-blocks headers.h -o src/bindings.rs -- -I../../c-layer/include | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "lib.h" | ||
#include "callbacks.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* automatically generated by rust-bindgen 0.70.1 */ | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct ProgressData { | ||
pub value: ::std::os::raw::c_longlong, | ||
pub name: *const ::std::os::raw::c_char, | ||
} | ||
#[allow(clippy::unnecessary_operation, clippy::identity_op)] | ||
const _: () = { | ||
["Size of ProgressData"][::std::mem::size_of::<ProgressData>() - 16usize]; | ||
["Alignment of ProgressData"][::std::mem::align_of::<ProgressData>() - 8usize]; | ||
["Offset of field: ProgressData::value"][::std::mem::offset_of!(ProgressData, value) - 0usize]; | ||
["Offset of field: ProgressData::name"][::std::mem::offset_of!(ProgressData, name) - 8usize]; | ||
}; | ||
pub type ZyppProgressCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
zypp_data: ProgressData, | ||
user_data: *mut ::std::os::raw::c_void, | ||
) -> ::std::os::raw::c_int, | ||
>; | ||
pub const PROBLEM_RESPONSE_PROBLEM_RETRY: PROBLEM_RESPONSE = 0; | ||
pub const PROBLEM_RESPONSE_PROBLEM_ABORT: PROBLEM_RESPONSE = 1; | ||
pub const PROBLEM_RESPONSE_PROBLEM_IGNORE: PROBLEM_RESPONSE = 2; | ||
pub type PROBLEM_RESPONSE = ::std::os::raw::c_uint; | ||
pub type ZyppDownloadStartCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
url: *const ::std::os::raw::c_char, | ||
localfile: *const ::std::os::raw::c_char, | ||
user_data: *mut ::std::os::raw::c_void, | ||
), | ||
>; | ||
pub type ZyppDownloadProgressCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
value: ::std::os::raw::c_int, | ||
url: *const ::std::os::raw::c_char, | ||
bps_avg: f64, | ||
bps_current: f64, | ||
user_data: *mut ::std::os::raw::c_void, | ||
) -> ::std::os::raw::c_int, | ||
>; | ||
pub type ZyppDownloadProblemCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
url: *const ::std::os::raw::c_char, | ||
error: ::std::os::raw::c_int, | ||
description: *const ::std::os::raw::c_char, | ||
user_data: *mut ::std::os::raw::c_void, | ||
) -> PROBLEM_RESPONSE, | ||
>; | ||
pub type ZyppDownloadFinishCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
url: *const ::std::os::raw::c_char, | ||
error: ::std::os::raw::c_int, | ||
reason: *const ::std::os::raw::c_char, | ||
user_data: *mut ::std::os::raw::c_void, | ||
), | ||
>; | ||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct Repository { | ||
pub url: *mut ::std::os::raw::c_char, | ||
pub alias: *mut ::std::os::raw::c_char, | ||
pub userName: *mut ::std::os::raw::c_char, | ||
} | ||
#[allow(clippy::unnecessary_operation, clippy::identity_op)] | ||
const _: () = { | ||
["Size of Repository"][::std::mem::size_of::<Repository>() - 24usize]; | ||
["Alignment of Repository"][::std::mem::align_of::<Repository>() - 8usize]; | ||
["Offset of field: Repository::url"][::std::mem::offset_of!(Repository, url) - 0usize]; | ||
["Offset of field: Repository::alias"][::std::mem::offset_of!(Repository, alias) - 8usize]; | ||
["Offset of field: Repository::userName"] | ||
[::std::mem::offset_of!(Repository, userName) - 16usize]; | ||
}; | ||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct RepositoryList { | ||
pub size: ::std::os::raw::c_uint, | ||
pub repos: *mut Repository, | ||
} | ||
#[allow(clippy::unnecessary_operation, clippy::identity_op)] | ||
const _: () = { | ||
["Size of RepositoryList"][::std::mem::size_of::<RepositoryList>() - 16usize]; | ||
["Alignment of RepositoryList"][::std::mem::align_of::<RepositoryList>() - 8usize]; | ||
["Offset of field: RepositoryList::size"] | ||
[::std::mem::offset_of!(RepositoryList, size) - 0usize]; | ||
["Offset of field: RepositoryList::repos"] | ||
[::std::mem::offset_of!(RepositoryList, repos) - 8usize]; | ||
}; | ||
#[repr(C)] | ||
#[derive(Debug, Copy, Clone)] | ||
pub struct Status { | ||
pub state: Status_STATE, | ||
pub error: *mut ::std::os::raw::c_char, | ||
} | ||
pub const Status_STATE_STATE_SUCCEED: Status_STATE = 0; | ||
pub const Status_STATE_STATE_FAILED: Status_STATE = 1; | ||
pub type Status_STATE = ::std::os::raw::c_uint; | ||
#[allow(clippy::unnecessary_operation, clippy::identity_op)] | ||
const _: () = { | ||
["Size of Status"][::std::mem::size_of::<Status>() - 16usize]; | ||
["Alignment of Status"][::std::mem::align_of::<Status>() - 8usize]; | ||
["Offset of field: Status::state"][::std::mem::offset_of!(Status, state) - 0usize]; | ||
["Offset of field: Status::error"][::std::mem::offset_of!(Status, error) - 8usize]; | ||
}; | ||
pub type ProgressCallback = ::std::option::Option< | ||
unsafe extern "C" fn( | ||
text: *const ::std::os::raw::c_char, | ||
stage: ::std::os::raw::c_uint, | ||
total: ::std::os::raw::c_uint, | ||
user_data: *mut ::std::os::raw::c_void, | ||
), | ||
>; | ||
extern "C" { | ||
pub fn set_zypp_progress_callback( | ||
progress: ZyppProgressCallback, | ||
user_data: *mut ::std::os::raw::c_void, | ||
); | ||
pub fn set_zypp_download_callbacks( | ||
start: ZyppDownloadStartCallback, | ||
progress: ZyppDownloadProgressCallback, | ||
problem: ZyppDownloadProblemCallback, | ||
finish: ZyppDownloadFinishCallback, | ||
user_data: *mut ::std::os::raw::c_void, | ||
); | ||
pub fn free_status(s: Status); | ||
pub fn init_target( | ||
root: *const ::std::os::raw::c_char, | ||
progress: ProgressCallback, | ||
user_data: *mut ::std::os::raw::c_void, | ||
) -> ::std::os::raw::c_int; | ||
pub fn list_repositories() -> RepositoryList; | ||
pub fn free_repository_list(repo_list: *mut RepositoryList); | ||
pub fn refresh_repositories( | ||
status: *mut Status, | ||
callback: ZyppProgressCallback, | ||
data: *mut ::std::os::raw::c_void, | ||
); | ||
pub fn free_zypp(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn add(left: u64, right: u64) -> u64 { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |