Struct remi_fs::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: Config) -> 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 Config::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 dirs::home_dir.

Trait Implementations§

source§

impl Clone for StorageService

source§

fn clone(&self) -> StorageService

Returns a copy 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

§

type Error = Error

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

const NAME: &'static str = "remi:fs"

The name of the storage service.
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. Use the [StorageService::multipart_upload] method to upload chunks by a specific size. Read more
source§

fn name(&self) -> &'static str

👎Deprecated since 0.5.0: use Self::NAME instead of the name() function, this will be removed in 0.7.0
Returns the name of this StorageService.
source§

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

Attempt to find a blob from a Blob where it returns the first blob that was found. A default implementation is given which just queries all blobs via StorageService::blobs and uses the find method. Read more

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

§

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

§

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

§

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