lib: fix clippy
Look, the type is fine. It's only an opaque thing to ensure lifetimes anyway.
This commit is contained in:
parent
d74c0fc04f
commit
315cd5394e
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{RepoCheckoutMode, RepoCheckoutOverwriteMode, RepoDevInoCache, SePolicy};
|
use crate::{RepoCheckoutMode, RepoCheckoutOverwriteMode, RepoDevInoCache, SePolicy};
|
||||||
use glib::translate::{Stash, ToGlib, ToGlibPtr};
|
use glib::translate::*;
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
use ostree_sys::{OstreeRepoCheckoutAtOptions, OstreeRepoDevInoCache, OstreeSePolicy};
|
use ostree_sys::*;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
mod repo_checkout_filter;
|
mod repo_checkout_filter;
|
||||||
|
|
@ -50,6 +50,7 @@ type StringStash<'a, T> = Stash<'a, *const c_char, Option<T>>;
|
||||||
type WrapperStash<'a, GlibT, WrappedT> = Stash<'a, *mut GlibT, Option<WrappedT>>;
|
type WrapperStash<'a, GlibT, WrappedT> = Stash<'a, *mut GlibT, Option<WrappedT>>;
|
||||||
|
|
||||||
impl<'a> ToGlibPtr<'a, *const OstreeRepoCheckoutAtOptions> for RepoCheckoutAtOptions {
|
impl<'a> ToGlibPtr<'a, *const OstreeRepoCheckoutAtOptions> for RepoCheckoutAtOptions {
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
type Storage = (
|
type Storage = (
|
||||||
Box<OstreeRepoCheckoutAtOptions>,
|
Box<OstreeRepoCheckoutAtOptions>,
|
||||||
StringStash<'a, PathBuf>,
|
StringStash<'a, PathBuf>,
|
||||||
|
|
@ -90,7 +91,7 @@ impl<'a> ToGlibPtr<'a, *const OstreeRepoCheckoutAtOptions> for RepoCheckoutAtOpt
|
||||||
|
|
||||||
if let Some(filter) = &self.filter {
|
if let Some(filter) = &self.filter {
|
||||||
options.filter_user_data = filter.to_glib_none().0;
|
options.filter_user_data = filter.to_glib_none().0;
|
||||||
options.filter = repo_checkout_filter::trampoline();
|
options.filter = Some(repo_checkout_filter::filter_trampoline);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stash(
|
Stash(
|
||||||
|
|
@ -112,10 +113,6 @@ mod tests {
|
||||||
use crate::RepoCheckoutFilterResult;
|
use crate::RepoCheckoutFilterResult;
|
||||||
use gio::{File, NONE_CANCELLABLE};
|
use gio::{File, NONE_CANCELLABLE};
|
||||||
use glib_sys::{GFALSE, GTRUE};
|
use glib_sys::{GFALSE, GTRUE};
|
||||||
use ostree_sys::{
|
|
||||||
OSTREE_REPO_CHECKOUT_MODE_NONE, OSTREE_REPO_CHECKOUT_MODE_USER,
|
|
||||||
OSTREE_REPO_CHECKOUT_OVERWRITE_NONE, OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL,
|
|
||||||
};
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
@ -190,7 +187,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!((*ptr).unused_ints, [0; 6]);
|
assert_eq!((*ptr).unused_ints, [0; 6]);
|
||||||
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
|
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
|
||||||
assert_eq!((*ptr).filter, repo_checkout_filter::trampoline());
|
assert!((*ptr).filter == Some(repo_checkout_filter::filter_trampoline));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
(*ptr).filter_user_data,
|
(*ptr).filter_user_data,
|
||||||
options.filter.as_ref().unwrap().to_glib_none().0,
|
options.filter.as_ref().unwrap().to_glib_none().0,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
use crate::{Repo, RepoCheckoutFilterResult};
|
use crate::{Repo, RepoCheckoutFilterResult};
|
||||||
use glib::translate::{
|
use glib::translate::*;
|
||||||
from_glib_borrow, from_glib_none, FromGlibPtrNone, Stash, ToGlib, ToGlibPtr,
|
|
||||||
};
|
|
||||||
use glib_sys::gpointer;
|
use glib_sys::gpointer;
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
use ostree_sys::{OstreeRepo, OstreeRepoCheckoutFilterResult};
|
use ostree_sys::*;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
/// A filter callback to decide which files to checkout from a [Repo](struct.Repo.html). The
|
/// A filter callback to decide which files to checkout from a [Repo](struct.Repo.html). The
|
||||||
|
|
@ -64,7 +62,7 @@ impl FromGlibPtrNone<gpointer> for &RepoCheckoutFilter {
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// If any parameter is a null pointer, the function panics.
|
/// If any parameter is a null pointer, the function panics.
|
||||||
unsafe extern "C" fn filter_trampoline(
|
pub(super) unsafe extern "C" fn filter_trampoline(
|
||||||
repo: *mut OstreeRepo,
|
repo: *mut OstreeRepo,
|
||||||
path: *const c_char,
|
path: *const c_char,
|
||||||
stat: *mut libc::stat,
|
stat: *mut libc::stat,
|
||||||
|
|
@ -87,25 +85,9 @@ unsafe extern "C" fn filter_trampoline(
|
||||||
result.to_glib()
|
result.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the trampoline function in a `Some`.
|
|
||||||
///
|
|
||||||
/// This is mostly convenient because the full type needs to be written out in fewer places.
|
|
||||||
pub(super) fn trampoline() -> Option<
|
|
||||||
unsafe extern "C" fn(
|
|
||||||
*mut OstreeRepo,
|
|
||||||
*const c_char,
|
|
||||||
*mut libc::stat,
|
|
||||||
gpointer,
|
|
||||||
) -> OstreeRepoCheckoutFilterResult,
|
|
||||||
> {
|
|
||||||
Some(filter_trampoline)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use glib::translate::ToGlibPtr;
|
|
||||||
use ostree_sys::OSTREE_REPO_CHECKOUT_FILTER_SKIP;
|
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue