Browse Source

Move ObjectType to core.

deprecated_bsvfs
Draklaw 5 years ago
parent
commit
82ea603ba4
  1. 2
      libbsv/src/core/mod.rs
  2. 20
      libbsv/src/core/object.rs
  3. 4
      libbsv/src/lib.rs
  4. 1
      libbsv/src/simple_db/mod.rs
  5. 9
      libbsv/src/simple_db/object.rs
  6. 4
      libbsv/src/simple_db/simple_db.rs
  7. 2
      libbsv/tests/simple_db.rs

2
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;

20
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 <https://www.gnu.org/licenses/>.
pub type ObjectType = [u8; 4];
pub const OTYPE_BLOB: &ObjectType = b"blob";
pub const OTYPE_TREE: &ObjectType = b"tree";

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

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

9
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<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!";

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

2
libbsv/tests/simple_db.rs

@ -27,8 +27,8 @@ use tempfile::{TempDir};
use libbsv::{
Result,
ObjectId,
OTYPE_BLOB,
simple_db::{
OTYPE_BLOB,
SimpleDb,
}
};

Loading…
Cancel
Save