Move ObjectType to core.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
pub mod error;
|
||||
pub mod config;
|
||||
pub mod object_id;
|
||||
pub mod object;
|
||||
pub mod repository;
|
||||
|
||||
|
||||
@@ -27,4 +28,5 @@ pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
pub use error::{Error, Result, ErrorKind};
|
||||
pub use config::{Config, RepositoryConfig};
|
||||
pub use object_id::ObjectId;
|
||||
pub use object::{ObjectType, OTYPE_BLOB, OTYPE_TREE};
|
||||
pub use repository::Repository;
|
||||
|
||||
20
libbsv/src/core/object.rs
Normal file
20
libbsv/src/core/object.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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/>.
|
||||
|
||||
|
||||
pub type ObjectType = [u8; 4];
|
||||
|
||||
pub const OTYPE_BLOB: &ObjectType = b"blob";
|
||||
pub const OTYPE_TREE: &ObjectType = b"tree";
|
||||
@@ -25,6 +25,8 @@ pub mod simple_db;
|
||||
pub use crate::core::{
|
||||
Error, Result, ErrorKind,
|
||||
Config, RepositoryConfig,
|
||||
ObjectId,
|
||||
ObjectId, ObjectType,
|
||||
Repository,
|
||||
|
||||
OTYPE_BLOB, OTYPE_TREE,
|
||||
};
|
||||
|
||||
@@ -20,6 +20,5 @@ pub mod object;
|
||||
|
||||
pub use simple_db::SimpleDb;
|
||||
pub use object::{
|
||||
OTYPE_BLOB, OTYPE_TREE,
|
||||
ObjectReader,
|
||||
};
|
||||
|
||||
@@ -30,12 +30,7 @@ use flate2::{
|
||||
|
||||
use crate::core::error::*;
|
||||
use crate::core::ObjectId;
|
||||
|
||||
|
||||
pub type ObjectType = [u8; 4];
|
||||
|
||||
pub const OTYPE_BLOB: &ObjectType = b"blob";
|
||||
pub const OTYPE_TREE: &ObjectType = b"tree";
|
||||
use crate::core::ObjectType;
|
||||
|
||||
|
||||
pub struct ObjectWriter<W: Write, D: Digest> {
|
||||
@@ -190,6 +185,8 @@ impl<T: Read + Seek> WriteAsObject for T {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::core::OTYPE_BLOB;
|
||||
|
||||
use super::*;
|
||||
|
||||
const PAYLOAD: &[u8; 12] = b"Hello World!";
|
||||
|
||||
@@ -24,10 +24,10 @@ use tempfile::{NamedTempFile};
|
||||
|
||||
use crate::core::error::*;
|
||||
use crate::core::ObjectId;
|
||||
use crate::core::{ObjectType, OTYPE_BLOB};
|
||||
|
||||
use super::object::{
|
||||
OTYPE_BLOB,
|
||||
ObjectReader, ObjectType, WriteAsObject,
|
||||
ObjectReader, WriteAsObject,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ use tempfile::{TempDir};
|
||||
use libbsv::{
|
||||
Result,
|
||||
ObjectId,
|
||||
simple_db::{
|
||||
OTYPE_BLOB,
|
||||
simple_db::{
|
||||
SimpleDb,
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user