Skip to main content

Storage

Struct Storage 

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub fn open(path: &Path, writable: bool) -> Result<Self>

Opens path, plus its sibling volumes if it is part of a split set.

Source

pub fn from_parts(recorded: &[(PathBuf, u64)], writable: bool) -> Result<Self>

Reopens a set whose original layout was recorded in the journal.

Source

pub fn sfv_checked(&self) -> bool

Whether this storage has already been verified against an .sfv file.

Source

pub fn mark_sfv_checked(&self)

Source

pub fn protect(&self)

From now on nothing may shrink, punch, write to or delete the archive.

Source

pub fn protected(&self) -> bool

Source

pub fn hard_linked(&self) -> Option<&Path>

The first volume that has another name, if any. Shrinking a file shrinks it under every name it has, so extracting in place would empty a hard link that may be the only copy someone meant to keep.

Source

pub fn primary(&self) -> &Path

Source

pub fn parts(&self) -> &[Part]

Source

pub fn record(&self) -> Vec<(PathBuf, u64)>

Source

pub fn original_len(&self) -> u64

The archive’s original length.

Source

pub fn current_len(&self) -> Result<u64>

How much of the archive is still on disk, checking that what is left is an untouched prefix of the original.

Source

pub fn set_len(&self, len: u64) -> Result<()>

Shrinks the archive to its first len bytes: whole volumes past that point are deleted, the one it falls in is truncated.

Source

pub fn punch(&self, from: u64, to: u64) -> Result<bool>

Gives back the disk space of the bytes in [from, to) while every offset stays where it was; they read as zeros afterwards. Returns false if the filesystem can’t. Filesystems free whole blocks only, so up to a block at each end may stay allocated until truncation.

Source

pub fn cut_to(&self, len: u64) -> Result<()>

Like set_len, but also cuts volumes that grew past their original length. Only for undoing an interrupted restore, which is the one thing that appends to an archive: the volume it appended to may have been whole, and set_len never touches whole volumes.

Source

pub fn write_at(&self, offset: u64, bytes: &[u8]) -> Result<()>

Writes bytes at offset of the joined archive and flushes them to disk. Bytes inside the archive go to the volume that holds them; bytes past its current end go to the last volume still there, which grows.

Source

pub fn remove(self) -> Result<()>

Deletes whatever is left of every part.

Source

pub fn reader(&self, tail: Option<Arc<Tail>>) -> Reader ⓘ

A reader of the joined archive. With a tail, the archive ends where the tail does: a split ZIP’s index is served rewritten, and can be shorter or longer than the bytes it stands for. Every other tail ends exactly at the archive’s original end.

Source

pub fn count_reads(&mut self, reads: Arc<Reads>)

Counts what every reader made from now on reads into reads, a pass over the whole archive by default.

Source

pub fn reads(&self) -> Arc<Reads> ⓘ

Shares the byte counter used by archive reads with another reader.

Source

pub fn expect_reads(&self, total: u64)

Starts the count over for a pass that reads total bytes.

Auto Trait Implementations§

§

impl !Freeze for Storage

§

impl Forget for Storage

§

impl Move for Storage

§

impl RefUnwindSafe for Storage

§

impl Send for Storage
where Arc<[Part]>: Send, I32NotAllOnes: Send, Atomic<bool>: Send, Arc<Reads>: Send,

§

impl Sync for Storage
where Arc<[Part]>: Sync, I32NotAllOnes: Sync, Atomic<bool>: Sync, Arc<Reads>: Sync,

§

impl Unpin for Storage
where Arc<[Part]>: Unpin, I32NotAllOnes: Unpin, Align1<u8>: Unpin, Arc<Reads>: Unpin,

§

impl UnsafeUnpin for Storage
where *const ArcInner<[Part]> is !null: UnsafeUnpin, PhantomData<ArcInner<[Part]>>: UnsafeUnpin, I32NotAllOnes: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const ArcInner<Reads> is !null: UnsafeUnpin, PhantomData<ArcInner<Reads>>: UnsafeUnpin,

§

impl UnwindSafe for Storage
where Arc<[Part]>: UnwindSafe, I32NotAllOnes: UnwindSafe, Align1<u8>: UnwindSafe, Arc<Reads>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.