Move extra Repo methods to plain impl as well

This commit is contained in:
Felix Krull 2019-05-24 22:39:24 +02:00 committed by Colin Walters
parent 493ba2e2f5
commit 66cf9b288f
3 changed files with 8 additions and 36 deletions

View File

@ -85,7 +85,6 @@ status = "generate"
[[object]] [[object]]
name = "OSTree.Repo" name = "OSTree.Repo"
status = "generate" status = "generate"
manual_traits = ["RepoExtManual"]
[[object.function]] [[object.function]]
# crashes while generating, not sure what's wrong with this; might be a gir issue # crashes while generating, not sure what's wrong with this; might be a gir issue
name = "write_metadata_async" name = "write_metadata_async"

View File

@ -35,5 +35,4 @@ mod tests;
// prelude // prelude
pub mod prelude { pub mod prelude {
pub use crate::auto::traits::*; pub use crate::auto::traits::*;
pub use crate::repo::RepoExtManual;
} }

View File

@ -34,38 +34,12 @@ unsafe fn from_glib_container_variant_set(ptr: *mut glib_sys::GHashTable) -> Has
set set
} }
pub trait RepoExtManual { impl Repo {
fn new_for_path<P: AsRef<Path>>(path: P) -> Repo; pub fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
fn traverse_commit<P: IsA<gio::Cancellable>>(
&self,
commit_checksum: &str,
maxdepth: i32,
cancellable: Option<&P>,
) -> Result<HashSet<ObjectName>, Error>;
// TODO: return GString?
fn list_refs<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, Error>;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
fn list_refs_ext<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
flags: RepoListRefsExtFlags,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, Error>;
}
impl<O: IsA<Repo>> RepoExtManual for O {
fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
Repo::new(&gio::File::new_for_path(path.as_ref())) Repo::new(&gio::File::new_for_path(path.as_ref()))
} }
fn traverse_commit<P: IsA<gio::Cancellable>>( pub fn traverse_commit<P: IsA<gio::Cancellable>>(
&self, &self,
commit_checksum: &str, commit_checksum: &str,
maxdepth: i32, maxdepth: i32,
@ -75,7 +49,7 @@ impl<O: IsA<Repo>> RepoExtManual for O {
let mut error = ptr::null_mut(); let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut(); let mut hashtable = ptr::null_mut();
let _ = ostree_sys::ostree_repo_traverse_commit( let _ = ostree_sys::ostree_repo_traverse_commit(
self.as_ref().to_glib_none().0, self.to_glib_none().0,
commit_checksum.to_glib_none().0, commit_checksum.to_glib_none().0,
maxdepth, maxdepth,
&mut hashtable, &mut hashtable,
@ -90,7 +64,7 @@ impl<O: IsA<Repo>> RepoExtManual for O {
} }
} }
fn list_refs<P: IsA<gio::Cancellable>>( pub fn list_refs<P: IsA<gio::Cancellable>>(
&self, &self,
refspec_prefix: Option<&str>, refspec_prefix: Option<&str>,
cancellable: Option<&P>, cancellable: Option<&P>,
@ -99,7 +73,7 @@ impl<O: IsA<Repo>> RepoExtManual for O {
let mut error = ptr::null_mut(); let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut(); let mut hashtable = ptr::null_mut();
let _ = ostree_sys::ostree_repo_list_refs( let _ = ostree_sys::ostree_repo_list_refs(
self.as_ref().to_glib_none().0, self.to_glib_none().0,
refspec_prefix.to_glib_none().0, refspec_prefix.to_glib_none().0,
&mut hashtable, &mut hashtable,
cancellable.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0,
@ -115,7 +89,7 @@ impl<O: IsA<Repo>> RepoExtManual for O {
} }
#[cfg(any(feature = "v2016_4", feature = "dox"))] #[cfg(any(feature = "v2016_4", feature = "dox"))]
fn list_refs_ext<P: IsA<gio::Cancellable>>( pub fn list_refs_ext<P: IsA<gio::Cancellable>>(
&self, &self,
refspec_prefix: Option<&str>, refspec_prefix: Option<&str>,
flags: RepoListRefsExtFlags, flags: RepoListRefsExtFlags,
@ -125,7 +99,7 @@ impl<O: IsA<Repo>> RepoExtManual for O {
let mut error = ptr::null_mut(); let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut(); let mut hashtable = ptr::null_mut();
let _ = ostree_sys::ostree_repo_list_refs_ext( let _ = ostree_sys::ostree_repo_list_refs_ext(
self.as_ref().to_glib_none().0, self.to_glib_none().0,
refspec_prefix.to_glib_none().0, refspec_prefix.to_glib_none().0,
&mut hashtable, &mut hashtable,
flags.to_glib(), flags.to_glib(),