StorageService

Struct StorageService 

Source
pub struct StorageService { /* private fields */ }
Expand description

Represents an implementation of a StorageService for the local filesystem.

Implementations§

Source§

impl StorageService

Source

pub fn new<P: AsRef<Path>>(path: P) -> StorageService

Creates a new StorageService instance.

Source

pub fn with_config(config: StorageConfig) -> StorageService

Creates a new StorageService instance with a provided configuration object.

Source

pub fn with_resolver<R: ContentTypeResolver + 'static>( self, resolver: R, ) -> StorageService

Updates the given ContentTypeResolver to something else.

Source

pub fn normalize<P: AsRef<Path>>(&self, path: P) -> Result<Option<PathBuf>>

Attempts to normalize a given path and returns a canonical, absolute path. It must follow some strict rules:

  • If the path starts with ./, then it will resolve from StorageConfig::directory if the directory was found. Otherwise, it’ll use the current directory.

  • If the path starts with ~/, then it will resolve from the home directory from etcetera::home_dir.

Trait Implementations§

Source§

impl Clone for StorageService

Source§

fn clone(&self) -> StorageService

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl StorageService for StorageService

Source§

type Error = Error

Represents a generic error to use for errors that could be emitted when calling any function.
Source§

fn name(&self) -> Cow<'static, str>

Returns the name of the storage service. Read more
Source§

fn init<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Optionally initialize this StorageService if it requires initialization, like creating a directory if it doesn’t exist. Read more
Source§

fn open<'life0, 'async_trait, P>( &'life0 self, path: P, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Opens a file in the specified path and returns the contents as Bytes if it existed, otherwise None will be returned to indicate that file doesn’t exist. Read more
Source§

fn blob<'life0, 'async_trait, P>( &'life0 self, path: P, ) -> Pin<Box<dyn Future<Output = Result<Option<Blob>>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Open a file in the given path and returns a Blob structure if the path existed, otherwise None will be returned to indiciate that a file doesn’t exist. Read more
Source§

fn blobs<'life0, 'async_trait, P>( &'life0 self, path: Option<P>, options: Option<ListBlobsRequest>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Blob>>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Iterate over a list of files from a storage service and returns a Vec of Blobs. Read more
Source§

fn delete<'life0, 'async_trait, P>( &'life0 self, path: P, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Deletes a file in a specified path. At the moment, () is returned but bool might be returned to indicate if it actually deleted itself or not. Read more
Source§

fn exists<'life0, 'async_trait, P>( &'life0 self, path: P, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Checks the existence of the file by the specified path. Read more
Source§

fn upload<'life0, 'async_trait, P>( &'life0 self, path: P, options: UploadRequest, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where P: 'async_trait + AsRef<Path> + Send, Self: 'async_trait, 'life0: 'async_trait,

Does a file upload where it writes the byte array as one call and does not do chunking. Read more
Source§

fn healthcheck<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Performs any healthchecks to determine the storage service’s health.

Auto Trait Implementations§

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

Source§

impl<T> Instrument for T

Source§

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

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

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

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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