pub struct TransactionManager { /* private fields */ }Expand description
Manages pending transactions, matching responses to requests by transactionId.
Implementations§
Source§impl TransactionManager
impl TransactionManager
pub fn new() -> Self
Sourcepub async fn create(
&self,
transaction_type: TransactionType,
) -> (String, Receiver<Result<TransactionResult, String>>)
pub async fn create( &self, transaction_type: TransactionType, ) -> (String, Receiver<Result<TransactionResult, String>>)
Create a new transaction, returning (transactionId, receiver). The receiver will get the result when the dylib responds. A timeout task is spawned that rejects after 120 seconds.
Sourcepub async fn resolve(
&self,
transaction_id: &str,
identifier: &str,
data: Option<Value>,
)
pub async fn resolve( &self, transaction_id: &str, identifier: &str, data: Option<Value>, )
Resolve a transaction with the dylib’s response.
Sourcepub async fn reject(&self, transaction_id: &str, error: &str)
pub async fn reject(&self, transaction_id: &str, error: &str)
Reject a transaction with an error message.
Sourcepub async fn is_pending(&self, transaction_id: &str) -> bool
pub async fn is_pending(&self, transaction_id: &str) -> bool
Check if a transaction ID is pending.
Sourcepub async fn pending_count(&self) -> usize
pub async fn pending_count(&self) -> usize
Number of pending transactions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransactionManager
impl !RefUnwindSafe for TransactionManager
impl Send for TransactionManager
impl Sync for TransactionManager
impl Unpin for TransactionManager
impl UnsafeUnpin for TransactionManager
impl !UnwindSafe for TransactionManager
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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