diff --git a/crates/fs/src/config.rs b/crates/fs/src/config.rs index 91eb2d3..a7bcdd8 100644 --- a/crates/fs/src/config.rs +++ b/crates/fs/src/config.rs @@ -21,18 +21,22 @@ use std::path::{Path, PathBuf}; +/// Type alias for [`StorageConfig`]. +#[deprecated(since = "0.9.0", note = "Use the `StorageConfig` struct instead")] +pub type Config = StorageConfig; + /// Represents the main configuration of using the `StorageService` implementation of remi-fs. #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Config { +pub struct StorageConfig { /// [`PathBuf`] to the directory where `remi-fs` can locate files from with the `./` prefix. pub directory: PathBuf, } -impl Config { +impl StorageConfig { /// Creates a new [`Config`] instance. - pub fn new>(path: P) -> Config { - Config { + pub fn new>(path: P) -> StorageConfig { + StorageConfig { directory: path.as_ref().into(), } } diff --git a/crates/fs/src/service.rs b/crates/fs/src/service.rs index e8b5e45..aab0831 100644 --- a/crates/fs/src/service.rs +++ b/crates/fs/src/service.rs @@ -19,7 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -use crate::{default_resolver, Config, ContentTypeResolver}; +use crate::{default_resolver, ContentTypeResolver, StorageConfig}; use remi::{async_trait, Blob, Bytes, Directory, File, ListBlobsRequest, StorageService as _, UploadRequest}; use std::{ borrow::Cow, @@ -38,17 +38,17 @@ use tracing::instrument; #[derive(Clone)] pub struct StorageService { resolver: Arc, - config: Config, + config: StorageConfig, } impl StorageService { /// Creates a new [`StorageService`] instance. pub fn new>(path: P) -> StorageService { - Self::with_config(Config::new(path)) + Self::with_config(StorageConfig::new(path)) } /// Creates a new [`StorageService`] instance with a provided configuration object. - pub fn with_config(config: Config) -> StorageService { + pub fn with_config(config: StorageConfig) -> StorageService { StorageService { resolver: Arc::new(default_resolver), config, diff --git a/crates/gridfs/README.md b/crates/gridfs/README.md index 72d7bfa..85fe9b2 100644 --- a/crates/gridfs/README.md +++ b/crates/gridfs/README.md @@ -26,13 +26,11 @@ use remi::{StorageService as _, UploadRequest}; #[tokio::main] async fn main() { - let storage = StorageService::new(StorageConfig { - // You can customise the MongoDB client here - client_options: mongodb::ClientOptions::builder().servers(vec!["mongodb://localhost:27017"]).build(); + let storage = StorageService::from_conn_string("mongodb://localhost:27017", StorageConfig { bucket: "my-bucket".into(), ..Default::default() - }); + }).await.unwrap(); // Initialize the container. This will: //