diff --git a/libbsv/src/core/mod.rs b/libbsv/src/core/mod.rs index a8ba778..f18c214 100644 --- a/libbsv/src/core/mod.rs +++ b/libbsv/src/core/mod.rs @@ -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; diff --git a/libbsv/src/core/object.rs b/libbsv/src/core/object.rs new file mode 100644 index 0000000..bee86d8 --- /dev/null +++ b/libbsv/src/core/object.rs @@ -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 . + + +pub type ObjectType = [u8; 4]; + +pub const OTYPE_BLOB: &ObjectType = b"blob"; +pub const OTYPE_TREE: &ObjectType = b"tree"; diff --git a/libbsv/src/lib.rs b/libbsv/src/lib.rs index 1d49bd4..9baed7d 100644 --- a/libbsv/src/lib.rs +++ b/libbsv/src/lib.rs @@ -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, }; diff --git a/libbsv/src/simple_db/mod.rs b/libbsv/src/simple_db/mod.rs index 1e0f8f0..e20b18c 100644 --- a/libbsv/src/simple_db/mod.rs +++ b/libbsv/src/simple_db/mod.rs @@ -20,6 +20,5 @@ pub mod object; pub use simple_db::SimpleDb; pub use object::{ - OTYPE_BLOB, OTYPE_TREE, ObjectReader, }; diff --git a/libbsv/src/simple_db/object.rs b/libbsv/src/simple_db/object.rs index f1323e8..8f8c2c0 100644 --- a/libbsv/src/simple_db/object.rs +++ b/libbsv/src/simple_db/object.rs @@ -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 { @@ -190,6 +185,8 @@ impl WriteAsObject for T { #[cfg(test)] mod tests { + use crate::core::OTYPE_BLOB; + use super::*; const PAYLOAD: &[u8; 12] = b"Hello World!"; diff --git a/libbsv/src/simple_db/simple_db.rs b/libbsv/src/simple_db/simple_db.rs index d973558..21ad913 100644 --- a/libbsv/src/simple_db/simple_db.rs +++ b/libbsv/src/simple_db/simple_db.rs @@ -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, }; diff --git a/libbsv/tests/simple_db.rs b/libbsv/tests/simple_db.rs index 03aa2c0..a5236a0 100644 --- a/libbsv/tests/simple_db.rs +++ b/libbsv/tests/simple_db.rs @@ -27,8 +27,8 @@ use tempfile::{TempDir}; use libbsv::{ Result, ObjectId, + OTYPE_BLOB, simple_db::{ - OTYPE_BLOB, SimpleDb, } };