feat: add corex-storage crate for unified storage abstraction

- Introduced corex-storage crate with support for local disk, S3-compatible, and Google Cloud Storage backends.
- Implemented StorageDriver trait for various storage backends.
- Added LocalFileStorage for local disk operations.
- Added S3Storage for S3-compatible object storage with multipart upload support.
- Added GcsStorage for Google Cloud Storage operations.
- Included error handling for storage operations.
- Added tests for each storage backend to ensure functionality.
- Created README.md for documentation and usage examples.
- Added Apache and MIT licenses for open-source compliance.
This commit is contained in:
asepharyana committed 2026-08-28 22:24:18 +07:00
1 parent 6a4b2b8f54
commit db4f277336
47 files changed

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
//! # corex-config
//!
//! A type-safe, dynamic configuration engine: load environment variables,
//! `.env` files, YAML, JSON, or TOML directly into a typed Rust struct, with
//! optional runtime hot-reload.
//!
//! - [`ConfigLoader`] merges any number of file/env sources into a single
//! typed value (files first, environment variables override).
//! - [`DynamicConfig`] wraps a loaded value behind an `RwLock`, optionally
//! watching its source files and swapping in a freshly reloaded value when
//! they change, broadcasting the change to subscribers.
//!
//! ## Example
//!
//! ```no_run
//! use serde::Deserialize;
//! use corex_config::ConfigLoader;
//!
//! #[derive(Debug, Deserialize, Clone)]
//! struct AppConfig {
//! port: u16,
//! database: DatabaseConfig,
//! }
//! #[derive(Debug, Deserialize, Clone)]
//! struct DatabaseConfig {
//! url: String,
//! }
//!
//! let config: AppConfig = ConfigLoader::new()
//! .merge_file("config.yaml".as_ref())
//! .unwrap()
//! .merge_env("APP")
//! .build()
//! .unwrap();
//! ```
pub mod error;
pub mod loader;
#[cfg(feature = "hot-reload")]
pub mod dynamic;
pub use error::ConfigError;
pub use loader::ConfigLoader;
#[cfg(feature = "hot-reload")]
pub use dynamic::DynamicConfig;
/// Marker trait for types loadable by [`ConfigLoader`].
///
/// Blanket-implemented for any `Deserialize + Send + Sync + 'static`.
pub trait Config: for<'de> serde::Deserialize<'de> + Send + Sync + 'static {}
impl<T> Config for T where T: for<'de> serde::Deserialize<'de> + Send + Sync + 'static {}