diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c251582..f832165 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -68,7 +68,7 @@ jobs: env: COLINK_SERVER_MQ_URI: ${{ matrix.mq_uri }} COLINK_SERVER_MQ_API: ${{ matrix.mq_api }} - run: cargo test + run: cargo test --features="storage_macro_dbc" - name: Run tests (standalone) if: ${{ matrix.mq == 'standalone' }} - run: cargo test + run: cargo test --features="storage_macro_dbc" diff --git a/Cargo.toml b/Cargo.toml index fe0c905..694fb07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "colink" -version = "0.3.8" +version = "0.3.9" edition = "2021" description = "CoLink Rust SDK" license = "MIT" @@ -50,4 +50,9 @@ variable_transfer = ["extensions", "remote_storage", "hyper", "jsonwebtoken", "r registry = [] policy_module = [] instant_server = ["reqwest"] -storage_macro = ["async-recursion", "rdbc2"] +storage_macro = ["async-recursion"] +storage_macro_dbc = ["rdbc2"] + +[[test]] +name = "test_storage_macro_dbc" +required-features = ["storage_macro_dbc"] diff --git a/README.md b/README.md index 9b7c947..504d280 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,13 @@ CoLink SDK helps both application and protocol developers access the functionali Add this to your Cargo.toml: ```toml [dependencies] -colink = "0.3.7" +colink = "0.3.9" +``` + +Enable more features in your Cargo.toml +``` +# if you use storage macro dbc +colink = { version = "0.3.9", features = ["storage_macro_dbc"] } ``` ## Getting Started diff --git a/src/application.rs b/src/application.rs index 823d8d4..b6cf6a4 100644 --- a/src/application.rs +++ b/src/application.rs @@ -119,6 +119,13 @@ impl CoLink { Ok(self.core_addr.clone()) } + pub fn get_jwt(&self) -> Result { + if self.jwt.is_empty() { + return Err("jwt not found".to_string()); + } + Ok(self.jwt.clone()) + } + pub fn update_jwt(&mut self, new_jwt: &str) -> Result<(), String> { self.jwt = new_jwt.to_string(); Ok(()) diff --git a/src/extensions/storage_macro.rs b/src/extensions/storage_macro.rs index 3379ff3..fcd5cfb 100644 --- a/src/extensions/storage_macro.rs +++ b/src/extensions/storage_macro.rs @@ -1,10 +1,10 @@ -use crate::StorageEntry; - mod append; mod chunk; +#[cfg(feature = "storage_macro_dbc")] mod dbc; mod fs; mod redis; +use crate::StorageEntry; type Error = Box; @@ -66,7 +66,14 @@ impl crate::application::CoLink { match macro_type.as_str() { "chunk" => self._read_entry_chunk(&string_before).await, "redis" => self._read_entry_redis(&string_before, &string_after).await, + #[cfg(feature = "storage_macro_dbc")] "dbc" => self._read_entry_dbc(&string_before, &string_after).await, + #[cfg(not(feature = "storage_macro_dbc"))] + "dbc" => Err(format!( + "Storage Macro DBC feature not enabled, but found $dbc in key name: {}", + key_name + ) + .into()), "fs" => self._read_entry_fs(&string_before, &string_after).await, _ => Err(format!( "invalid storage macro, found {} in key name {}",