Skip to content

Commit

Permalink
change!: move sink::Sink to the top-level exclusively (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 18, 2021
1 parent 494772c commit ab4e726
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
36 changes: 29 additions & 7 deletions git-odb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,45 @@
//! * loose object reading and writing
//! * access to packed objects
//! * multiple loose objects and pack locations as gathered from `alternates` files.
#![allow(deprecated)] // TODO: actually remove the deprecated items and remove thos allow
// TODO: actually remove the deprecated items and remove thos allow
#![allow(deprecated)]

use std::cell::RefCell;
use std::path::PathBuf;
use std::sync::Arc;

use git_features::threading::OwnShared;
use git_features::zlib::stream::deflate;
pub use git_pack as pack;

mod store;
pub use store::{cache, compound, general, linked, loose, sink, Cache, RefreshMode, Sink};
pub use store::{cache, compound, general, linked, loose, Cache, RefreshMode};

pub mod alternate;

///
/// It can optionally compress the content, similarly to what would happen when using a [`loose::Store`][crate::store::loose::Store].
///
pub struct Sink {
compressor: Option<RefCell<deflate::Write<std::io::Sink>>>,
}

/// Create a new [`Sink`] with compression disabled.
pub fn sink() -> Sink {
Sink { compressor: None }
}

///
pub mod sink;

///
pub mod find;

/// An object database equivalent to `/dev/null`, dropping all objects stored into it.
mod traits;

pub use traits::{Find, FindExt, Write};

/// A thread-local handle to access any object.
pub type Handle = Cache<general::Handle<OwnShared<general::Store>>>;
/// A thread-local handle to access any object, but thread-safe and independent of the actual type of `OwnShared` or feature toggles in `git-features`.
Expand All @@ -40,8 +67,3 @@ pub fn at_opts(objects_dir: impl Into<PathBuf>, slots: general::init::Slots) ->
pub fn at(objects_dir: impl Into<PathBuf>) -> std::io::Result<Handle> {
at_opts(objects_dir, Default::default())
}

///
pub mod find;
mod traits;
pub use traits::{Find, FindExt, Write};
14 changes: 1 addition & 13 deletions git-odb/src/store/sink.rs → git-odb/src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@ use std::{
io::{self, Write},
};

use crate::Sink;
use git_features::zlib::stream::deflate;

/// An object database equivalent to `/dev/null`, dropping all objects stored into it.
///
/// It can optionally compress the content, similarly to what would happen when using a [`loose::Store`][crate::store::loose::Store].
///
pub struct Sink {
compressor: Option<RefCell<deflate::Write<io::Sink>>>,
}

impl Sink {
/// Enable or disable compression. Compression is disabled by default
pub fn compress(mut self, enable: bool) -> Self {
Expand All @@ -26,11 +19,6 @@ impl Sink {
}
}

/// Create a new [`Sink`] with compression disabled.
pub fn sink() -> Sink {
Sink { compressor: None }
}

impl crate::traits::Write for Sink {
type Error = io::Error;

Expand Down
5 changes: 0 additions & 5 deletions git-odb/src/store/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
use std::{cell::RefCell, sync::Arc};

pub use sink::{sink, Sink};

///
pub mod cache;
pub mod compound;
pub mod general;
pub mod linked;
pub mod loose;

///
pub mod sink;

/// A way to access objects along with pre-configured thread-local caches for packed base objects as well as objects themselves.
///
/// By default, no cache will be used.
Expand Down

0 comments on commit ab4e726

Please sign in to comment.