repo: change custom new method to std::path::Path-alike

This commit is contained in:
Felix Krull 2018-10-07 23:14:56 +02:00 committed by Colin Walters
parent fa615fb1bb
commit f26e0013a5
2 changed files with 5 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use glib::translate::*;
use glib_ffi; use glib_ffi;
use std::collections::HashSet; use std::collections::HashSet;
use std::ptr; use std::ptr;
use std::path::Path;
use ObjectName; use ObjectName;
unsafe extern "C" fn read_variant_table(_key: glib_ffi::gpointer, value: glib_ffi::gpointer, hash_set: glib_ffi::gpointer) { unsafe extern "C" fn read_variant_table(_key: glib_ffi::gpointer, value: glib_ffi::gpointer, hash_set: glib_ffi::gpointer) {
@ -27,7 +28,7 @@ unsafe fn from_glib_container_variant_set(ptr: *mut glib_ffi::GHashTable) -> Has
pub trait RepoExtManual { pub trait RepoExtManual {
fn new_for_str(path: &str) -> Repo; fn new_for_path<P: AsRef<Path>>(path: P) -> Repo;
fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>( fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>(
&self, &self,
commit_checksum: &str, commit_checksum: &str,
@ -36,8 +37,8 @@ pub trait RepoExtManual {
} }
impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O { impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
fn new_for_str(path: &str) -> Repo { fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
Repo::new(&gio::File::new_for_path(path)) Repo::new(&gio::File::new_for_path(path.as_ref()))
} }
fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>( fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>(

View File

@ -8,7 +8,7 @@ use gio::prelude::*;
use libostree::prelude::*; use libostree::prelude::*;
fn main() { fn main() {
let repo = libostree::Repo::new_for_str("../../../repo-bare"); let repo = libostree::Repo::new_for_path("../../../repo-bare");
//let result = repo.create(libostree::RepoMode::Archive, Option::None); //let result = repo.create(libostree::RepoMode::Archive, Option::None);
//result.expect("we did not expect this to fail :O"); //result.expect("we did not expect this to fail :O");