Add Ref::is_ref()

This commit is contained in:
Matthias Beyer 2018-01-08 23:34:13 +01:00
parent 1f133eac3b
commit 7fb13acf15
5 changed files with 18 additions and 0 deletions

View file

@ -31,3 +31,4 @@ walkdir = "1"
libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore" }
libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" }
libimagentrylist = { version = "0.6.0", path = "../../../lib/entry/libimagentrylist" }
libimagentryutil = { version = "0.6.0", path = "../../../lib/entry/libimagentryutil" }

View file

@ -26,6 +26,7 @@ error_chain! {
ListError(::libimagentrylist::error::ListError, ::libimagentrylist::error::ListErrorKind);
StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind);
TomlQueryError(::toml_query::error::Error, ::toml_query::error::ErrorKind);
EntryUtilError(::libimagentryutil::error::EntryUtilError, ::libimagentryutil::error::EntryUtilErrorKind);
}
foreign_links {

View file

@ -45,6 +45,7 @@ extern crate walkdir;
#[macro_use] extern crate libimagstore;
extern crate libimagerror;
extern crate libimagentrylist;
#[macro_use] extern crate libimagentryutil;
#[macro_use] extern crate error_chain;
module_entry_path_mod!("ref");

View file

@ -25,6 +25,8 @@ use std::fs::File;
use std::fs::Permissions;
use libimagstore::store::Entry;
use libimagentryutil::isa::Is;
use libimagentryutil::isa::IsKindHeaderPathProvider;
use toml::Value;
use toml_query::read::TomlValueReadExt;
@ -38,6 +40,9 @@ use hasher::*;
pub trait Ref {
/// Check whether the underlying object is actually a ref
fn is_ref(&self) -> Result<bool>;
/// Get the hash from the path of the ref
fn get_path_hash(&self) -> Result<String>;
@ -113,9 +118,15 @@ pub trait Ref {
fn get_current_permissions(&self) -> Result<Permissions>;
}
provide_kindflag_path!(pub IsRef, "ref.is_ref");
impl Ref for Entry {
/// Check whether the underlying object is actually a ref
fn is_ref(&self) -> Result<bool> {
self.is::<IsRef>().map_err(From::from)
}
/// Get the hash from the path of the ref
fn get_path_hash(&self) -> Result<String> {
self.get_location()

View file

@ -26,6 +26,7 @@ use libimagstore::storeid::IntoStoreId;
use libimagstore::storeid::StoreId;
use libimagstore::storeid::StoreIdIterator;
use libimagstore::store::Store;
use libimagentryutil::isa::Is;
use toml::Value;
@ -34,6 +35,7 @@ use error::RefError as RE;
use error::ResultExt;
use error::Result;
use flags::RefFlags;
use reference::IsRef;
use hasher::*;
use module_path::ModuleEntryPath;
use util::*;
@ -282,6 +284,8 @@ impl RefStore for Store {
}
}
let _ = fle.set_isflag::<IsRef>()?;
Ok(fle)
}