Add Ref::is_ref()
This commit is contained in:
parent
1f133eac3b
commit
7fb13acf15
5 changed files with 18 additions and 0 deletions
|
@ -31,3 +31,4 @@ walkdir = "1"
|
||||||
libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore" }
|
libimagstore = { version = "0.6.0", path = "../../../lib/core/libimagstore" }
|
||||||
libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" }
|
libimagerror = { version = "0.6.0", path = "../../../lib/core/libimagerror" }
|
||||||
libimagentrylist = { version = "0.6.0", path = "../../../lib/entry/libimagentrylist" }
|
libimagentrylist = { version = "0.6.0", path = "../../../lib/entry/libimagentrylist" }
|
||||||
|
libimagentryutil = { version = "0.6.0", path = "../../../lib/entry/libimagentryutil" }
|
||||||
|
|
|
@ -26,6 +26,7 @@ error_chain! {
|
||||||
ListError(::libimagentrylist::error::ListError, ::libimagentrylist::error::ListErrorKind);
|
ListError(::libimagentrylist::error::ListError, ::libimagentrylist::error::ListErrorKind);
|
||||||
StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind);
|
StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind);
|
||||||
TomlQueryError(::toml_query::error::Error, ::toml_query::error::ErrorKind);
|
TomlQueryError(::toml_query::error::Error, ::toml_query::error::ErrorKind);
|
||||||
|
EntryUtilError(::libimagentryutil::error::EntryUtilError, ::libimagentryutil::error::EntryUtilErrorKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreign_links {
|
foreign_links {
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern crate walkdir;
|
||||||
#[macro_use] extern crate libimagstore;
|
#[macro_use] extern crate libimagstore;
|
||||||
extern crate libimagerror;
|
extern crate libimagerror;
|
||||||
extern crate libimagentrylist;
|
extern crate libimagentrylist;
|
||||||
|
#[macro_use] extern crate libimagentryutil;
|
||||||
#[macro_use] extern crate error_chain;
|
#[macro_use] extern crate error_chain;
|
||||||
|
|
||||||
module_entry_path_mod!("ref");
|
module_entry_path_mod!("ref");
|
||||||
|
|
|
@ -25,6 +25,8 @@ use std::fs::File;
|
||||||
use std::fs::Permissions;
|
use std::fs::Permissions;
|
||||||
|
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
|
use libimagentryutil::isa::Is;
|
||||||
|
use libimagentryutil::isa::IsKindHeaderPathProvider;
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
use toml_query::read::TomlValueReadExt;
|
use toml_query::read::TomlValueReadExt;
|
||||||
|
@ -38,6 +40,9 @@ use hasher::*;
|
||||||
|
|
||||||
pub trait Ref {
|
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
|
/// Get the hash from the path of the ref
|
||||||
fn get_path_hash(&self) -> Result<String>;
|
fn get_path_hash(&self) -> Result<String>;
|
||||||
|
|
||||||
|
@ -113,9 +118,15 @@ pub trait Ref {
|
||||||
fn get_current_permissions(&self) -> Result<Permissions>;
|
fn get_current_permissions(&self) -> Result<Permissions>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provide_kindflag_path!(pub IsRef, "ref.is_ref");
|
||||||
|
|
||||||
impl Ref for Entry {
|
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
|
/// Get the hash from the path of the ref
|
||||||
fn get_path_hash(&self) -> Result<String> {
|
fn get_path_hash(&self) -> Result<String> {
|
||||||
self.get_location()
|
self.get_location()
|
||||||
|
|
|
@ -26,6 +26,7 @@ use libimagstore::storeid::IntoStoreId;
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
use libimagstore::storeid::StoreIdIterator;
|
use libimagstore::storeid::StoreIdIterator;
|
||||||
use libimagstore::store::Store;
|
use libimagstore::store::Store;
|
||||||
|
use libimagentryutil::isa::Is;
|
||||||
|
|
||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ use error::RefError as RE;
|
||||||
use error::ResultExt;
|
use error::ResultExt;
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use flags::RefFlags;
|
use flags::RefFlags;
|
||||||
|
use reference::IsRef;
|
||||||
use hasher::*;
|
use hasher::*;
|
||||||
use module_path::ModuleEntryPath;
|
use module_path::ModuleEntryPath;
|
||||||
use util::*;
|
use util::*;
|
||||||
|
@ -282,6 +284,8 @@ impl RefStore for Store {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = fle.set_isflag::<IsRef>()?;
|
||||||
|
|
||||||
Ok(fle)
|
Ok(fle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue