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