Struct matrix_sdk::encryption::secret_storage::SecretStorage
source · pub struct SecretStorage { /* private fields */ }
e2e-encryption
only.Expand description
A high-level API to manage secret storage.
To get this, use [Client::encryption()::secret_storage()
].
Implementations§
source§impl SecretStorage
impl SecretStorage
sourcepub async fn open_secret_store(
&self,
secret_storage_key: &str,
) -> Result<SecretStore>
pub async fn open_secret_store( &self, secret_storage_key: &str, ) -> Result<SecretStore>
Open the SecretStore
with the given key
.
The secret_storage_key
can be a passphrase or a Base58 encoded secret
storage key.
§Examples
use ruma::events::secret::request::SecretName;
let secret_store = client
.encryption()
.secret_storage()
.open_secret_store("It's a secret to everybody")
.await?;
let my_secret = "Top secret secret";
let my_secret_name = "m.treasure";
secret_store.put_secret(my_secret_name, my_secret);
sourcepub fn create_secret_store(&self) -> CreateStore<'_>
pub fn create_secret_store(&self) -> CreateStore<'_>
Create a new SecretStore
.
The SecretStore
will be protected by a randomly generated key, or
optionally a passphrase can be provided as well.
In both cases, whether a passphrase was provided or not, the key to open
the SecretStore
can be obtained using the
SecretStore::secret_storage_key()
method.
Note: This method will set the new secret storage key as the default
key in the m.secret_storage.default_key
event. All the known secrets
will be re-encrypted and uploaded to the homeserver as well. This
includes the following secrets:
m.cross_signing.master
: The master cross-signing key.m.cross_signing.self_signing
: The self-signing cross-signing key.m.cross_signing.user_signing
: The user-signing cross-signing key.
§Examples
use ruma::events::secret::request::SecretName;
let secret_store = client
.encryption()
.secret_storage()
.create_secret_store()
.await?;
let my_secret = "Top secret secret";
let my_secret_name = SecretName::from("m.treasure");
secret_store.put_secret(my_secret_name, my_secret);
let secret_storage_key = secret_store.secret_storage_key();
println!("Your secret storage key is {secret_storage_key}, save it somewhere safe.");
sourcepub async fn is_enabled(&self) -> Result<bool>
pub async fn is_enabled(&self) -> Result<bool>
Run a network request to find if secret storage is set up for this user.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretStorage
impl !RefUnwindSafe for SecretStorage
impl Send for SecretStorage
impl Sync for SecretStorage
impl Unpin for SecretStorage
impl !UnwindSafe for SecretStorage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CompatExt for T
impl<T> CompatExt for T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more