Skip to main content

Vault

Struct Vault 

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

Implementations§

Source§

impl Vault

Source

pub async fn open(root: impl Into<PathBuf>) -> Result<Vault>

Creates the directory layout (if needed) and removes stale temporary files.

Source

pub fn root(&self) -> &Path

Source

pub fn with_scanner(self, scanner: Option<ScannerConfig>) -> Vault

The same vault, scanning every new file for malware before it is stored (see crate::malware); None = no scan.

Source

pub fn tmp_dir(&self) -> PathBuf

Source

pub fn object_path(&self, sha256: &str) -> AppResult<PathBuf>

Path of the blob with the given hash. The hash must be validated hex.

Source

pub async fn begin_upload(&self, max_bytes: u64) -> AppResult<Upload>

Starts a streaming upload limited to max_bytes.

Source

pub async fn store_bytes(&self, data: &[u8]) -> AppResult<StoredBlob>

Stores a complete in-memory buffer (used by tests and small imports).

Source

pub async fn open_blob(&self, sha256: &str) -> AppResult<File>

Source

pub async fn exists(&self, sha256: &str) -> bool

Source

pub async fn verify(&self, sha256: &str) -> AppResult<bool>

Re-hashes a blob and compares it with its name.

Source

pub async fn check_writable(&self) -> AppResult<()>

Checks that the vault directory is writable (used by /readyz).

Source

pub fn uploads_dir(&self) -> PathBuf

Directory of the chunked uploads in progress. It is on the vault’s file system, so a completed upload moves into objects/ atomically.

Source

pub async fn create_staging(&self, session: Uuid) -> AppResult<()>

Creates the (empty) staging file of a chunked upload.

Source

pub async fn write_staged( &self, session: Uuid, offset: u64, chunk: &[u8], ) -> AppResult<()>

Writes a chunk at offset of a staging file and flushes it to disk. Anything behind offset (the rest of an interrupted earlier chunk that was never confirmed) is cut off first, so the file always equals the confirmed bytes plus this chunk.

Source

pub async fn hash_staged(&self, session: Uuid) -> AppResult<StoredBlob>

SHA-256 and length of a staging file (read once, from disk – the chunks may have arrived across server restarts).

Source

pub async fn adopt_staged(&self, session: Uuid, sha256: &str) -> AppResult<()>

Moves a verified staging file to its content address (or drops it if identical content is stored already).

Source

pub async fn remove_staged(&self, session: Uuid) -> AppResult<()>

Removes the staging file of a session (no error if there is none).

Source

pub async fn stale_staged(&self, older_than: Duration) -> AppResult<Vec<Uuid>>

Staging files not changed for older_than, with their session id.

Source

pub async fn object_prefixes(&self) -> AppResult<Vec<String>>

The two-character directories below objects/ (ab of objects/ab/cd/abcd…), sorted – the pages of Vault::objects_in.

Source

pub async fn objects_in(&self, prefix: &str) -> AppResult<Vec<StoredObject>>

The blobs below objects/<prefix>/, with size and modification time. Anything that is not a blob at its content address (another name, a file in the wrong directory) is skipped – and never removed.

Source

pub async fn object_age(&self, sha256: &str) -> AppResult<Option<Duration>>

How long ago a blob was written or last stored again (see Upload::finish); None if there is no such blob.

Source

pub async fn remove_object_older_than( &self, sha256: &str, grace: Duration, ) -> AppResult<bool>

Removes a blob if it was not written or stored again within grace. Only services::retention calls this, after it made sure that the database refers to the blob nowhere. Returns whether it was removed.

Trait Implementations§

Source§

impl Clone for Vault

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Vault

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Vault

§

impl RefUnwindSafe for Vault

§

impl Send for Vault

§

impl Sync for Vault

§

impl Unpin for Vault

§

impl UnsafeUnpin for Vault

§

impl UnwindSafe for Vault

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Parallelizable for T
where T: Send + Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more