pub enum Store {
Disk(PathBuf),
S3(S3Signer),
}Expand description
Where uploaded files are kept: a folder (development, tests) or an S3
bucket. Keys are paths such as comments/12/thumb/shelf.png.
Variants§
Implementations§
Source§impl Store
impl Store
Sourcepub async fn delete(&self, key: &str) -> Result<()>
pub async fn delete(&self, key: &str) -> Result<()>
Removes key; removing a missing file is fine.
§Errors
If it can’t be removed, or S3 can’t be reached.
Sourcepub async fn size(&self, key: &str) -> Result<Option<u64>>
pub async fn size(&self, key: &str) -> Result<Option<u64>>
The size in bytes of the file saved as key, if there is one.
§Errors
If the folder can’t be read, or S3 can’t be reached.
Sourcepub async fn rename(&self, from: &str, to: &str) -> Result<()>
pub async fn rename(&self, from: &str, to: &str) -> Result<()>
Moves the file saved as from to to (move is Rust’s keyword).
§Errors
If from is missing, or the move fails.
Sourcepub async fn list(&self, prefix: &str) -> Result<Vec<String>>
pub async fn list(&self, prefix: &str) -> Result<Vec<String>>
The keys of every file under prefix ("" for all), sorted:
list("comments/12/").
§Errors
If the folder can’t be read, or S3 can’t be reached.
Sourcepub fn signed_url(&self, key: &str, expires_in: u64) -> String
pub fn signed_url(&self, key: &str, expires_in: u64) -> String
A link to key that works for expires_in seconds and no longer,
for a private file: a presigned URL on S3, or on disk
/files/<key>?token=…, which SignedFiles
serves.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
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
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
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 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> ⓘ
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