pub struct Txn<State> { /* private fields */ }
Expand description
A transaction context.
Implementations§
Source§impl<State> Txn<State>where
State: StateInstance<FE = CacheBlock, Txn = Self>,
impl<State> Txn<State>where
State: StateInstance<FE = CacheBlock, Txn = Self>,
Sourcepub fn request(&self) -> &Request
pub fn request(&self) -> &Request
Return the [Request
] which initiated this transaction on this host.
Sourcepub fn grant(
&self,
actor: &Actor,
cluster_path: TCPathBuf,
scopes: Vec<TCPathBuf>,
) -> TCResult<Self>
pub fn grant( &self, actor: &Actor, cluster_path: TCPathBuf, scopes: Vec<TCPathBuf>, ) -> TCResult<Self>
Return a new Txn
which grants the given [Scope
]s to the given Actor
.
Sourcepub fn claim(self, actor: &Actor, cluster_path: TCPathBuf) -> TCResult<Self>
pub fn claim(self, actor: &Actor, cluster_path: TCPathBuf) -> TCResult<Self>
Claim ownership of this transaction.
Sourcepub fn is_owner(&self, cluster_path: &[PathSegment]) -> bool
pub fn is_owner(&self, cluster_path: &[PathSegment]) -> bool
Check if the cluster at the specified path on this host is the owner of the transaction.
Sourcepub fn has_leader(&self, cluster_path: &[PathSegment]) -> bool
pub fn has_leader(&self, cluster_path: &[PathSegment]) -> bool
Check if this transaction has a leader for the given cluster.
Sourcepub fn is_leader(&self, cluster_path: &[PathSegment]) -> bool
pub fn is_leader(&self, cluster_path: &[PathSegment]) -> bool
Check if this host is leading the transaction for the specified cluster.
Sourcepub fn lead(self, actor: &Actor, cluster_path: TCPathBuf) -> TCResult<Self>
pub fn lead(self, actor: &Actor, cluster_path: TCPathBuf) -> TCResult<Self>
Claim leadership of this transaction for the given cluster.
Sourcepub fn leader(&self, cluster_path: &[PathSegment]) -> Option<&Link>
pub fn leader(&self, cluster_path: &[PathSegment]) -> Option<&Link>
Return the leader of this transaction for the given cluster, if there is one.
Trait Implementations§
Source§impl<State> RPCClient<State> for Txn<State>where
State: StateInstance<FE = CacheBlock, Txn = Self>,
impl<State> RPCClient<State> for Txn<State>where
State: StateInstance<FE = CacheBlock, Txn = Self>,
Source§fn get<'a, 'async_trait, L, V>(
&'a self,
link: L,
key: V,
) -> Pin<Box<dyn Future<Output = TCResult<State>> + Send + 'async_trait>>
fn get<'a, 'async_trait, L, V>( &'a self, link: L, key: V, ) -> Pin<Box<dyn Future<Output = TCResult<State>> + Send + 'async_trait>>
Resolve a GET op within this transaction context.
Source§fn put<'a, 'async_trait, L, K, V>(
&'a self,
link: L,
key: K,
value: V,
) -> Pin<Box<dyn Future<Output = TCResult<()>> + Send + 'async_trait>>
fn put<'a, 'async_trait, L, K, V>( &'a self, link: L, key: K, value: V, ) -> Pin<Box<dyn Future<Output = TCResult<()>> + Send + 'async_trait>>
Resolve a PUT op within this transaction context.
Source§fn post<'a, 'async_trait, L, P>(
&'a self,
link: L,
params: P,
) -> Pin<Box<dyn Future<Output = TCResult<State>> + Send + 'async_trait>>
fn post<'a, 'async_trait, L, P>( &'a self, link: L, params: P, ) -> Pin<Box<dyn Future<Output = TCResult<State>> + Send + 'async_trait>>
Resolve a POST op within this transaction context.
Source§impl<State: Clone + 'static> Transaction<CacheBlock> for Txn<State>
impl<State: Clone + 'static> Transaction<CacheBlock> for Txn<State>
Source§fn context<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = TCResult<DirLock<CacheBlock>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn context<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = TCResult<DirLock<CacheBlock>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Allows locking the filesystem directory of this transaction context,
e.g. to cache un-committed state or to compute an intermediate result.
Source§fn subcontext<I: Into<Id> + Send>(&self, id: I) -> Self
fn subcontext<I: Into<Id> + Send>(&self, id: I) -> Self
Create a new transaction context with the given
id
.Source§fn subcontext_unique(&self) -> Self
fn subcontext_unique(&self) -> Self
Create a new transaction subcontext with its own unique [
Dir
].Auto Trait Implementations§
impl<State> Freeze for Txn<State>
impl<State> !RefUnwindSafe for Txn<State>
impl<State> Send for Txn<State>
impl<State> Sync for Txn<State>
impl<State> Unpin for Txn<State>
impl<State> !UnwindSafe for Txn<State>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<F> Match for F
impl<F> Match for F
Source§fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
Returns
true
if self
can be cast into the target type T
.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
Source§fn can_cast_from(_: &F) -> bool
fn can_cast_from(_: &F) -> bool
Test if
value
can be cast into Self
.Source§fn opt_cast_from(f: F) -> Option<T>
fn opt_cast_from(f: F) -> Option<T>
Returns
Some(Self)
if the source value can be cast into Self
, otherwise None
.Source§impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
Source§fn can_cast_into(&self) -> bool
fn can_cast_into(&self) -> bool
Test if
self
can be cast into T
.Source§fn opt_cast_into(self) -> Option<T>
fn opt_cast_into(self) -> Option<T>
Returns
Some(T)
if self
can be cast into T
, otherwise None
.Source§fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
Returns
Ok(T)
if self
can be cast into T
, otherwise calls on_err
.