Mostly improved tree walking I guess.
This commit is contained in:
@@ -63,7 +63,10 @@ pub trait Cas {
|
||||
}
|
||||
|
||||
pub trait RefStore {
|
||||
fn get_ref<P: AsRef<Utf8Path>>(&self, key: P) -> Result<ObjectId>;
|
||||
fn set_ref<P: AsRef<Utf8Path>>(&mut self, key: P, value: &ObjectId) -> Result<()>;
|
||||
fn remove_ref<P: AsRef<Utf8Path>>(&mut self, key: P) -> Result<()>;
|
||||
}
|
||||
fn get_ref(&self, key: &Utf8Path) -> Result<ObjectId>;
|
||||
fn set_ref(&mut self, key: &Utf8Path, value: &ObjectId) -> Result<()>;
|
||||
fn remove_ref(&mut self, key: &Utf8Path) -> Result<()>;
|
||||
}
|
||||
|
||||
pub trait CasWithRef: Cas + RefStore {
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
// use std::path::Utf8PathBuf;
|
||||
|
||||
use std::path::StripPrefixError;
|
||||
|
||||
use crate::ObjectId;
|
||||
|
||||
|
||||
/// Result type used through cas-core.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
@@ -87,6 +91,9 @@ pub enum Error {
|
||||
#[error("non-unicode file name: '{0}'")]
|
||||
NonUnicodeFileName(String),
|
||||
|
||||
#[error("object {0} does not exists")]
|
||||
ObjectDoesNotExists(ObjectId),
|
||||
|
||||
#[error("{0}")]
|
||||
UnknownError(String),
|
||||
}
|
||||
@@ -129,6 +136,11 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StripPrefixError> for Error {
|
||||
fn from(value: StripPrefixError) -> Self {
|
||||
Error::unknown(format!("Invalid operation: {}", value))
|
||||
}
|
||||
}
|
||||
|
||||
// fn format_optional_path(maybe_path: &Option<Utf8PathBuf>) -> String {
|
||||
// match maybe_path {
|
||||
|
||||
@@ -35,10 +35,10 @@ mod cas;
|
||||
pub use crate::{
|
||||
error::{Error, Result},
|
||||
object_id::{ObjectId, hex, write_hex},
|
||||
object_type::{ObjectType},
|
||||
object_metadata::{ObjectMetadata},
|
||||
object_type::ObjectType,
|
||||
object_metadata::ObjectMetadata,
|
||||
pipeline::{Pipeline, DefaultPipeline, Reader, Writer, ReadWrapper, WriteWrapper},
|
||||
cas::{Cas, RefStore},
|
||||
cas::{Cas, CasWithRef, RefStore},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// along with bsv. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
use super::object_type::{ObjectType};
|
||||
use super::object_type::ObjectType;
|
||||
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user