Start implementing a cas in separate crates.
This commit is contained in:
40
cas-core/src/cas.rs
Normal file
40
cas-core/src/cas.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
// This file is part of bsv.
|
||||
//
|
||||
// bsv is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// cdb is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
// more details.
|
||||
//
|
||||
// You should have received a copy of the Affero GNU General Public License
|
||||
// along with cdb. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
use super::error::Result;
|
||||
use super::object_id::ObjectId;
|
||||
use super::object_type::ObjectType;
|
||||
use super::object_metadata::ObjectMetadata;
|
||||
|
||||
|
||||
// pub struct ObjectIdIterator;
|
||||
|
||||
|
||||
pub trait Cas {
|
||||
fn object_id_from_string(&self, hex: &str) -> Result<ObjectId>;
|
||||
fn object_id_from_partial(&self, hex: &str) -> Result<ObjectId>;
|
||||
|
||||
fn has_object_id(&self, oid: &ObjectId) -> Result<bool>;
|
||||
// fn iter_object_id(&self) -> Result<ObjectIdIterator>;
|
||||
|
||||
fn read_object(&self, oid: &ObjectId) -> Result<(ObjectMetadata, &dyn std::io::Read)>;
|
||||
fn write_object(&mut self, otype: ObjectType, data: &mut dyn std::io::Read) -> Result<ObjectId>;
|
||||
fn remove_object(&mut self, oid: &ObjectId) -> Result<()>;
|
||||
|
||||
fn read_ref(&self, key: &str) -> Result<ObjectId>;
|
||||
fn write_ref(&mut self, key: &str, value: &ObjectId) -> Result<()>;
|
||||
fn remove_ref(&mut self, key: &str) -> Result<()>;
|
||||
}
|
||||
Reference in New Issue
Block a user