pub struct PackStore { /* private fields */ }Expand description
A TileStore over one append-only file.
Implementations§
Source§impl PackStore
impl PackStore
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self>
pub fn open(path: impl Into<PathBuf>) -> Result<Self>
Opens the pack at path for writing, creating it when absent, and
takes <path>.lock. A pack another writer holds is refused with
io::ErrorKind::WouldBlock.
Opens the pack at path as one of several writers, creating it when
absent. No lock is held between changes; each change waits up to
SHARED_LOCK_WAIT for <path>.lock and fails with
io::ErrorKind::WouldBlock after that.
PackStore::open_shared with its own wait for the lock.
Sourcepub fn open_read(path: impl Into<PathBuf>) -> Result<Self>
pub fn open_read(path: impl Into<PathBuf>) -> Result<Self>
Opens the pack at path for reading, without a lock. The pack must
exist.
Sourcepub fn break_lock(path: impl AsRef<Path>) -> Result<bool>
pub fn break_lock(path: impl AsRef<Path>) -> Result<bool>
Removes a lock a crashed writer left. The caller knows no writer is alive; nothing here checks.
Sourcepub fn live_bytes(&self) -> Result<u64>
pub fn live_bytes(&self) -> Result<u64>
Bytes the live records occupy, framing, magic and index included: the pack after a compaction is exactly this long.
Trait Implementations§
Source§impl TileStore for PackStore
impl TileStore for PackStore
Source§fn get(&self, path: &str) -> Result<Option<Vec<u8>>>
fn get(&self, path: &str) -> Result<Option<Vec<u8>>>
The bytes at
path, or nothing when there is no such file.Source§fn put(&self, path: &str, bytes: &[u8]) -> Result<()>
fn put(&self, path: &str, bytes: &[u8]) -> Result<()>
Writes
bytes at path, whole or not at all, replacing what is there.Source§fn create_new(&self, path: &str, bytes: &[u8]) -> Result<bool>
fn create_new(&self, path: &str, bytes: &[u8]) -> Result<bool>
Writes
bytes at path only when nothing is there; false when
something is.Source§fn delete(&self, path: &str) -> Result<bool>
fn delete(&self, path: &str) -> Result<bool>
Removes
path; false when there was nothing to remove.Source§fn rename(&self, from: &str, to: &str) -> Result<()>
fn rename(&self, from: &str, to: &str) -> Result<()>
Moves
from to to, replacing what is at to.Auto Trait Implementations§
impl !Freeze for PackStore
impl RefUnwindSafe for PackStore
impl Send for PackStore
impl Sync for PackStore
impl Unpin for PackStore
impl UnsafeUnpin for PackStore
impl UnwindSafe for PackStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more