chore(API, AppServer): Deal with CryptoServer being uninit.

Before this, we would just raise an error.
This commit is contained in:
Karolin Varner
2024-08-09 21:07:59 +02:00
parent 5f6c36e773
commit 48f7ff93e3
9 changed files with 498 additions and 25 deletions

View File

@@ -92,3 +92,47 @@ impl<T> Drop for Forgetting<T> {
forget(value)
}
}
pub trait DiscardResultExt {
fn discard_result(self);
}
impl<T> DiscardResultExt for T {
fn discard_result(self) {}
}
pub trait ForgetExt {
fn forget(self);
}
impl<T> ForgetExt for T {
fn forget(self) {
std::mem::forget(self)
}
}
pub trait SwapWithExt {
fn swap_with(&mut self, other: Self) -> Self;
fn swap_with_mut(&mut self, other: &mut Self);
}
impl<T> SwapWithExt for T {
fn swap_with(&mut self, mut other: Self) -> Self {
self.swap_with_mut(&mut other);
other
}
fn swap_with_mut(&mut self, other: &mut Self) {
std::mem::swap(self, other)
}
}
pub trait SwapWithDefaultExt {
fn swap_with_default(&mut self) -> Self;
}
impl<T: Default> SwapWithDefaultExt for T {
fn swap_with_default(&mut self) -> Self {
self.swap_with(Self::default())
}
}