Use pointer coercion instead of messing with -sys

This commit is contained in:
Felix Krull 2019-09-02 09:59:45 +02:00 committed by Colin Walters
parent d55d1b1d43
commit 4cd981d01b
3 changed files with 8 additions and 30 deletions

View File

@ -32,6 +32,12 @@ impl FromGlibPtrFull<*mut [u8; 32]> for Checksum {
}
}
impl FromGlibPtrFull<*mut [*mut u8; 32]> for Checksum {
unsafe fn from_glib_full(ptr: *mut [*mut u8; 32]) -> Self {
Checksum::new(ptr as *mut u8 as *mut [u8; 32])
}
}
impl FromGlibPtrFull<*mut u8> for Checksum {
unsafe fn from_glib_full(ptr: *mut u8) -> Self {
Checksum::new(ptr as *mut [u8; 32])

View File

@ -129,7 +129,7 @@ impl Repo {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ostree_sys::fixed::ostree_repo_write_content(
let _ = ostree_sys::ostree_repo_write_content(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object_input.as_ref().to_glib_none().0,
@ -156,7 +156,7 @@ impl Repo {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ostree_sys::fixed::ostree_repo_write_metadata(
let _ = ostree_sys::ostree_repo_write_metadata(
self.to_glib_none().0,
objtype.to_glib(),
expected_checksum.to_glib_none().0,

View File

@ -1,29 +1 @@
pub use libc::stat;
pub mod fixed {
use crate::{OstreeObjectType, OstreeRepo};
use glib::gboolean;
use libc::c_char;
extern "C" {
pub fn ostree_repo_write_content(
self_: *mut OstreeRepo,
expected_checksum: *const c_char,
object_input: *mut gio::GInputStream,
length: u64,
out_csum: *mut *mut [u8; 32],
cancellable: *mut gio::GCancellable,
error: *mut *mut glib::GError,
) -> gboolean;
pub fn ostree_repo_write_metadata(
self_: *mut OstreeRepo,
objtype: OstreeObjectType,
expected_checksum: *const c_char,
object: *mut glib::GVariant,
out_csum: *mut *mut [u8; 32],
cancellable: *mut gio::GCancellable,
error: *mut *mut glib::GError,
) -> gboolean;
}
}