Mostly improved tree walking I guess.

This commit is contained in:
2023-10-21 19:55:17 +02:00
parent 2b27b788e5
commit 25c7d0d470
17 changed files with 554 additions and 346 deletions

View File

@@ -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 {
}

View File

@@ -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 {

View File

@@ -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},
};

View File

@@ -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)]