mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 13:40:55 -04:00
refactor(indexeddb)!: Use &str for name in public API
This commit is contained in:
committed by
Jonas Platte
parent
4db162b8a2
commit
6bed51f016
@@ -138,7 +138,7 @@ pub struct AccountInfo {
|
||||
|
||||
impl IndexeddbCryptoStore {
|
||||
pub(crate) async fn open_with_store_cipher(
|
||||
prefix: String,
|
||||
prefix: &str,
|
||||
store_cipher: Option<Arc<StoreCipher>>,
|
||||
) -> Result<Self> {
|
||||
let name = format!("{:0}::matrix-sdk-crypto", prefix);
|
||||
@@ -185,7 +185,7 @@ impl IndexeddbCryptoStore {
|
||||
|
||||
/// Open a new `IndexeddbCryptoStore` with default name and no passphrase
|
||||
pub async fn open() -> Result<Self> {
|
||||
IndexeddbCryptoStore::open_with_store_cipher("crypto".to_owned(), None).await
|
||||
IndexeddbCryptoStore::open_with_store_cipher("crypto", None).await
|
||||
}
|
||||
|
||||
fn encode_key<T>(&self, table_name: &str, key: T) -> JsValue
|
||||
@@ -218,7 +218,7 @@ impl IndexeddbCryptoStore {
|
||||
}
|
||||
|
||||
/// Open a new `IndexeddbCryptoStore` with given name and passphrase
|
||||
pub async fn open_with_passphrase(prefix: String, passphrase: &str) -> Result<Self> {
|
||||
pub async fn open_with_passphrase(prefix: &str, passphrase: &str) -> Result<Self> {
|
||||
let name = format!("{:0}::matrix-sdk-crypto-meta", prefix);
|
||||
|
||||
let mut db_req: OpenDbRequest = IdbDatabase::open_f64(&name, 1.0)?;
|
||||
@@ -270,7 +270,7 @@ impl IndexeddbCryptoStore {
|
||||
}
|
||||
|
||||
/// Open a new `IndexeddbCryptoStore` with given name and no passphrase
|
||||
pub async fn open_with_name(name: String) -> Result<Self> {
|
||||
pub async fn open_with_name(name: &str) -> Result<Self> {
|
||||
IndexeddbCryptoStore::open_with_store_cipher(name, None).await
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,11 @@ pub use state_store::{
|
||||
/// same name and passphrase.
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
async fn open_stores_with_name(
|
||||
name: impl Into<String>,
|
||||
name: &str,
|
||||
passphrase: Option<&str>,
|
||||
) -> Result<(IndexeddbStateStore, IndexeddbCryptoStore), OpenStoreError> {
|
||||
let name = name.into();
|
||||
let mut builder = IndexeddbStateStore::builder();
|
||||
builder.name(name.clone());
|
||||
builder.name(name.to_owned());
|
||||
|
||||
if let Some(passphrase) = passphrase {
|
||||
builder.passphrase(passphrase.to_owned());
|
||||
@@ -42,13 +41,11 @@ async fn open_stores_with_name(
|
||||
/// that uses the given name and passphrase. If `encryption` is enabled, a
|
||||
/// [`IndexeddbCryptoStore`] with the same parameters is also opened.
|
||||
pub async fn make_store_config(
|
||||
name: impl Into<String>,
|
||||
name: &str,
|
||||
passphrase: Option<&str>,
|
||||
) -> Result<StoreConfig, OpenStoreError> {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
let name = name.into();
|
||||
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
{
|
||||
let (state_store, crypto_store) = open_stores_with_name(name, passphrase).await?;
|
||||
@@ -58,7 +55,7 @@ pub async fn make_store_config(
|
||||
#[cfg(not(feature = "e2e-encryption"))]
|
||||
{
|
||||
let mut builder = IndexeddbStateStore::builder();
|
||||
builder.name(name.clone());
|
||||
builder.name(name.to_owned());
|
||||
|
||||
if let Some(passphrase) = passphrase {
|
||||
builder.passphrase(passphrase.to_owned());
|
||||
|
||||
@@ -141,7 +141,7 @@ impl ClientBuilder {
|
||||
#[cfg(feature = "indexeddb")]
|
||||
pub async fn indexeddb_store(
|
||||
self,
|
||||
name: impl Into<String>,
|
||||
name: &str,
|
||||
passphrase: Option<&str>,
|
||||
) -> Result<Self, matrix_sdk_indexeddb::OpenStoreError> {
|
||||
let config = matrix_sdk_indexeddb::make_store_config(name, passphrase).await?;
|
||||
|
||||
Reference in New Issue
Block a user