pub struct Vault { /* private fields */ }Implementations§
Source§impl Vault
impl Vault
Sourcepub async fn open(root: impl Into<PathBuf>) -> Result<Vault>
pub async fn open(root: impl Into<PathBuf>) -> Result<Vault>
Creates the directory layout (if needed) and removes stale temporary files.
pub fn root(&self) -> &Path
Sourcepub fn with_scanner(self, scanner: Option<ScannerConfig>) -> Vault
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.
pub fn tmp_dir(&self) -> PathBuf
Sourcepub fn object_path(&self, sha256: &str) -> AppResult<PathBuf>
pub fn object_path(&self, sha256: &str) -> AppResult<PathBuf>
Path of the blob with the given hash. The hash must be validated hex.
Sourcepub async fn begin_upload(&self, max_bytes: u64) -> AppResult<Upload>
pub async fn begin_upload(&self, max_bytes: u64) -> AppResult<Upload>
Starts a streaming upload limited to max_bytes.
Sourcepub async fn store_bytes(&self, data: &[u8]) -> AppResult<StoredBlob>
pub async fn store_bytes(&self, data: &[u8]) -> AppResult<StoredBlob>
Stores a complete in-memory buffer (used by tests and small imports).
pub async fn open_blob(&self, sha256: &str) -> AppResult<File>
pub async fn exists(&self, sha256: &str) -> bool
Sourcepub async fn verify(&self, sha256: &str) -> AppResult<bool>
pub async fn verify(&self, sha256: &str) -> AppResult<bool>
Re-hashes a blob and compares it with its name.
Sourcepub async fn check_writable(&self) -> AppResult<()>
pub async fn check_writable(&self) -> AppResult<()>
Checks that the vault directory is writable (used by /readyz).
Sourcepub fn uploads_dir(&self) -> PathBuf
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.
Sourcepub async fn create_staging(&self, session: Uuid) -> AppResult<()>
pub async fn create_staging(&self, session: Uuid) -> AppResult<()>
Creates the (empty) staging file of a chunked upload.
Sourcepub async fn write_staged(
&self,
session: Uuid,
offset: u64,
chunk: &[u8],
) -> AppResult<()>
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.
Sourcepub async fn hash_staged(&self, session: Uuid) -> AppResult<StoredBlob>
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).
Sourcepub async fn adopt_staged(&self, session: Uuid, sha256: &str) -> AppResult<()>
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).
Sourcepub async fn remove_staged(&self, session: Uuid) -> AppResult<()>
pub async fn remove_staged(&self, session: Uuid) -> AppResult<()>
Removes the staging file of a session (no error if there is none).
Sourcepub async fn stale_staged(&self, older_than: Duration) -> AppResult<Vec<Uuid>>
pub async fn stale_staged(&self, older_than: Duration) -> AppResult<Vec<Uuid>>
Staging files not changed for older_than, with their session id.
Sourcepub async fn object_prefixes(&self) -> AppResult<Vec<String>>
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.
Sourcepub async fn objects_in(&self, prefix: &str) -> AppResult<Vec<StoredObject>>
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.
Sourcepub async fn object_age(&self, sha256: &str) -> AppResult<Option<Duration>>
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.
Sourcepub async fn remove_object_older_than(
&self,
sha256: &str,
grace: Duration,
) -> AppResult<bool>
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§
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> Parallelizable for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.