|
|
@ -10,13 +10,13 @@ use crate::entity::item::*; |
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
|
|
|
|
|
|
|
pub struct InMemoryGatewayTransaction {
|
|
|
|
pub struct InMemoryGatewayTransaction<'a> {
|
|
|
|
working_gateway: InMemoryGateway,
|
|
|
|
original_gateway: &'static mut InMemoryGateway,
|
|
|
|
original_gateway: &'a mut InMemoryGateway,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl EntityGatewayTransaction for InMemoryGatewayTransaction {
|
|
|
|
impl<'a> EntityGatewayTransaction for InMemoryGatewayTransaction<'a> {
|
|
|
|
fn gateway<'b>(&'b mut self) -> &'b mut dyn EntityGateway {
|
|
|
|
&mut self.working_gateway
|
|
|
|
}
|
|
|
@ -129,7 +129,7 @@ impl InMemoryGateway { |
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl EntityGateway for InMemoryGateway {
|
|
|
|
async fn transaction(&'static mut self) -> Result<Box<dyn EntityGatewayTransaction + 'static>, GatewayError>
|
|
|
|
async fn transaction<'a>(&'a mut self) -> Result<Box<dyn EntityGatewayTransaction + 'a>, GatewayError>
|
|
|
|
{
|
|
|
|
let working_gateway = {
|
|
|
|
let users = self.users.lock().unwrap().clone();
|
|
|
@ -166,10 +166,10 @@ impl EntityGateway for InMemoryGateway { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn with_transaction<F, Fut, R, E>(&'static mut self, func: F) -> Result<R, E>
|
|
|
|
async fn with_transaction<'a, F, Fut, R, E>(&'a mut self, func: F) -> Result<R, E>
|
|
|
|
where
|
|
|
|
Fut: Future<Output = Result<(Box<dyn EntityGatewayTransaction>, R), E>> + Send,
|
|
|
|
F: FnOnce(Box<dyn EntityGatewayTransaction>) -> Fut + Send,
|
|
|
|
Fut: Future<Output = Result<(Box<dyn EntityGatewayTransaction + 'a>, R), E>> + Send + 'a,
|
|
|
|
F: FnOnce(Box<dyn EntityGatewayTransaction + 'a>) -> Fut + Send,
|
|
|
|
R: Send,
|
|
|
|
E: From<GatewayError>,
|
|
|
|
{
|
|
|
|